• Advertisement
Sign in to follow this  

Multitexturing

This topic is 2547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
[code]
uniform sampler2D tex1;
uniform sampler2D tex2;
...
t1 = texture2D(tex1, texCoord1);
t2 = texture2D(tex2, texCoord2);
[/code]

My opengl display function does something like:
[code]
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);
[/code]

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
FYI, this does nothing outside of the fixed function pipeline, you can remove it:

glEnable(GL_TEXTURE_2D)

Share this post


Link to post
Share on other sites
[quote name='karwosts' timestamp='1296247475' post='4766344']FYI, this does nothing outside of the fixed function pipeline, you can remove it:

glEnable(GL_TEXTURE_2D)

[/quote]

Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement