Do not draw anything if vertex containers are empty.

This commit is contained in:
Maciej Suminski 2016-05-02 16:08:50 +02:00
parent 928d4e0404
commit 05a30b7591
1 changed files with 11 additions and 1 deletions

View File

@ -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;