@ -50,35 +50,19 @@ bool AbstractShaderProgram::attachShader(Shader* shader) {
return true ;
return true ;
}
}
bool AbstractShaderProgram : : bindAttribute ( GLuint location , const string & name ) {
void AbstractShaderProgram : : bindAttribute ( GLuint location , const string & name ) {
if ( state ! = Initialized ) {
if ( state ! = Initialized ) {
Error ( ) < < " AbstractShaderProgram: attribute cannot be bound after linking. " ;
Error ( ) < < " AbstractShaderProgram: attribute cannot be bound after linking. " ;
assert ( 0 ) ;
assert ( 0 ) ;
return false ;
}
}
/* Check whether given id already exists */
glBindAttribLocation ( program , location , name . c_str ( ) ) ;
if ( attributes . find ( location ) ! = attributes . end ( ) ) return false ;
/* Check whether given name already exists */
for ( map < GLuint , string > : : const_iterator it = attributes . begin ( ) ; it ! = attributes . end ( ) ; + + it )
if ( it - > second = = name ) return false ;
attributes . insert ( pair < GLuint , string > ( location , name ) ) ;
return true ;
}
}
void AbstractShaderProgram : : link ( ) {
void AbstractShaderProgram : : link ( ) {
/* Already compiled or failed, exit */
/* Already compiled or failed, exit */
if ( state ! = Initialized ) return ;
if ( state ! = Initialized ) return ;
/* Set state to failed if anything goes wrong */
state = Failed ;
/* Bind attributes to specified locations */
for ( map < GLuint , string > : : const_iterator it = attributes . begin ( ) ; it ! = attributes . end ( ) ; + + it )
glBindAttribLocation ( program , it - > first , it - > second . c_str ( ) ) ;
/* Link shader program */
/* Link shader program */
glLinkProgram ( program ) ;
glLinkProgram ( program ) ;