Skip to content
Snippets Groups Projects
Commit 99371f89 authored by Jonathan Goodman's avatar Jonathan Goodman
Browse files

Added new bindTexture and unbindTexture API to LLGLSLShader. Reviewed by davep.

parent ed1b78e3
No related branches found
No related tags found
No related merge requests found
...@@ -476,6 +476,58 @@ void LLGLSLShader::bindNoShader(void) ...@@ -476,6 +476,58 @@ void LLGLSLShader::bindNoShader(void)
} }
} }
S32 LLGLSLShader::bindTexture(const std::string &uniform, LLTexture *texture, LLTexUnit::eTextureType mode)
{
S32 channel = 0;
channel = getUniformLocation(uniform);
return bindTexture(channel, texture, mode);
}
S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode)
{
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
return -1;
}
uniform = mTexture[uniform];
if (uniform > -1)
{
gGL.getTexUnit(uniform)->bind(texture, mode);
}
return uniform;
}
S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureType mode)
{
S32 channel = 0;
channel = getUniformLocation(uniform);
return unbindTexture(channel);
}
S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode)
{
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
return -1;
}
uniform = mTexture[uniform];
if (uniform > -1)
{
gGL.getTexUnit(uniform)->unbind(mode);
}
return uniform;
}
S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode) S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)
{ {
if (uniform < 0 || uniform >= (S32)mTexture.size()) if (uniform < 0 || uniform >= (S32)mTexture.size())
......
...@@ -130,7 +130,14 @@ class LLGLSLShader ...@@ -130,7 +130,14 @@ class LLGLSLShader
//the corresponding channel will be active upon return //the corresponding channel will be active upon return
//returns channel texture is enabled in from [0-MAX) //returns channel texture is enabled in from [0-MAX)
S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE); S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE); S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
// bindTexture returns the texture unit we've bound the texture to.
// You can reuse the return value to unbind a texture when required.
S32 bindTexture(const std::string& uniform, LLTexture *texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 unbindTexture(const std::string& uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 unbindTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
BOOL link(BOOL suppress_errors = FALSE); BOOL link(BOOL suppress_errors = FALSE);
void bind(); void bind();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment