PDA

View Full Version : About texture mapping



Maximus
03-30-2003, 07:02 AM
I'm a true beginner,and I try to map a bmp image to the 3d space.My codes is as belows:

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_MAG_FILTE R, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R, GL_NEAREST);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);/* Force 4-byte alignment */
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGB8,width,
height, 0, GL_RGB, GL_UNSIGNED_BYTE, bits);
glEndList();

where bits stands for the RGB(8bits each)picture pointer,and width and height is the size of the picture,but all I get is nothing but white texture.
I don't know whether the parameters I chose is incorrect,thanks for your help.

NO WAR!

shinpaughp
03-30-2003, 09:57 AM
Did you use glGenTextures and glBindTexture before this code?

Poons
03-30-2003, 01:50 PM
try glBindTexture(GL_TEXTURE_2D,myTexture)
where myTexture is an unsigned int.

you also have to enable texture mapping with glEnable(GL_TEXTURE_2D)