Changeset 235 for trunk/src/gl/gl_program.cc
- Timestamp:
- 05/12/14 16:52:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_program.cc
r232 r235 106 106 if (!fragment_shader.compile( fragment_program )) { return false; } 107 107 108 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::POSITION ), "nv_position" ); 109 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::TEXCOORD ), "nv_texcoord" ); 110 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::NORMAL ), "nv_normal" ); 111 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::COLOR ), "nv_color" ); 112 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::TANGENT ), "nv_tangent" ); 108 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::POSITION ), "nv_position" ); 109 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::TEXCOORD ), "nv_texcoord" ); 110 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::NORMAL ), "nv_normal" ); 111 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::COLOR ), "nv_color" ); 112 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::TANGENT ), "nv_tangent" ); 113 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::BONEINDEX ), "nv_boneindex" ); 114 glBindAttribLocation( m_name.get_value(), static_cast<GLuint>( slot::BONEWEIGHT ), "nv_boneweight"); 113 115 114 116 glAttachShader( m_name.get_value(), fragment_shader.get_id() ); … … 181 183 182 184 string name( name_buffer, size_t(uni_nlen) ); 183 185 184 186 // skip built-ins 185 187 if ( name.substr(0,3) == "gl_" ) continue; … … 187 189 int uni_loc = glGetUniformLocation( m_name.get_value(), name.c_str() ); 188 190 datatype utype = gl_enum_to_datatype( uni_type ); 191 192 // check for array 193 string::size_type arrchar = name.find('['); 194 if ( arrchar != string::npos ) 195 { 196 name = name.substr( 0, arrchar ); 197 } 198 189 199 m_uniform_map[ name ] = create_uniform( utype, name, uni_loc, uni_len ); 190 200 } … … 204 214 switch( ubase->get_type() ) 205 215 { 206 case FLOAT : glUniform1f ( uloc, ((uniform< enum_to_type< FLOAT >::type >*)( ubase ))->get_value() ); break;207 case INT : glUniform1i ( uloc, ((uniform< enum_to_type< INT >::type >*)( ubase ))->get_value() ); break;208 case FLOAT_VECTOR_2 : glUniform2fv( uloc, 1, glm::value_ptr(((uniform< enum_to_type< FLOAT_VECTOR_2 >::type >*)( ubase ))->get_value())); break;209 case FLOAT_VECTOR_3 : glUniform3fv( uloc, 1, glm::value_ptr(((uniform< enum_to_type< FLOAT_VECTOR_3 >::type >*)( ubase ))->get_value())); break;210 case FLOAT_VECTOR_4 : glUniform4fv( uloc, 1, glm::value_ptr(((uniform< enum_to_type< FLOAT_VECTOR_4 >::type >*)( ubase ))->get_value())); break;211 case INT_VECTOR_2 : glUniform2iv( uloc, 1, glm::value_ptr(((uniform< enum_to_type< INT_VECTOR_2 >::type >*)( ubase ))->get_value())); break;212 case INT_VECTOR_3 : glUniform3iv( uloc, 1, glm::value_ptr(((uniform< enum_to_type< INT_VECTOR_3 >::type >*)( ubase ))->get_value())); break;213 case INT_VECTOR_4 : glUniform4iv( uloc, 1, glm::value_ptr(((uniform< enum_to_type< INT_VECTOR_4 >::type >*)( ubase ))->get_value())); break;214 case FLOAT_MATRIX_2 : glUniformMatrix2fv( uloc, 1, GL_FALSE, glm::value_ptr(((uniform< enum_to_type< FLOAT_MATRIX_2 >::type >*)( ubase ))->get_value())); break;215 case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, 1, GL_FALSE, glm::value_ptr(((uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*)( ubase ))->get_value())); break;216 case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, 1, GL_FALSE, glm::value_ptr(((uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*)( ubase ))->get_value())); break;216 case FLOAT : glUniform1fv( uloc, ubase->get_length(), ((uniform< enum_to_type< FLOAT >::type >*)( ubase ))->get_value() ); break; 217 case INT : glUniform1iv( uloc, ubase->get_length(), ((uniform< enum_to_type< INT >::type >*)( ubase ))->get_value() ); break; 218 case FLOAT_VECTOR_2 : glUniform2fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_2 >::type >*)( ubase ))->get_value()); break; 219 case FLOAT_VECTOR_3 : glUniform3fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_3 >::type >*)( ubase ))->get_value()); break; 220 case FLOAT_VECTOR_4 : glUniform4fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_4 >::type >*)( ubase ))->get_value()); break; 221 case INT_VECTOR_2 : glUniform2iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_2 >::type >*)( ubase ))->get_value()); break; 222 case INT_VECTOR_3 : glUniform3iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_3 >::type >*)( ubase ))->get_value()); break; 223 case INT_VECTOR_4 : glUniform4iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_4 >::type >*)( ubase ))->get_value()); break; 224 case FLOAT_MATRIX_2 : glUniformMatrix2fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_2 >::type >*)( ubase ))->get_value()); break; 225 case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*)( ubase ))->get_value()); break; 226 case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*)( ubase ))->get_value()); break; 217 227 default : break; // error? 218 228 }
Note: See TracChangeset
for help on using the changeset viewer.