Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Batch::loadNormalData( GLfloat* normals, unsigned num_elements )
- {
- // See commenting in loadPositionData
- if( m_NormalBuffer != 0 )
- glDeleteBuffers( 1, &m_NormalBuffer );
- if( m_VAO == 0 )
- {
- if( !genVAO( ) )
- return false;
- }
- if( m_NormalBuffer == 0 )
- {
- std::stringstream stream;
- stream << "Failed to generate m_NormalBuffer in batch '"
- << ( m_IDString.empty( ) ? "ID_NOT_SET" : m_IDString ) << "'";
- m_ErrorString = stream.str( );
- return false;
- }
- glBindVertexArray( m_VAO );
- glEnableVertexAttribArray( ToolBox::Math::GLSL_ATTR::NORMAL );
- glBindBuffer( GL_ARRAY_BUFFER, m_NormalBuffer );
- glBufferData( GL_ARRAY_BUFFER, sizeof( GLfloat ) * num_elements, normals, GL_STATIC_DRAW );
- glVertexAttribPointer( ToolBox::Math::GLSL_ATTR::NORMAL, 3, GL_FLOAT, GL_FALSE, 0, ( const GLvoid* )0 );
- glBindVertexArray( 0 );
- glBindBuffer( GL_ARRAY_BUFFER, 0 );
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement