Jump to content
  • Advertisement
Sign in to follow this  
svnstrk

Binding textures to GLSL

This topic is 2524 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,

im trying to send multiple texture ids to glsl via this code:


glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, textureId[]);
glUniform1i(glGetUniformLocation(6, "tex1"), 0);


glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, textureId[2]);
glUniform1i(glGetUniformLocation(6, "tex2"), 1);


but somehow it slows the program (a lot) and sometimes fail to render. im not sure what happened. when i send only one texture, it works perfectly. but when i send both with the code above, it crashes. there's nothing wrong with the texture: they both successfully sent to gpu and can be rendered. there is no change in the glsl since im not yet using the second texture. anyone know why this happens?


thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
And aside from what V-man said:glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, textureId[2]);
glUniform1i(glGetUniformLocation(6, "tex2"), 1);

You're using the third element of the textureId array here. Is that intentional? Is textureId declared as "GLuint textureId[3]"?

Share this post


Link to post
Share on other sites
hi,

yes that was a typo. the array is fine, there are 5 elements all printed out correctly just right before i bind them. so it wouldn't be the array. im still not sure what happened, it can render the first frame, but it stuck after that. any idea why its happened?

thanks in advance

Share this post


Link to post
Share on other sites
ah sorry, apparently i forgot i already use GL_TEXTURE0 for the background, and I binded the wrong one. thats probably why its not rendered correctly. thanks anyway.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!