Original Post
Hello,
I'm currently using the following code for allocating textures in my game. It is called once per texture (which is enumerated using ANSI _findfirst() and _findnext()):
This is done between calls for glBegin(GL_QUADS) and glEnd(). gGetTextureID() loops through the array of available textures, looking for the proper string, and returning the OpenGL texture ID (generated from glGenTextures()).
The problem here is that, no matter how many textures are added to the list, the renderer ALWAYS chooses the last-loaded texture. I am confused; should each glGenTextures() call generate a unique texture, for which the data is dependent on the call to auxDIBImageLoad()? Maybe I should be using glGenTextures() only once, allocating an array of textures?
I don't know if this is a limitation of my OpenGL implementation (in Windows 2000), my video card (Voodoo3 3000 AGP), or PEBKAC.
Help?
MatrixCubed
http://MatrixCubed.cjb.net [edited by - MatrixCubed on June 12, 2002 5:10:40 PM]
AUX_RGBImageRec* lptex;
lptex = auxDIBImageLoad(szName);
glGenTextures(1, &(g_lpTextureList[i].iID));
glBindTexture(GL_TEXTURE_2D, g_lpTextureList[i].iID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, lptex->sizeX, lptex->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, lptex->data);
The list of textures (g_lpTextureList) is simply an array of structures which only holds filenames and OpenGL-generated texture IDs.
Then, per tile that I render, I call the following code:
glBindTexture(GL_TEXTURE_2D, gGetTextureID(szName));
glColor3f(1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(x, g_dwHeight - y - h, z);
glTexCoord2f(1.0f, 0.0f); glVertex3f(x + w, g_dwHeight - y - h, z);
glTexCoord2f(1.0f, 1.0f); glVertex3f(x + w, g_dwHeight - y, z);
glTexCoord2f(0.0f, 1.0f); glVertex3f(x, g_dwHeight - y, z);
http://MatrixCubed.cjb.net [edited by - MatrixCubed on June 12, 2002 5:10:40 PM]