Advertisement
Guest User

Untitled

a guest
Aug 15th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. bool Batch::loadNormalData( GLfloat* normals, unsigned num_elements )
  2. {
  3.     // See commenting in loadPositionData
  4.  
  5.     if( m_NormalBuffer != 0 )
  6.         glDeleteBuffers( 1, &m_NormalBuffer );
  7.  
  8.     if( m_VAO == 0 )
  9.     {
  10.         if( !genVAO( ) )
  11.             return false;
  12.     }
  13.  
  14.     if( m_NormalBuffer == 0 )
  15.     {
  16.         std::stringstream stream;
  17.         stream << "Failed to generate m_NormalBuffer in batch '"  
  18.                 << ( m_IDString.empty( ) ? "ID_NOT_SET" : m_IDString ) << "'";
  19.         m_ErrorString = stream.str( );
  20.  
  21.         return false;
  22.     }
  23.  
  24.     glBindVertexArray( m_VAO );
  25.     glEnableVertexAttribArray( ToolBox::Math::GLSL_ATTR::NORMAL );
  26.     glBindBuffer( GL_ARRAY_BUFFER, m_NormalBuffer );
  27.     glBufferData( GL_ARRAY_BUFFER, sizeof( GLfloat ) * num_elements, normals, GL_STATIC_DRAW );
  28.     glVertexAttribPointer( ToolBox::Math::GLSL_ATTR::NORMAL, 3, GL_FLOAT, GL_FALSE, 0, ( const GLvoid* )0 );
  29.     glBindVertexArray( 0 );
  30.     glBindBuffer( GL_ARRAY_BUFFER, 0 );
  31.  
  32.     return true;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement