Hello,
I’m trying to use the pixel texturing function in NV_texture_shader. I’m trying to do something pretty basic - use the R and G channels of one texture as the texture coordinates for another. I have the following code snippet. What am I doing wrong?!?!
// Pixel Texture Map. First texture used as
// texture coordinates. R and G channels go
// from 0.0 to 1.0. Alpha is set to 1.0.
glEnable(GL_TEXTURE_SHADER_NV);
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexEnvi(GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexEnvi(GL_TEXTURE_SHADER_NV,
GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
// Texture that I’m trying to map.
glEnable(GL_TEXTURE_SHADER_NV);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexEnvi(GL_TEXTURE_ENV,
GL_TEXTURE_ENV_MODE, GL_REPLACE);
// Drawing a square w/texture map.
glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f,
0.0f);
glVertex3f(-1.0f, -1.0f, 1.05f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f,
0.0f);
glVertex3f( 1.0f, -1.0f, 1.05f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f,
1.0f);
glVertex3f( 1.0f, 1.0f, 1.05f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f,
1.0f);
glVertex3f(-1.0f, 1.0f, 1.05f);
glEnd();
glDisable(GL_TEXTURE_SHADER_NV);
glFlush();
What I’m getting is the first texture mapped onto the square as a color texture instead of being used as texture coordinates. I’ve tried several combinations of these statements and still didn’t get the right mapping. It seems to work if I use the DEPENDENT_GB_TEXTURE_2D_NV, but I wanted to avoid using that. Thanks in advance for any help!
- Q.