PDA

View Full Version : Help! Problem about Glut



Dickie
09-21-2003, 05:21 AM
I was studying NEHE's tutorial recently and I try to rewrite his code using glub. it went on smoothly at first but i meet a problem when dealing with multi-texture.

i write my LoadTexture as Below:

bool LoadMyTextures()
{
AUX_RGBImageRec* TextureImage[MyTexNum];
memset(TextureImage,0,sizeof(void*) * MyTexNum);
for (int i = 1;i <= MyTexNum;i++) {
glGenTextures(i,&MyTexture[i - 1]);
if ((TextureImage[i - 1] = auxDIBImageLoad(MyTexFile[i - 1])) == NULL)
return false;
glBindTexture(GL_TEXTURE_2D,MyTexture[i - 1]);
glTexImage2D(GL_TEXTURE_2D,0,3,TextureImage[i - 1] -> sizeX,
TextureImage[i - 1] -> sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,TextureImage[i - 1]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);

free(TextureImage[i - 1]->data);
free(TextureImage[i - 1]);
}
return true;
}

//.....the end

then i use glBindTexture() in my display function to change to different texture but fail.
It seems that glbindTexture() doesn't work and i can only use the last texture i have loaded.

Anybody help me! Thank you!

[This message has been edited by Dickie (edited 09-21-2003).]

Dickie
09-21-2003, 05:26 AM
sorry to write the message in a mess, but it seems that my 'tab' key doesn't work in the text field.

Dickie
09-21-2003, 05:38 AM
Solved Now!!
i just saw a topic below and find that i make a big mistake of placing glBindTexture between glBegin() and glEnd()!
Thank you all!