Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: General question about sf::texture  (Read 1350 times)

0 Members and 1 Guest are viewing this topic.

hipsterdufus

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
General question about sf::texture
« on: August 11, 2013, 08:26:31 am »
Hi all, just a question about how this sort of thing is usually done. I have a list of "tiles" that make up my level. Should each tile have it's own sf::Texture or should the sf::Texture be contained in my "level" class. Seems kind of wasteful when each object is going to have a copy of the same texture ("tileset.png") but without owning its own copy I'm not sure how each one can individually draw itself if it wants to. I'm trying to use a big vertex array instead of sprites to draw the map btw so I'm rethinking my entire design. Any tips on how this should be done?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: General question about sf::texture
« Reply #1 on: August 11, 2013, 10:11:38 am »
You definitely want to use just one texture with all the tiles if you can, since that means only one draw() call for all of your tiles once you get the right vertex array set up.

The tutorials actually give an example for tile maps specifically, so start there: http://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php#example-tile-map

hipsterdufus

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: General question about sf::texture
« Reply #2 on: August 11, 2013, 10:53:18 am »
Yes I've been trying to use that example a lot. It just seems weird to have the texture defined at a higher level. To me, it's more intuitive for each low level object to have its own texture. I guess it's something I need to get used to.

 

anything