Browse Source

Fix slow opengl canvas on Mac OS 10.9.

pull/1/head
Paulo Henrique Silva 11 years ago
committed by Maciej Suminski
parent
commit
3132690c0b
  1. 8
      common/gal/opengl/gpu_manager.cpp
  2. 3
      include/gal/opengl/gpu_manager.h

8
common/gal/opengl/gpu_manager.cpp

@ -94,6 +94,7 @@ GPU_CACHED_MANAGER::~GPU_CACHED_MANAGER()
{
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glDeleteBuffers( 1, &m_verticesBuffer );
glDeleteBuffers( 1, &m_indicesBuffer );
}
}
@ -105,6 +106,7 @@ void GPU_CACHED_MANAGER::Initialize()
if( !m_buffersInitialized )
{
glGenBuffers( 1, &m_verticesBuffer );
glGenBuffers( 1, &m_indicesBuffer );
m_buffersInitialized = true;
}
}
@ -167,9 +169,13 @@ void GPU_CACHED_MANAGER::EndDrawing()
VertexSize, (GLvoid*) ShaderOffset );
}
glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, (GLvoid*) m_indices.get() );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indicesBuffer );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indicesSize * sizeof(int), (GLvoid*) m_indices.get(), GL_DYNAMIC_DRAW );
glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, 0 );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
// Deactivate vertex array
glDisableClientState( GL_COLOR_ARRAY );

3
include/gal/opengl/gpu_manager.h

@ -144,6 +144,9 @@ protected:
///> Handle to vertices buffer
GLuint m_verticesBuffer;
///> Handle to indices buffer
GLuint m_indicesBuffer;
///> Number of indices stored in the indices buffer
unsigned int m_indicesSize;
};

Loading…
Cancel
Save