Jump to content

  • Log In with Google      Sign In   
  • Create Account

Multitexturing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 dandrestor   Members   -  Reputation: 102

Like
0Likes
Like

Posted 28 January 2011 - 02:03 PM

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.

Sponsor:

#2 kilah   Members   -  Reputation: 474

Like
1Likes
Like

Posted 28 January 2011 - 02:09 PM

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).

#3 dandrestor   Members   -  Reputation: 102

Like
0Likes
Like

Posted 28 January 2011 - 02:19 PM

Of course. Thank you so much. This was the missing link!
Normal mapping, here I come :D

D.

#4 karwosts   Members   -  Reputation: 840

Like
0Likes
Like

Posted 28 January 2011 - 02:44 PM

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

glEnable(GL_TEXTURE_2D)

My Projects:
Portfolio Map for Android - Free Visual Portfolio Tracker
Electron Flux for Android - Free Puzzle/Logic Game

#5 dandrestor   Members   -  Reputation: 102

Like
0Likes
Like

Posted 28 January 2011 - 03:41 PM

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

glEnable(GL_TEXTURE_2D)


Thanks!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS