Add GL assert checks.

This commit is contained in:
Chris Danford
2005-11-28 23:26:22 +00:00
parent 9d0cc2d322
commit 48d259a370
+32 -7
View File
@@ -919,7 +919,11 @@ static void InvalidateAllGeometry()
RageCompiledGeometryHWOGL::RageCompiledGeometryHWOGL() RageCompiledGeometryHWOGL::RageCompiledGeometryHWOGL()
{ {
g_GeometryList.insert( this ); g_GeometryList.insert( this );
m_nPositions = m_nTextureCoords = m_nNormals = m_nTriangles = m_nTextureMatrixScale = 0; m_nPositions = 0;
m_nTextureCoords = 0;
m_nNormals = 0;
m_nTriangles = 0;
m_nTextureMatrixScale = 0;
AllocateBuffers(); AllocateBuffers();
} }
@@ -979,53 +983,63 @@ void RageCompiledGeometryHWOGL::AllocateBuffers()
void RageCompiledGeometryHWOGL::UploadData() void RageCompiledGeometryHWOGL::UploadData()
{ {
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3), GetTotalVertices()*sizeof(RageVector3),
&m_vPosition[0], &m_vPosition[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
// AssertNoGLError(); AssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2), GetTotalVertices()*sizeof(RageVector2),
&m_vTexture[0], &m_vTexture[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
// AssertNoGLError(); AssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3), GetTotalVertices()*sizeof(RageVector3),
&m_vNormal[0], &m_vNormal[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
// AssertNoGLError(); AssertNoGLError();
GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles ); GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ELEMENT_ARRAY_BUFFER_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB,
GetTotalTriangles()*sizeof(msTriangle), GetTotalTriangles()*sizeof(msTriangle),
&m_vTriangles[0], &m_vTriangles[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
// AssertNoGLError(); AssertNoGLError();
if( m_bAnyNeedsTextureMatrixScale ) if( m_bAnyNeedsTextureMatrixScale )
{ {
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2), GetTotalVertices()*sizeof(RageVector2),
&m_vTexMatrixScale[0], &m_vTexMatrixScale[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError();
} }
} }
void RageCompiledGeometryHWOGL::Invalidate() void RageCompiledGeometryHWOGL::Invalidate()
{ {
/* Our vertex buffers no longer exist. Reallocate and reupload. */ /* Our vertex buffers no longer exist. Reallocate and reupload. */
m_nPositions = m_nTextureCoords = m_nNormals = m_nTriangles = m_nTextureMatrixScale = 0; m_nPositions = 0;
m_nTextureCoords = 0;
m_nNormals = 0;
m_nTriangles = 0;
m_nTextureMatrixScale = 0;
AllocateBuffers(); AllocateBuffers();
UploadData(); UploadData();
} }
@@ -1034,6 +1048,7 @@ void RageCompiledGeometryHWOGL::Allocate( const vector<msMesh> &vMeshes )
{ {
RageCompiledGeometrySWOGL::Allocate( vMeshes ); RageCompiledGeometrySWOGL::Allocate( vMeshes );
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3), GetTotalVertices()*sizeof(RageVector3),
@@ -1042,6 +1057,7 @@ void RageCompiledGeometryHWOGL::Allocate( const vector<msMesh> &vMeshes )
AssertNoGLError(); AssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2), GetTotalVertices()*sizeof(RageVector2),
@@ -1050,6 +1066,7 @@ void RageCompiledGeometryHWOGL::Allocate( const vector<msMesh> &vMeshes )
AssertNoGLError(); AssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3), GetTotalVertices()*sizeof(RageVector3),
@@ -1058,6 +1075,7 @@ void RageCompiledGeometryHWOGL::Allocate( const vector<msMesh> &vMeshes )
AssertNoGLError(); AssertNoGLError();
GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles ); GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ELEMENT_ARRAY_BUFFER_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB,
GetTotalTriangles()*sizeof(msTriangle), GetTotalTriangles()*sizeof(msTriangle),
@@ -1066,6 +1084,7 @@ void RageCompiledGeometryHWOGL::Allocate( const vector<msMesh> &vMeshes )
AssertNoGLError(); AssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
AssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2), GetTotalVertices()*sizeof(RageVector2),
@@ -1089,14 +1108,17 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
return; return;
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
AssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions );
AssertNoGLError(); AssertNoGLError();
glVertexPointer(3, GL_FLOAT, 0, NULL ); glVertexPointer(3, GL_FLOAT, 0, NULL );
AssertNoGLError(); AssertNoGLError();
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
AssertNoGLError();
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
AssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords );
AssertNoGLError(); AssertNoGLError();
glTexCoordPointer(2, GL_FLOAT, 0, NULL); glTexCoordPointer(2, GL_FLOAT, 0, NULL);
@@ -1113,6 +1135,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
if( bLighting || bTextureGenS || bTextureGenT ) if( bLighting || bTextureGenS || bTextureGenT )
{ {
glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_NORMAL_ARRAY);
AssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals );
AssertNoGLError(); AssertNoGLError();
glNormalPointer(GL_FLOAT, 0, NULL); glNormalPointer(GL_FLOAT, 0, NULL);
@@ -1121,6 +1144,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
else else
{ {
glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_NORMAL_ARRAY);
AssertNoGLError();
} }
if( meshInfo.m_bNeedsTextureMatrixScale ) if( meshInfo.m_bNeedsTextureMatrixScale )
@@ -1138,6 +1162,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
AssertNoGLError(); AssertNoGLError();
GLExt.glUseProgramObjectARB( g_bTextureMatrixShader ); GLExt.glUseProgramObjectARB( g_bTextureMatrixShader );
AssertNoGLError();
} }
else else
{ {
@@ -1162,6 +1187,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
glMatrixMode( GL_TEXTURE ); glMatrixMode( GL_TEXTURE );
glLoadMatrixf( (const float*)mat ); glLoadMatrixf( (const float*)mat );
AssertNoGLError();
} }
} }
@@ -1590,7 +1616,6 @@ void RageDisplay_OGL::DeleteTexture( unsigned uTexHandle )
FlushGLErrors(); FlushGLErrors();
glDeleteTextures(1,reinterpret_cast<GLuint*>(&uTexID)); glDeleteTextures(1,reinterpret_cast<GLuint*>(&uTexID));
AssertNoGLError(); AssertNoGLError();
} }