Skip to main content
GameDev.net gamedev.net
🔒 Locked

2nd texture doesn't work

Started by famous Jun 15, 2010 at 9:11 AM 1 replies 600+ views
Original Post
famous
famous
I just don't get it. First some code:

glActiveTextureARB(GL_TEXTURE0 + 0);	glEnable(GL_TEXTURE_2D);	glBindTexture(GL_TEXTURE_2D, texture[0].texID);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);	glActiveTextureARB(GL_TEXTURE0 + 1);	glEnable(GL_TEXTURE_2D);	glBindTexture(GL_TEXTURE_2D, texture[1].texID);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);	glBegin(GL_QUADS);		// Front Face		glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f, 0.0f);		glMultiTexCoord2fARB(GL_TEXTURE1, 0.0f, 0.0f);		glVertex3f(-100.0f, -100.0f,  0.0f);		glMultiTexCoord2fARB(GL_TEXTURE0, 1.0f, 0.0f);		glMultiTexCoord2fARB(GL_TEXTURE1, 1.0f, 0.0f);		glVertex3f( 100.0f, -100.0f,  0.0f);		glMultiTexCoord2fARB(GL_TEXTURE0, 1.0f, 1.0f);		glMultiTexCoord2fARB(GL_TEXTURE1, 1.0f, 1.0f);		glVertex3f( 100.0f,  100.0f,  0.0f);		glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f, 1.0f);		glMultiTexCoord2fARB(GL_TEXTURE1, 0.0f, 1.0f);		glVertex3f(-100.0f,  100.0f,  0.0f);	glEnd();


Later on I pass those two things to my shader:

glUniform1fARB(glGetUniformLocationARB(p, "shadowMap1"), 0);	glUniform1fARB(glGetUniformLocationARB(p, "shadowMap2"), 1);


For some reason it seems like shadowMap2 contains the same texture as shadowMap1. Can anyone spot the mistake?
Avantarius
Avantarius
You should call the glUniform1fARB's before doing the drawing with glBegin, otherwise the shader will not know that "shadowmap2" should contain your second texture and assume that all your samplers use texture unit 0. Thats why you get twice the same texture in your shader.
famous
famous
Actually, I have two different applications. The first one is a framwork with a draw callback where I first load the shader and then do the drawing. When I try to display the 2nd texture here the output seems to be somewhat dependend from it but far from being correct. I.e. if I have a depth map the output is a single-colored grey quad. If I use a desert texture the output is a yellow/orange quad, etc.

The 2nd application (for debugging purposes) works with glut where I load the shader after setting the draw callback with glutDisplayFunc so I think the order is correct.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.