Jump to content
  • Advertisement
Sign in to follow this  
JohnnyCode

active unit 0

This topic is 3614 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

hello all, I got me another problem. I use GLSL shader and texture units. In my mesh render method I do following to set up texture units: int l=-1; if (m_vTextures.size()>0){ for (int n=0;n<m_vTextures.size();n++) { l++; glActiveTexture(GL_TEXTURE0+l); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,m_vTextures.at(n)->GetHWName()); glClientActiveTexture(GL_TEXTURE0+l); } } The problem is that if I set unit 0 as the active unit my mesh is all black but if I use other higher units(and change uniforms setting to correspond of course) I get my texture drawn. I do no settings or operations on unit 0 except that I load my textures by that unit like this: glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,m_iTextureName); glTexImage2D(GL_TEXTURE_2D,0, 3, m_iWidth, m_iHeight,0, GL_BGR, GL_UNSIGNED_BYTE, colorsa); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, m_iWidth, m_iHeight, GL_BGR, GL_UNSIGNED_BYTE, colorsa); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glBindTextureEXT(GL_TEXTURE_2D,0); glDisable(GL_TEXTURE_2D); This is how I pass textures to my shader: if (mesh->GetTexture(0,1)) glUniform1i(texuA,0); if (mesh->GetTexture(1,1)) glUniform1i(texuB,1); if (mesh->GetTexture(2,1)) glUniform1i(texuC,2); if (mesh->GetTexture(3,1)) glUniform1i(texuD,3); So I somehow can't use unit 0. Why could that be?

Share this post


Link to post
Share on other sites
Advertisement
I don't know about the problem you are having but...
You don't need to call glClientActiveTexture. That is for glTexCoordPointer.

You don't need to glEnable(GL_TEXTURE_2D);

You don't need to glBindTextureEXT(GL_TEXTURE_2D,0);

You don't need glTexImage2D since you re calling gluBuild2DMipmaps

Since you want to use mipmaps
why do you call glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
Use glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);

Share this post


Link to post
Share on other sites
solved, I was setting the same sampler to more shader unifroms. So it seems I cant use the same sampler on more then one uniform shader sampler. Hmmm, can I somehow set more shader sampler2d unifroms to the same sampler?

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!