Original Post
Hello! I've pretty much worked this out and everything renders as I want it to. I've written a quick and dirty little test app (with a bunch of hardcoded stuff; I just want to test the end result before I go through with this for my game) to render a tile-based map in OpenGL. Basically I have a texture containing a series of 16x16 tiles (oldschool SNES style :) ) and I map them to a grid of quads. Simple enough, works like a charm, and gives me the results I want. The problem, sloppy just-work-and-we'll-worry-about-writing-good-code-later listing aside, lies in the tediousness associated with mapping the right tile onto my quads. Here's an example (again, everything has been hard-coded in a "just work" way; I don't have my map format up yet). Aside from the fact this is sloppy (and not in a for.. loop, but hey, it's a bloody test ;) ) it feels like I'm wasting a lot of time reassigning texture coordinates all the time like that. The end result will read stuff from a map file. However, am I going to have to reassign the coordinates every tile? Is there a way to just do it once (and if so, should I order tiles by texture? Remember they all use the same texture, just with different coordinates to select the right tile to display, and there's no way I'm gonna drag around a few thousand 16x16 bitmaps ;) ) Any pointers would be quite appreciated. :) Thanks!
glBindTexture(GL_TEXTURE_2D, Texture[0]);
glBegin(GL_QUADS);
glTexCoord2f(0.533f, 0.733f); glVertex3f(-10.0f, -2.0f, -10.0f);
glTexCoord2f(0.466f, 0.733f); glVertex3f( -8.0f, -1.0f, -10.0f);
glTexCoord2f(0.466f, 0.666f); glVertex3f( -8.0f, -1.0f, -8.0f);
glTexCoord2f(0.533f, 0.666f); glVertex3f(-10.0f, -1.0f, -8.0f);
glTexCoord2f(0.533f, 0.733f); glVertex3f(-10.0f, -1.0f, -8.0f);
glTexCoord2f(0.466f, 0.733f); glVertex3f( -8.0f, -1.0f, -8.0f);
glTexCoord2f(0.466f, 0.666f); glVertex3f( -8.0f, 0.0f, -6.0f);
glTexCoord2f(0.533f, 0.666f); glVertex3f(-10.0f, 0.0f, -6.0f);
glTexCoord2f(0.533f, 0.733f); glVertex3f(-8.0f, -1.0f, -10.0f);
glTexCoord2f(0.466f, 0.733f); glVertex3f(-6.0f, 0.0f, -10.0f);
glTexCoord2f(0.466f, 0.666f); glVertex3f(-6.0f, 0.0f, -8.0f);
glTexCoord2f(0.533f, 0.666f); glVertex3f(-8.0f, -1.0f, -8.0f);
...