From 7b17d06133cfbef2da762cf5a41d9c3cdfcab96e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 26 Mar 2006 21:59:29 +0000 Subject: [PATCH] split out GetCenteringMatrix --- stepmania/src/RageDisplay.cpp | 19 +++++++++++++------ stepmania/src/RageDisplay.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 56ef5a93fa..f08f86b112 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -613,15 +613,15 @@ void RageDisplay::ChangeCentering( int iTranslateX, int iTranslateY, int iAddWid UpdateCentering(); } -void RageDisplay::UpdateCentering() +RageMatrix RageDisplay::GetCenteringMatrix( float fTranslateX, float fTranslateY, float fAddWidth, float fAddHeight ) const { // in screen space, left edge = -1, right edge = 1, bottom edge = -1. top edge = 1 float fWidth = (float) GetActualVideoModeParams().width; float fHeight = (float) GetActualVideoModeParams().height; - float fPercentShiftX = SCALE( g_iTranslateX, 0, fWidth, 0, +2.0f ); - float fPercentShiftY = SCALE( g_iTranslateY, 0, fHeight, 0, -2.0f ); - float fPercentScaleX = SCALE( g_iAddWidth, 0, fWidth, 1.0f, 2.0f ); - float fPercentScaleY = SCALE( g_iAddHeight, 0, fHeight, 1.0f, 2.0f ); + float fPercentShiftX = SCALE( fTranslateX, 0, fWidth, 0, +2.0f ); + float fPercentShiftY = SCALE( fTranslateY, 0, fHeight, 0, -2.0f ); + float fPercentScaleX = SCALE( fAddWidth, 0, fWidth, 1.0f, 2.0f ); + float fPercentScaleY = SCALE( fAddHeight, 0, fHeight, 1.0f, 2.0f ); RageMatrix m1; RageMatrix m2; @@ -635,7 +635,14 @@ void RageDisplay::UpdateCentering() fPercentScaleX, fPercentScaleY, 1 ); - RageMatrixMultiply( &m_Centering, &m1, &m2 ); + RageMatrix mOut; + RageMatrixMultiply( &mOut, &m1, &m2 ); + return mOut; +} + +void RageDisplay::UpdateCentering() +{ + m_Centering = GetCenteringMatrix( (float) g_iTranslateX, (float) g_iTranslateY, (float) g_iAddWidth, (float) g_iAddHeight ); } bool RageDisplay::SaveScreenshot( RString sPath, GraphicsFileFormat format ) diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 99d6aff53f..df27085162 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -326,6 +326,7 @@ protected: // Matrix that adjusts position and scale of image on the screen // RageMatrix m_Centering; + RageMatrix GetCenteringMatrix( float fTranslateX, float fTranslateY, float fAddWidth, float fAddHeight ) const; void UpdateCentering(); // Called by the RageDisplay derivitives