Commit 3132690c authored by Paulo Henrique Silva's avatar Paulo Henrique Silva Committed by Maciej Suminski

Fix slow opengl canvas on Mac OS 10.9.

parent 12472644
...@@ -94,6 +94,7 @@ GPU_CACHED_MANAGER::~GPU_CACHED_MANAGER() ...@@ -94,6 +94,7 @@ GPU_CACHED_MANAGER::~GPU_CACHED_MANAGER()
{ {
glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 );
glDeleteBuffers( 1, &m_verticesBuffer ); glDeleteBuffers( 1, &m_verticesBuffer );
glDeleteBuffers( 1, &m_indicesBuffer );
} }
} }
...@@ -105,6 +106,7 @@ void GPU_CACHED_MANAGER::Initialize() ...@@ -105,6 +106,7 @@ void GPU_CACHED_MANAGER::Initialize()
if( !m_buffersInitialized ) if( !m_buffersInitialized )
{ {
glGenBuffers( 1, &m_verticesBuffer ); glGenBuffers( 1, &m_verticesBuffer );
glGenBuffers( 1, &m_indicesBuffer );
m_buffersInitialized = true; m_buffersInitialized = true;
} }
} }
...@@ -167,9 +169,13 @@ void GPU_CACHED_MANAGER::EndDrawing() ...@@ -167,9 +169,13 @@ void GPU_CACHED_MANAGER::EndDrawing()
VertexSize, (GLvoid*) ShaderOffset ); 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_ARRAY_BUFFER, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
// Deactivate vertex array // Deactivate vertex array
glDisableClientState( GL_COLOR_ARRAY ); glDisableClientState( GL_COLOR_ARRAY );
......
...@@ -144,6 +144,9 @@ protected: ...@@ -144,6 +144,9 @@ protected:
///> Handle to vertices buffer ///> Handle to vertices buffer
GLuint m_verticesBuffer; GLuint m_verticesBuffer;
///> Handle to indices buffer
GLuint m_indicesBuffer;
///> Number of indices stored in the indices buffer ///> Number of indices stored in the indices buffer
unsigned int m_indicesSize; unsigned int m_indicesSize;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment