Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualPAndersson

Posted 30 November 2012 - 06:19 PM

Finally got some more time to look into the issue and managed to find and solve the problem.

The setTexture method should look like this:

[source lang="cpp"] void ShaderProgram::setTexture(String variableName, int samplerNo, ICubeMap* texture) { assert(this->programId == this->activeProgram); assert(samplerNo >= 0); //Prepere texture glCheckedCall( glActiveTexture(GL_TEXTURE0 + samplerNo) ); glCheckedCall( glEnable(GL_TEXTURE_CUBE_MAP) ); glCheckedCall( glBindTexture(GL_TEXTURE_CUBE_MAP, texture->getOpenGLId()) ); GLint loc = glCheckedCall( glGetUniformLocation(this->programId, variableName.getStringUtf8()) ); if (loc < 0) syslog.Error(String("Failed to find uniform cubemap name \"") + variableName + "\" in program " + this->getProgramID()); glCheckedCall( glUniform1i(loc, samplerNo) ); }[/source]
As in my previous post, I bound the texture before activating it thus effectivly messing with other texture units. Simply swapping the order in which the function calls are made solved everything.

Thank you for your help, and this just cements my sentiment that state-based interfaces are evil :P

#2PAndersson

Posted 30 November 2012 - 06:17 PM

Finally got some more time to look into the issue and managed to find and solve the problem.

The setTexture method should look like this:

[source lang="cpp"] void ShaderProgram::setTexture(String variableName, int samplerNo, ICubeMap* texture) { assert(this->programId == this->activeProgram); assert(samplerNo >= 0); //Prepere texture glCheckedCall( glActiveTexture(GL_TEXTURE0 + samplerNo) ); glCheckedCall( glEnable(GL_TEXTURE_CUBE_MAP) ); glCheckedCall( glBindTexture(GL_TEXTURE_CUBE_MAP, texture->getOpenGLId()) ); GLint loc = glCheckedCall( glGetUniformLocation(this->programId, variableName.getStringUtf8()) ); if (loc < 0) syslog.Error(String("Failed to find uniform cubemap name \"") + variableName + "\" in program " + this->getProgramID()); glCheckedCall( glUniform1i(loc, samplerNo) ); }[/source]
As in my previous post, I bound the texture before activating it thus effectivly messing with other texture units. Simply swapping the order in which the function calls are made solved everything.

Thank you for your help, and this just cements my sentiment that state-based interfaces are evil :P

#1PAndersson

Posted 30 November 2012 - 06:16 PM

Finally got some more time to look into the issue and managed to find and solve the problem.

The setTexture method should look like this:

[source lang="cpp"] void ShaderProgram::setTexture(String variableName, int samplerNo, ICubeMap* texture) { assert(this->programId == this->activeProgram); assert(samplerNo >= 0); //Prepere texture glCheckedCall( glActiveTexture(GL_TEXTURE0 + samplerNo) ); glCheckedCall( glEnable(GL_TEXTURE_CUBE_MAP) ); glCheckedCall( glBindTexture(GL_TEXTURE_CUBE_MAP, texture->getOpenGLId()) ); GLint loc = glCheckedCall( glGetUniformLocation(this->programId, variableName.getStringUtf8()) ); if (loc < 0) syslog.Error(String("Failed to find uniform cubemap name \"") + variableName + "\" in program " + this->getProgramID()); glCheckedCall( glUniform1i(loc, samplerNo) ); }[/source]
As in my previous post, I bound the texture before activating it thus effectivly messing with other texture units. Simply swapping the order in which the function calls are made solved everything.

PARTNERS