I posted this on the beginners board since I originally thought it was a beginners question, but I never got a reply, so it obviously went over their heads, so I’ll post here.
I am trying to load multiple textures when the level loads, but for some reason, once the bitmaps are loaded, one of the two is invisible, like the polygons with that texture aren’t even drawn! Here is the source, maybe you’ll spot something i am just over-looking…
//MAX_TEXTURES is 256 right now
//Global vars
char texlist[MAX_TEXTURES][32];
GLuint texture[MAX_TEXTURES];//This is called when drawing the screen
unsigned long FindTexture(char *texname)
{
char texbuf[32];sprintf(texbuf, “%s”, texname);
for(unsigned long loop = 0; loop < MAX_TEXTURES; loop++)
if(strstr(texlist[loop], texbuf) != NULL)
return (loop + 1);return 1;
}//This is my loading routine
BOOL LoadBMP()
{
char texbuf[256];
int texnum = 0;
BOOL status;
GLubyte fixer, image[32][32][3];
FILE *texfile;
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;for(unsigned long loop = 0; loop < area.numObjects; loop++)
{
status = TRUE;
for(unsigned long t_loop = 0; t_loop < MAX_TEXTURES; t_loop++)
{
if(strstr(texlist[t_loop], area.object[loop].Texture) != NULL)
{
status = FALSE;
}
}
if(status)
{
sprintf(texlist[texnum], “%s”, area.object[loop].Texture);
texnum++;
}
}glGenTextures(texnum, &texture[0]);
for(unsigned long loop = 0; loop < texnum; loop++)
{
MessageBox(glwnd, texlist[loop], “LoadBMP(unsigned long)”, MB_OK);
sprintf(texbuf, “Textures\%s”, texlist[loop]);
if((texfile = fopen(texbuf, “rb”)) == NULL)
return FALSE;fread(&bmfh, sizeof(BITMAPFILEHEADER), 1, texfile); fread(&bmih, sizeof(BITMAPINFOHEADER), 1, texfile); fread(&image, sizeof(image), 1, texfile); fclose(texfile); for(short int x_loop = 0; x_loop < 32; x_loop++) { for(short int y_loop = 0; y_loop < 32; y_loop++) { fixer = image[y_loop][x_loop][0]; image[y_loop][x_loop][0] = image[y_loop][x_loop][2]; image[y_loop][x_loop][2] = fixer; } } glBindTexture(GL_TEXTURE_2D, texture[loop]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, 32, 32, GL_RGB, GL_UNSIGNED_BYTE, image); }
return TRUE;
}//And here’s the drawing routine
glNormal3f(0.0f, 0.0f, 1.0f);
for(unsigned long o_loop = 0; o_loop < area.numObjects; o_loop++)
{
glBindTexture(GL_TEXTURE_2D, FindTexture(area.object[o_loop].Texture));
glBegin(GL_TRIANGLES);
for(int t_loop = 0; t_loop < area.object[o_loop].numTriangles; t_loop++)
{
glTexCoord2f(area.object[o_loop].triangle[t_loop].vertex[0].u, area.object[o_loop].triangle[t_loop].vertex[0].v);
glVertex3f(area.object[o_loop].triangle[t_loop].vertex[0].x, area.object[o_loop].triangle[t_loop].vertex[0].y, area.object[o_loop].triangle[t_loop].vertex[0].z);glTexCoord2f(area.object[o_loop].triangle[t_loop].vertex[1].u, area.object[o_loop].triangle[t_loop].vertex[1].v); glVertex3f(area.object[o_loop].triangle[t_loop].vertex[1].x, area.object[o_loop].triangle[t_loop].vertex[1].y, area.object[o_loop].triangle[t_loop].vertex[1].z); glTexCoord2f(area.object[o_loop].triangle[t_loop].vertex[2].u, area.object[o_loop].triangle[t_loop].vertex[2].v); glVertex3f(area.object[o_loop].triangle[t_loop].vertex[2].x, area.object[o_loop].triangle[t_loop].vertex[2].y, area.object[o_loop].triangle[t_loop].vertex[2].z); } glEnd(); }
Now my small 512w128h512l room only loads two textures, one for the walls and one for the ceiling/floor. The ceiling/floor texture works perfectly, while it acts as though my wall polygons aren’t even drawn! Any ideas?