From bdf364a5aa3c456f4cae221d4106010821eacde6 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 11 Nov 2002 09:56:07 +0000 Subject: [PATCH] Fix flushing when setting modulate and when changing textures; implement stats. --- stepmania/src/RageDisplay.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 50e4d158c7..5b04e9da1e 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -38,6 +38,7 @@ RageMatrix& GetTopModelMatrix() { return g_matModelStack.back(); } int g_flags = 0; /* SDL video flags */ GLenum g_vertMode = GL_TRIANGLES; RageVertex g_vertQueue[MAX_NUM_VERTICIES]; +RageTimer g_LastCheckTimer; int g_iNumVerts; float g_fLastCheckTime; int g_iFramesRenderedSinceLastCheck; @@ -151,6 +152,20 @@ void RageDisplay::Flip() { FlushQueue(); SDL_GL_SwapBuffers(); + g_iFramesRenderedSinceLastCheck++; + + if( g_LastCheckTimer.PeekDeltaTime() >= 1.0f ) // update stats every 1 sec. + { + g_LastCheckTimer.GetDeltaTime(); + g_iFPS = g_iFramesRenderedSinceLastCheck; + g_iFramesRenderedSinceLastCheck = 0; + g_iTPF = g_iVertsRenderedSinceLastCheck / g_iFPS; + g_iVertsRenderedSinceLastCheck = 0; + g_iDPF = g_iDrawsSinceLastCheck / g_iFPS; + g_iDrawsSinceLastCheck = 0; + //LOG->Trace( "FPS: %d, TPF: %d, DPF: %d", m_iFPS, m_iTPF, m_iDPF ); + } + } @@ -198,12 +213,12 @@ void RageDisplay::DrawStrip( const RageVertex v[], int iNumVerts ) } void RageDisplay::AddVerts( const RageVertex v[], int iNumVerts ) { - // Try not to overflow the queue - if( g_iNumVerts > MAX_NUM_VERTICIES-30 ) - FlushQueue(); - for( int i=0; i MAX_NUM_VERTICIES ) + FlushQueue(); + // transform the verticies as we copy RageVec3TransformCoord( &g_vertQueue[g_iNumVerts].p, &v[i].p, &GetTopModelMatrix() ); g_vertQueue[g_iNumVerts].c = v[i].c; @@ -322,6 +337,7 @@ void RageDisplay::SetTexture( RageTexture* pTexture ) if( iLastTexID != iNewTexID ) FlushQueue(); + iLastTexID = iNewTexID; glBindTexture( GL_TEXTURE_2D, iNewTexID ); } @@ -330,7 +346,7 @@ void RageDisplay::SetTextureModeModulate() int a; glGetTexEnviv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &a ); - if( a == GL_MODULATE ) + if( a != GL_MODULATE ) FlushQueue(); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);