diff --git a/src/RageDisplay.h b/src/RageDisplay.h index 8e3e674116..5f286681d6 100644 --- a/src/RageDisplay.h +++ b/src/RageDisplay.h @@ -244,6 +244,8 @@ public: */ virtual unsigned CreateRenderTarget( const RenderTargetParam &, int & /* iTextureWidthOut */, int & /* iTextureHeightOut */ ) { return 0; } + virtual unsigned GetRenderTarget() { return 0; } + /* Set the render target, or 0 to resume rendering to the framebuffer. An active render * target may not be used as a texture. If bPreserveTexture is true, the contents * of the texture will be preserved from the previous call; otherwise, cleared. If diff --git a/src/RageDisplay_OGL.cpp b/src/RageDisplay_OGL.cpp index a104057df5..af02450337 100644 --- a/src/RageDisplay_OGL.cpp +++ b/src/RageDisplay_OGL.cpp @@ -2475,6 +2475,14 @@ unsigned RageDisplay_Legacy::CreateRenderTarget( const RenderTargetParam ¶m, return iTexture; } +unsigned RageDisplay_Legacy::GetRenderTarget( ) +{ + for( map::const_iterator it = g_mapRenderTargets.begin( ); it != g_mapRenderTargets.end( ); ++it ) + if( it->second == g_pCurrentRenderTarget ) + return it->first; + return 0; +} + void RageDisplay_Legacy::SetRenderTarget( unsigned iTexture, bool bPreserveTexture ) { if (iTexture == 0) diff --git a/src/RageDisplay_OGL.h b/src/RageDisplay_OGL.h index b4735a4e0a..8fa8f3a5a0 100644 --- a/src/RageDisplay_OGL.h +++ b/src/RageDisplay_OGL.h @@ -71,6 +71,7 @@ public: bool IsEffectModeSupported( EffectMode effect ); bool SupportsRenderToTexture() const; unsigned CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ); + unsigned GetRenderTarget(); void SetRenderTarget( unsigned iHandle, bool bPreserveTexture ); bool IsZWriteEnabled() const; bool IsZTestEnabled() const; diff --git a/src/RageTextureRenderTarget.cpp b/src/RageTextureRenderTarget.cpp index 33df34c887..d62c307883 100644 --- a/src/RageTextureRenderTarget.cpp +++ b/src/RageTextureRenderTarget.cpp @@ -47,6 +47,7 @@ void RageTextureRenderTarget::Destroy() void RageTextureRenderTarget::BeginRenderingTo( bool bPreserveTexture ) { + m_iPreviousRenderTarget = DISPLAY->GetRenderTarget( ); DISPLAY->SetRenderTarget( m_iTexHandle, bPreserveTexture ); /* We're rendering to a texture, not the framebuffer. @@ -69,7 +70,7 @@ void RageTextureRenderTarget::FinishRenderingTo() DISPLAY->CameraPopMatrix(); DISPLAY->PopMatrix(); - DISPLAY->SetRenderTarget( 0 ); + DISPLAY->SetRenderTarget( m_iPreviousRenderTarget ); } // lua start diff --git a/src/RageTextureRenderTarget.h b/src/RageTextureRenderTarget.h index b4a9dee90a..2932637013 100644 --- a/src/RageTextureRenderTarget.h +++ b/src/RageTextureRenderTarget.h @@ -27,6 +27,7 @@ private: void Create(); void Destroy(); unsigned m_iTexHandle; + unsigned m_iPreviousRenderTarget; }; #endif