PDA

View Full Version : problem with glTexImage2D()



dilectio
11-21-2002, 06:40 PM
Guys, i need your help on glTexImage2D()

Here are my codes snipet to load .bmp textures:

BitmapStruct TextureImage;
bitmap(name, &TextureImage);

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &texture[0]);

glBindTexture(GL_TEXTURE_2D, texture[0]);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);

gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage.Width, TextureImage.Height, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.Pixels);

if (TextureImage.Pixels)
free(TextureImage.Pixels);

Here is how i use the textures:
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[0]);

The codes above works fine. The textures apear as expected.
But when i replace gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage.Width, TextureImage.Height, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.Pixels);
with glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TextureImage.Width, TextureImage.Height, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage.Pixels);
because i do not want to do mipmapping, my objects does not have any textures. I just dunno what is wrong.

[This message has been edited by dilectio (edited 11-21-2002).]

Dakeyras
11-21-2002, 07:32 PM
You also need to change
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_NEAREST);
to
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

to disable mipmapping.