Jump to content
  • Advertisement
Sign in to follow this  
shane1985

OpenGL Tile Map Performance Questions

This topic is 4830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the fastest way to render a 2d tile map in openGL. Right now I just loop through the matrix and render each tile with a function I call, although it seems like it's running pretty slow, since I'm only rendering 768 textured quads. What are the potential bottlenecks of this system, and what sorts of things could I do to speed it up? Thanks -Shane

Share this post


Link to post
Share on other sites
Advertisement
Off the top of my head, you should optimize the system by only drawing what you will be seeing...Shouldn't be too difficult and it will boost performance. How big are these quads?

Some code would help a lot.

Share this post


Link to post
Share on other sites
In my engine I check which tiles are visible and only render those. I don't know if your doing this already, but it also user only one texture per layer. This saves a lot of texture swaps and thus some time.

Share this post


Link to post
Share on other sites
Little hint: If your drawing a lot of the same things use lists or vertex buffers or Vertex Buffer Objects

(look for any of those things + Opengl on google and youll find a lot)

Share this post


Link to post
Share on other sites
Sorry I haven't responded more quickly, but after I posted, I realized one of the major problems was my switching the texture ID for every tile. This is obviously a stupid way to do it, so I did a quick sort based on the texture ID. Once I did that, I also found a few other problems, and now my frame rate is where I would expect it to be. Thanks for your replies anyway!

(I realize now my post was a little hasty, but I was frustrated after spending too much time fixing the wrong "bottlenecks"!)

-Shane

Share this post


Link to post
Share on other sites
You could directly draw the map onto the texture, and then use only 2 triangles.

Share this post


Link to post
Share on other sites
Or the other way around. Add all the little tiles in one big map, so that you don't have to swap textures at all. Thats how I do it in my engine at least. With this method I get a framerate of 400+ including dynamic lighting (no shadows).

[Edited by - jeroenb on July 31, 2005 2:41:48 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!