OpenGL question

Member
Posts: 105
Joined: 2007.03
Post: #1
Okay I'm very unclear with the inner workings of opnegl and have a fairly simple question. If Im drawing an isometric tile map using textured quads, and my code is such:

Code:
for (x = 0; x < kMapWidth; x++)
{
     for (y = 0; y < kMapWidth; y++)
     {
         DrawTile(x,y);
     }
}


does opengl automatically draw the whole map and then only display the visible portion? or will it figure out the visible portion and only draw that?
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.11
Post: #2
OpenGL only draws the visible portion but it still runs through the drawing functions to some extent for off screen stuff. I would suggest only drawing the tiles that are on screen.
Code:
for (x = minTileOnScreenX; x < maxTileOnScreenX; x++)
{
    for (y = minTileOnScreenY; y < maxTileOnScreenY; y++)
    {
        DrawTile(x,y);
    }
}

You'll have to figure out the min and max tiles on screen. This should speed up drawing larger maps. Smaller maps may not be noticeably faster.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #3
Leroy, what your talking about is called object culling. OpenGL (normally) only does pixel culling.

Culling is something used normally in large scale games, and you should become acquainted with it.

Global warming is caused by hobos and mooses
Quote this message in a reply
Post Reply