Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 15th, 2012  |  syntax: C++  |  size: 0.98 KB  |  views: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data