SFML community forums
Help => Graphics => Topic started by: Jimmyee on May 09, 2013, 06:50:18 pm
-
Hello. I've been trying to render a map without lose of CPU. Some day I found this: http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php (http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php) It's a good tutorial but it didn't help me at all and there is my question: how can I render a map using vertex arrays with use of multiple textures loaded from files? My map tiles are saved in several files and I don't want to call draw() so often but only once. Should I join all the textures to a big one (if it's possible) and use it?
-
You either have one vertex array per texture, so you can draw each one with each texture, or you use some tilemaps, grouping all the textures into one.
There aren't any good workarounds to this problem :)
-
Yes, this is what I was doing last time - each tile had it's individual verticles initialized in the class constructor and the texture was chosen using the tile ID number, then they all were drawn in a MapRender class in a big loop. It's still slow so I'm just gonna use one texture for now... Until I don't find better solution :)
-
Should I join all the textures to a big one (if it's possible) and use it?
Of course you should! If the texture is not too big.
-
Oh OK. I found found needed functions.
Thank you for your opinions!
By the way, I'm new so I should tell you who I am.
I am Charlie and I'm from Poland, 20 years old. I'm making a 2D RPG using the SFML 2.0 engine. It gonna be MMO in the future but first I have to master all the functions of SFML I need. I'm a C++ programmer for like 5 years now but I don't feel like experienced with making games :P