From 9c73aed254370dee94d74a256baf343d6e54100d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 25 Jul 2006 20:10:56 +0000 Subject: [PATCH] Do SetDefaultRenderStates in BeginFrame, instead of on init, so we don't depend on state being preserved long-term, and so every renderer doesn't have to do this. --- stepmania/src/RageDisplay.cpp | 12 ++++++++++++ stepmania/src/RageDisplay.h | 4 ++-- stepmania/src/RageDisplay_D3D.cpp | 6 ++---- stepmania/src/RageDisplay_OGL.cpp | 7 +++---- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 4ea3b1b78c..67a41983b0 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -121,11 +121,23 @@ RString RageDisplay::GetStats() const return s; } +bool RageDisplay::BeginFrame() +{ + this->SetDefaultRenderStates(); + + return true; +} + void RageDisplay::EndFrame() { ProcessStatsOnFlip(); } +void RageDisplay::BeginConcurrentRendering() +{ + this->SetDefaultRenderStates(); +} + void RageDisplay::StatsAddVerts( int iNumVertsRendered ) { g_iVertsRenderedSinceLastCheck += iNumVertsRendered; } /* Draw a line as a quad. GL_LINES with SmoothLines off can draw line diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index f0edb6ea76..2ea304fc0c 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -152,7 +152,7 @@ public: /* Call this when the resolution has been changed externally: */ virtual void ResolutionChanged(); - virtual bool BeginFrame() = 0; + virtual bool BeginFrame(); virtual void EndFrame(); virtual VideoModeParams GetActualVideoModeParams() const = 0; bool IsWindowed() const { return this->GetActualVideoModeParams().windowed; } @@ -167,7 +167,7 @@ public: // thread before and after rendering. virtual void BeginConcurrentRenderingMainThread() { } virtual void EndConcurrentRenderingMainThread() { } - virtual void BeginConcurrentRendering() { } + virtual void BeginConcurrentRendering(); virtual void EndConcurrentRendering() { } /* return 0 if failed or internal texture resource handle diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 10934835bb..91517731c7 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -621,8 +621,6 @@ RString RageDisplay_D3D::TryVideoMode( const VideoModeParams &_p, bool &bNewDevi ResolutionChanged(); - this->SetDefaultRenderStates(); - return RString(); // mode change successful } @@ -661,7 +659,6 @@ bool RageDisplay_D3D::BeginFrame() if( sError != "" ) RageException::Throw( sError ); - this->SetDefaultRenderStates(); break; } } @@ -670,7 +667,8 @@ bool RageDisplay_D3D::BeginFrame() g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 ); g_pd3dDevice->BeginScene(); - return true; + + return RageDisplay::BeginFrame(); } static RageTimer g_LastFrameEndedAt( RageZeroTimer ); diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index c34e0d02b8..d8b5a74d18 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -598,8 +598,6 @@ RString RageDisplay_OGL::TryVideoMode( const VideoModeParams &p, bool &bNewDevic InitScalingScript(); } - this->SetDefaultRenderStates(); - /* Set vsync the Windows way, if we can. (What other extensions are there * to do this, for other archs?) */ if( GLExt.wglSwapIntervalEXT ) @@ -629,7 +627,8 @@ bool RageDisplay_OGL::BeginFrame() glClearColor( 0,0,0,1 ); SetZWrite( true ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - return true; + + return RageDisplay::BeginFrame(); } void RageDisplay_OGL::EndFrame() @@ -1584,7 +1583,7 @@ void RageDisplay_OGL::EndConcurrentRenderingMainThread() void RageDisplay_OGL::BeginConcurrentRendering() { g_pWind->BeginConcurrentRendering(); - SetDefaultRenderStates(); + RageDisplay::BeginConcurrentRendering(); } void RageDisplay_OGL::EndConcurrentRendering()