View Full Version : Texture mapping

06-25-2001, 04:13 AM
I cannot get texture mapping to work.
I have created a context.
I have enabled 2d texture mapping.
I have generated a texture name.
I have bound the texture name to 2d textures
I have used the following to setup my texture

glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, array)

where array is a [256*256*3] byte array of texture data.

I setup my quad with texture coords for each corner but when I display the quad it appears coloured with no texture.
I have re-bound the texture before calling glBegin but still nothing.

I have used glGetError but it reports that nothing is wrong. Please help as I have run out of ideas. http://www.opengl.org/discussion_boards/ubb/frown.gif

[This message has been edited by stim (edited 06-25-2001).]

Tim Stirling
06-25-2001, 04:36 AM
Can you post more code!

06-25-2001, 04:44 AM
When you say it appears colored, are you saying that that color is the primary color? Or does the color change depending on the texture used? If the color changes as the texture changes, then it sounds like texture mapping is working fine, and that its the texture coordinates that are bad (or possibly the texture matrix).

06-25-2001, 05:59 AM
this is the setup code...
(I have omitted the error checking code for space)

glGenTextures(1, &m_nTexture);
glBindTexture(GL_TEXTURE_2D, m_nTexture);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, array);

this is the drawing code...

glBindTexture(GL_TEXTURE_2D, m_nTexture);
glTexCoord2d(0,0); glVertex2d(-1,-1);
glTexCoord2d(1,0); glVertex2d( 1,-1);
glTexCoord2d(1,1); glVertex2d( 1, 1);
glTexCoord2d(0,1); glVertex2d(-1, 1);

the quad is rendered white only.
is this enough code?

[This message has been edited by stim (edited 06-25-2001).]

06-25-2001, 06:33 AM
For each texture binded you must set Min and Mag Filter property.


For some reason if you don't set these properties, the texture isn't displayed.

I have the same problem one week ago (RIVA TNT)

[This message has been edited by Boresight (edited 06-25-2001).]

06-25-2001, 06:42 AM
I tried that but The texture appeared black.

06-25-2001, 11:23 AM
Is it possible to make textures affected by lighting? I have a moon texture and I want the light to go around like the sun.

06-26-2001, 12:05 AM
Thank you Boresight. The texture parameters worked. I was using a blank texture. Doh! http://www.opengl.org/discussion_boards/ubb/redface.gif

06-26-2001, 08:44 AM
Hehe.. done that to.

but what if i want 2 textures and want to set witch texture should show most ?