Hello
I've mainly used things like GDI and SDL to do graphics, I've now started to use openGL but I can't get my head around some things -- I've read books and articles all over the place too.
Hypothetically say I want to show 1,000,000 (1000x1000) tiles. My program renders the openGL scene as quickly as possible in a big loop, should I be rendering all 1,000,000 tiles (every frame...)? (Even though they're out of the viewport).
Such as
Code:
____________
|-----------*|
| |
| #######|*************
| #######|*** to 1000 >
|_____#######|*************
*********************
*********************
*****to 1000 down****
*********************
? Where # are visible tiles and * are out of view.
Am I supposed to just describe the scene and let openGL handle the rest? Or shouldn't I be drawing quads for the out of view tiles? Like:
Code:
static void renderMap(void)
{
int r = 0, c = 0;
for(r = 0; r < rows; r++)
{
for(c = 0; c < cols; c++)
{
/* render each tile for the current row/col */
glBegin(GL_QUADS);
glVertex3f();
glVertex3f();
glVertex3f();
glVertex3f();
glEnd();
}
}
}
Which is called every frame :\, 1,000,000 tiles -- am I supposed to do that, or only redraw specific ones?
I plan to move around the map (in the little visible section on the screen). In GDI I'd only render what I could see (per frame), I assume it's different for GL?
Thanks