PDA

View Full Version : How to put background img w/o shader inteference



th0r1000
07-30-2006, 09:38 AM
Hi,

I am trying to put a background image with an object in front of it. The object uses a bump mapping shader. This is my Variable init code:

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,glptex);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,glpl3d);

glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,backg);

This is the code i use to draw the background:

glUseProgramObjectARB(0);
glDisable(GL_VERTEX_PROGRAM_ARB);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,backg);
glBegin(GL_QUADS);
glNormal3f(0,0,1);
glColor3f(1.0,1.0,1.0);
glTexcoord2f(0,0);
glvertex3f(-1,-1,0);

glTexcoord2f(1,0);
glvertex3f(1,-1,0);

glTexcoord2f(1,1);
glvertex3f(1,1,0);

glTexcoord2f(0,1);
glvertex3f(-1,1,0);

glEnd;
glUseProgramObjectARB(ProgramObject);

The shader works with my object but the background is PURPLE??
The shader seems to be interfering with my normal
opengl code.

Does anyone know how to fix this?

Zengar
07-30-2006, 06:02 PM
Looks like you use wrong texture unit. glTexCoord operations set the coordinates for the first unit, and from your code looks like you're still referencing the third unit. Possibly the result you get is sampling the single pixel from the third texture.