Jump to content
  • Advertisement
Sign in to follow this  
leiavoia

OpenGL Displaying a 2D tilemap

This topic is 5465 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

let's say i have a 2D tilebased game. The map is 100x100 and i can only display about ~20x20 of those on the screen at any given time. The normal way to do this is to loop through the tilemap[x][y] and only render the tiles that are in the screen area. Whould it be faster or slower to shove the data for all the textured quads of the tilemap into a display list and just render the display list every frame? (letting OpenGL clip out the off-screen parts?) I ask because i don't know much about what OpenGL is doing with my display lists behind my back.

Share this post


Link to post
Share on other sites
Advertisement
i found that sticking all the tiles into a vertex array and rendering the screen of tiles in a single call to DrawArrays() (or whatever, its been awhile since ive looked at that code =) gave me an increase in speed on the machines i tested it on.

im curious if display list's would be faster too.

Share this post


Link to post
Share on other sites
>>Whould it be faster or slower to shove the data for all the textured quads of the tilemap into a display list and just render the display list every frame? (letting OpenGL clip out the off-screen parts?)<<

prolly not, youre only drawing 20x20=400 quads

>>The normal way to do this is to loop through the tilemap[x][y] and only render the tiles that are in the screen area.<<
now how are u drawing them if i read u right your looping through the tiles like so
looop all tiles
{
set this tiles material/texture etc
draw the tile
}

now this is gonna be a lot slower than drawing all the tiles onscreen first that use textureA and then all the tiles that use textureB.

i just posted something about this in a nother thread just a minute ago see 'serious speed decrease' thread

Share this post


Link to post
Share on other sites
I have just finished my map 2d rendering, I have all the ground textures on one texture, that saved me a lot of texture switching. and sped up my rendering. Then I have all my overlay textures on one texture.

I do multiple passes on the map but its much faster then when I was passing a pointer to a texture to the renderer. also I now draw only a little over the window size and let OpenGL clip but instead of rendering 10000 tiles I am now rendering about 160 tiles.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!