Trouble reloading textures in linux

Hey guys… I’m having a little trouble doing some texture stuff and was wondering if you’d help me out.

I want to add a menu entry for toggling MIP MAPS. What I wrote works fine in windows, but when I try it in linux all my textures turn white. I am using GLUT.

BOOL initTextures(GLuint texs)
{
RGBIMG image; /* temporary tex container */

glGenTextures(TEX_NUMBER, texs);/* initialize texture array */

if(!loadImage(“floor.raw”, 128, 128, &image))/* load ground tex /
{
fprintf(stderr, "Error opening file ‘floor.raw’
");
return FALSE;
}
glBindTexture(GL_TEXTURE_2D, texs[FLOOR]);/
bind tex /
parameterizeTexture(&image); /
set tex drawing parameters */

free(image.data); /* no longer need image, so free /
return TRUE; /
SUCCESS */

} /* end initTextures() */

void reloadTextures(GLuint texs)
{
glDeleteTextures(TEX_NUMBER, texs);
initTextures(texs);

} /* end reloadTextures() */

/* the following parameters are common to all textures */
void parameterizeTexture(const RGBIMG i)
{
/
this function does not bind textures, binding must be done before
calling this function /
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);/
texs are single byte aligned */

/* now we generate the mipmaps for the textures. this makes everything
look better (in windows) */
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, i->width, i->height, GL_RGB,
GL_UNSIGNED_BYTE, i->data);

if(useMipMaps)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
}
else /* useMipMaps == FALSE */
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}

/* the following line takes the byte image of our texture, stored in
i->data and copies it to video memory so we can use it */
glTexImage2D(GL_TEXTURE_2D, 0, 3, i->width, i->height, 0,
GL_RGB, GL_UNSIGNED_BYTE, i->data);

} /* end parameterizeTextures() */

What happens is when I hit the menu it flips the useMipMaps bit (either true/false), then calls reloadTextures() which deletes any resident textures and reloads them with mip mapping either enabled or disabled.

What’s getting me is that it works fine in windows, but not in linux. The loadImage() functions works fine, that just loads a RAW image into memory.

Does anyone have any idea why this won’t work? If you need more code I’ll supply.

Thanks for any help guys!
Greg

Sorry guys… I figured it out… I was calling glGenTextures() over and over when I should have only called it once.

Funny that it worked in windows, though.

Also bear in mind that Build2DMipmaps builds and uploads the mipmaps(including the full texture) so you should better do something like:

if(usemipmaps){
set texparams;
build2dmipmaps;
}else{
set texparams;
loadteximage2d;
}