Display linking errors in debug mode for shaders. Added SHADER::GetAttribute() function for getting shaders attribute location.
This commit is contained in:
parent
e8acd2919b
commit
ad5d10a8ba
|
@ -168,23 +168,30 @@ void SHADER::ConfigureGeometryShader( GLuint maxVertices, GLuint geometryInputTy
|
|||
}
|
||||
|
||||
|
||||
void SHADER::Link()
|
||||
bool SHADER::Link()
|
||||
{
|
||||
// Shader linking
|
||||
glLinkProgram( programNumber );
|
||||
ProgramInfo( programNumber );
|
||||
|
||||
// Check the Link state
|
||||
GLint linkStatus = 0;
|
||||
glGetObjectParameterivARB( programNumber, GL_OBJECT_LINK_STATUS_ARB, &linkStatus );
|
||||
glGetObjectParameterivARB( programNumber, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &isShaderLinked );
|
||||
|
||||
if( !linkStatus )
|
||||
#ifdef __WXDEBUG__
|
||||
if( !isShaderLinked )
|
||||
{
|
||||
wxLogError( wxString::FromUTF8( "Can't link the shaders!" ) );
|
||||
exit( 1 );
|
||||
int maxLength;
|
||||
glGetProgramiv( programNumber, GL_INFO_LOG_LENGTH, &maxLength );
|
||||
maxLength = maxLength + 1;
|
||||
char *linkInfoLog = new char[maxLength];
|
||||
glGetProgramInfoLog( programNumber, maxLength, &maxLength, linkInfoLog );
|
||||
std::cerr << "Shader linking error:" << std::endl;
|
||||
std::cerr << linkInfoLog;
|
||||
delete[] linkInfoLog;
|
||||
}
|
||||
#endif /* __WXDEBUG__ */
|
||||
|
||||
isShaderLinked = true;
|
||||
return isShaderLinked;
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,3 +222,9 @@ void SHADER::SetParameter( int parameterNumber, float value )
|
|||
{
|
||||
glUniform1f( parameterLocation[parameterNumber], value );
|
||||
}
|
||||
|
||||
|
||||
int SHADER::GetAttribute( std::string aAttributeName )
|
||||
{
|
||||
return glGetAttribLocation( programNumber, aAttributeName.c_str() );
|
||||
}
|
||||
|
|
|
@ -80,8 +80,9 @@ public:
|
|||
|
||||
/**
|
||||
* Link the shaders.
|
||||
* @return true in case of success, false otherwise.
|
||||
*/
|
||||
void Link();
|
||||
bool Link();
|
||||
|
||||
/**
|
||||
* Use the shader.
|
||||
|
@ -122,6 +123,14 @@ public:
|
|||
*/
|
||||
void SetParameter( int aParameterNumber, float aValue );
|
||||
|
||||
/**
|
||||
* @brief Gets an attribute location.
|
||||
*
|
||||
* @param aAttributeName is the name of the attribute.
|
||||
* @return the location.
|
||||
*/
|
||||
int GetAttribute( std::string aAttributeName );
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue