Multitexturing

Started by
3 comments, last by dandrestor 13 years, 2 months ago
Hi guys,

I'm trying to use multitexturing in my program but I'm hopelessly lost... Help!!!

I have written a basic fragment shader which declares two uniform sampler2D variables.

uniform sampler2D tex1;
uniform sampler2D tex2;
...
t1 = texture2D(tex1, texCoord1);
t2 = texture2D(tex2, texCoord2);


My opengl display function does something like:

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, tex1);
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex0);
glEnable(GL_TEXTURE_2D)
...
glClientActiveTexture(GL_TEXTURE0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 32, buffer0);
glClientActiveTexture(GL_TEXTURE1);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 32, buffer1);


No matter what I do, it seems that in my shader the two uniforms point to the same texture object! I think the call to glBindTexture is wrong... Could you help me understand this?

Thanks a bunch!
D.
Advertisement
You need to upload the multitexture information into the shader. Right now your shader is streaming only the first texture, as you are not linking the shader with any other texture even if you are binding texture from your OGL code (short answer: glUniform to upload texture to bind).
Of course. Thank you so much. This was the missing link!
Normal mapping, here I come :D

D.
FYI, this does nothing outside of the fixed function pipeline, you can remove it:

glEnable(GL_TEXTURE_2D)
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
FYI, this does nothing outside of the fixed function pipeline, you can remove it:

glEnable(GL_TEXTURE_2D)



Thanks!

This topic is closed to new replies.

Advertisement