diff --git a/common/gal/opengl/gpu_manager.cpp b/common/gal/opengl/gpu_manager.cpp index 2012f4ed25..348f39c98c 100644 --- a/common/gal/opengl/gpu_manager.cpp +++ b/common/gal/opengl/gpu_manager.cpp @@ -160,6 +160,12 @@ void GPU_CACHED_MANAGER::EndDrawing() wxASSERT( m_isDrawing ); + if( m_indicesSize == 0 ) + { + m_isDrawing = false; + return; + } + // Prepare buffers glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); @@ -178,7 +184,8 @@ void GPU_CACHED_MANAGER::EndDrawing() } glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indicesBuffer ); - glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indicesSize * sizeof(int), (GLvoid*) m_indices.get(), GL_DYNAMIC_DRAW ); + glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indicesSize * sizeof(int), + (GLvoid*) m_indices.get(), GL_STATIC_DRAW ); glDrawElements( GL_TRIANGLES, m_indicesSize, GL_UNSIGNED_INT, 0 ); @@ -290,6 +297,9 @@ void GPU_NONCACHED_MANAGER::EndDrawing() prof_start( &totalRealTime ); #endif /* __WXDEBUG__ */ + if( m_container->GetSize() == 0 ) + return; + VERTEX* vertices = m_container->GetAllVertices(); GLfloat* coordinates = (GLfloat*) ( vertices ); GLubyte* colors = (GLubyte*) ( vertices ) + ColorOffset;