fix centering matrix + perspective projections
This commit is contained in:
@@ -238,8 +238,8 @@ void PrefsManager::Init()
|
|||||||
|
|
||||||
m_iCenterImageTranslateX = 0;
|
m_iCenterImageTranslateX = 0;
|
||||||
m_iCenterImageTranslateY = 0;
|
m_iCenterImageTranslateY = 0;
|
||||||
m_fCenterImageScaleX = 1;
|
m_fCenterImageAddWidth = 0;
|
||||||
m_fCenterImageScaleY = 1;
|
m_fCenterImageAddHeight = 0;
|
||||||
|
|
||||||
m_iAttractSoundFrequency = 1;
|
m_iAttractSoundFrequency = 1;
|
||||||
m_bAllowExtraStage = true;
|
m_bAllowExtraStage = true;
|
||||||
@@ -554,8 +554,8 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
|
|||||||
|
|
||||||
ini.GetValue( "Options", "CenterImageTranslateX", m_iCenterImageTranslateX );
|
ini.GetValue( "Options", "CenterImageTranslateX", m_iCenterImageTranslateX );
|
||||||
ini.GetValue( "Options", "CenterImageTranslateY", m_iCenterImageTranslateY );
|
ini.GetValue( "Options", "CenterImageTranslateY", m_iCenterImageTranslateY );
|
||||||
ini.GetValue( "Options", "CenterImageScaleX", m_fCenterImageScaleX );
|
ini.GetValue( "Options", "CenterImageAddWidth", m_fCenterImageAddWidth );
|
||||||
ini.GetValue( "Options", "CenterImageScaleY", m_fCenterImageScaleY );
|
ini.GetValue( "Options", "CenterImageAddHeight", m_fCenterImageAddHeight );
|
||||||
ini.GetValue( "Options", "AttractSoundFrequency", m_iAttractSoundFrequency );
|
ini.GetValue( "Options", "AttractSoundFrequency", m_iAttractSoundFrequency );
|
||||||
ini.GetValue( "Options", "AllowExtraStage", m_bAllowExtraStage );
|
ini.GetValue( "Options", "AllowExtraStage", m_bAllowExtraStage );
|
||||||
ini.GetValue( "Options", "HideDefaultNoteSkin", m_bHideDefaultNoteSkin );
|
ini.GetValue( "Options", "HideDefaultNoteSkin", m_bHideDefaultNoteSkin );
|
||||||
@@ -789,8 +789,8 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
|
|||||||
|
|
||||||
ini.SetValue( "Options", "CenterImageTranslateX", m_iCenterImageTranslateX );
|
ini.SetValue( "Options", "CenterImageTranslateX", m_iCenterImageTranslateX );
|
||||||
ini.SetValue( "Options", "CenterImageTranslateY", m_iCenterImageTranslateY );
|
ini.SetValue( "Options", "CenterImageTranslateY", m_iCenterImageTranslateY );
|
||||||
ini.SetValue( "Options", "CenterImageScaleX", m_fCenterImageScaleX );
|
ini.SetValue( "Options", "CenterImageAddWidth", m_fCenterImageAddWidth );
|
||||||
ini.SetValue( "Options", "CenterImageScaleY", m_fCenterImageScaleY );
|
ini.SetValue( "Options", "CenterImageAddHeight", m_fCenterImageAddHeight );
|
||||||
ini.SetValue( "Options", "AttractSoundFrequency", m_iAttractSoundFrequency );
|
ini.SetValue( "Options", "AttractSoundFrequency", m_iAttractSoundFrequency );
|
||||||
ini.SetValue( "Options", "AllowExtraStage", m_bAllowExtraStage );
|
ini.SetValue( "Options", "AllowExtraStage", m_bAllowExtraStage );
|
||||||
ini.SetValue( "Options", "HideDefaultNoteSkin", m_bHideDefaultNoteSkin );
|
ini.SetValue( "Options", "HideDefaultNoteSkin", m_bHideDefaultNoteSkin );
|
||||||
|
|||||||
@@ -192,8 +192,8 @@ public:
|
|||||||
bool m_bMemoryCardsMountOnlyWhenNecessary;
|
bool m_bMemoryCardsMountOnlyWhenNecessary;
|
||||||
int m_iCenterImageTranslateX;
|
int m_iCenterImageTranslateX;
|
||||||
int m_iCenterImageTranslateY;
|
int m_iCenterImageTranslateY;
|
||||||
float m_fCenterImageScaleX;
|
int m_fCenterImageAddWidth;
|
||||||
float m_fCenterImageScaleY;
|
int m_fCenterImageAddHeight;
|
||||||
int m_iAttractSoundFrequency; // 0 = never, 1 = every time
|
int m_iAttractSoundFrequency; // 0 = never, 1 = every time
|
||||||
bool m_bAllowExtraStage;
|
bool m_bAllowExtraStage;
|
||||||
bool m_bHideDefaultNoteSkin;
|
bool m_bHideDefaultNoteSkin;
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ void RageDisplay::SetDefaultRenderStates()
|
|||||||
SetBlendMode( BLEND_NORMAL );
|
SetBlendMode( BLEND_NORMAL );
|
||||||
SetTextureFiltering( true );
|
SetTextureFiltering( true );
|
||||||
LoadMenuPerspective(0, CENTER_X, CENTER_Y); // 0 FOV = ortho
|
LoadMenuPerspective(0, CENTER_X, CENTER_Y); // 0 FOV = ortho
|
||||||
ChangeCentering(0,0,1,1);
|
ChangeCentering(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -632,12 +632,26 @@ RageMatrix RageDisplay::GetFrustumMatrix( float l, float r, float b, float t, fl
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay::ChangeCentering( int trans_x, int trans_y, float scale_x, float scale_y )
|
void RageDisplay::ChangeCentering( int trans_x, int trans_y, int add_width, int add_height )
|
||||||
{
|
{
|
||||||
|
// in screen space, left edge = -1, right edge = 1, bottom edge = -1. top edge = 1
|
||||||
|
float fPercentShiftX = 2*trans_x/640.f;
|
||||||
|
float fPercentShiftY = -2*trans_y/480.f;
|
||||||
|
float fPercentScaleX = (640.f+add_width)/640.f;
|
||||||
|
float fPercentScaleY = (480.f+add_height)/480.f;
|
||||||
|
|
||||||
RageMatrix m1;
|
RageMatrix m1;
|
||||||
RageMatrix m2;
|
RageMatrix m2;
|
||||||
RageMatrixTranslation( &m1, float(trans_x), float(trans_y), 0 );
|
RageMatrixTranslation(
|
||||||
RageMatrixScaling( &m2, scale_x, scale_y, 1 );
|
&m1,
|
||||||
|
fPercentShiftX,
|
||||||
|
fPercentShiftY,
|
||||||
|
0 );
|
||||||
|
RageMatrixScaling(
|
||||||
|
&m2,
|
||||||
|
fPercentScaleX,
|
||||||
|
fPercentScaleY,
|
||||||
|
1 );
|
||||||
RageMatrixMultiply( &m_Centering, &m1, &m2 );
|
RageMatrixMultiply( &m_Centering, &m1, &m2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ public:
|
|||||||
void LoadLookAt( float fov, const RageVector3 &Eye, const RageVector3 &At, const RageVector3 &Up );
|
void LoadLookAt( float fov, const RageVector3 &Eye, const RageVector3 &At, const RageVector3 &Up );
|
||||||
|
|
||||||
/* Centering matrix */
|
/* Centering matrix */
|
||||||
void ChangeCentering( int trans_x, int trans_y, float scale_x, float scale_y );
|
void ChangeCentering( int trans_x, int trans_y, int add_width, int add_height );
|
||||||
|
|
||||||
RageSurface *CreateSurfaceFromPixfmt( PixelFormat pixfmt, void *pixels, int width, int height, int pitch );
|
RageSurface *CreateSurfaceFromPixfmt( PixelFormat pixfmt, void *pixels, int width, int height, int pitch );
|
||||||
PixelFormat FindPixelFormat( int bpp, int Rmask, int Gmask, int Bmask, int Amask, bool realtime=false );
|
PixelFormat FindPixelFormat( int bpp, int Rmask, int Gmask, int Bmask, int Amask, bool realtime=false );
|
||||||
|
|||||||
@@ -737,10 +737,11 @@ RageDisplay::VideoModeParams RageDisplay_D3D::GetVideoModeParams() const { retur
|
|||||||
|
|
||||||
void RageDisplay_D3D::SendCurrentMatrices()
|
void RageDisplay_D3D::SendCurrentMatrices()
|
||||||
{
|
{
|
||||||
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)GetProjectionTop() );
|
RageMatrix projection;
|
||||||
RageMatrix modelView;
|
RageMatrixMultiply( &projection, GetCentering(), GetProjectionTop() );
|
||||||
RageMatrixMultiply( &modelView, GetCentering(), GetViewTop() );
|
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)&projection );
|
||||||
g_pd3dDevice->SetTransform( D3DTS_VIEW, (D3DMATRIX*)&modelView );
|
|
||||||
|
g_pd3dDevice->SetTransform( D3DTS_VIEW, (D3DMATRIX*)GetViewTop() );
|
||||||
|
|
||||||
/* Convert to OpenGL-style "pixel-centered" coords */
|
/* Convert to OpenGL-style "pixel-centered" coords */
|
||||||
RageMatrix m;
|
RageMatrix m;
|
||||||
|
|||||||
@@ -836,14 +836,18 @@ static void SetupVertices( const RageSpriteVertex v[], int iNumVerts )
|
|||||||
|
|
||||||
void RageDisplay_OGL::SendCurrentMatrices()
|
void RageDisplay_OGL::SendCurrentMatrices()
|
||||||
{
|
{
|
||||||
|
RageMatrix projection;
|
||||||
|
RageMatrixMultiply( &projection, GetCentering(), GetProjectionTop() );
|
||||||
glMatrixMode( GL_PROJECTION );
|
glMatrixMode( GL_PROJECTION );
|
||||||
glLoadMatrixf( (const float*)GetProjectionTop() );
|
glLoadMatrixf( (const float*)&projection );
|
||||||
|
|
||||||
|
// OpenGL has just "modelView", whereas D3D has "world" and "view"
|
||||||
RageMatrix modelView;
|
RageMatrix modelView;
|
||||||
RageMatrixMultiply( &modelView, GetCentering(), GetViewTop() );
|
RageMatrixMultiply( &modelView, GetViewTop(), GetWorldTop() );
|
||||||
RageMatrixMultiply( &modelView, &modelView, GetWorldTop() );
|
|
||||||
glMatrixMode( GL_MODELVIEW );
|
glMatrixMode( GL_MODELVIEW );
|
||||||
glLoadMatrixf( (const float*)&modelView );
|
glLoadMatrixf( (const float*)&modelView );
|
||||||
glMatrixMode( GL_TEXTURE );
|
|
||||||
|
glMatrixMode( GL_TEXTURE );
|
||||||
glLoadMatrixf( (const float*)GetTextureTop() );
|
glLoadMatrixf( (const float*)GetTextureTop() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ void ScreenCenterImage::Input( const DeviceInput& DeviceI, const InputEventType
|
|||||||
if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == KEY_SPACE )
|
if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == KEY_SPACE )
|
||||||
{
|
{
|
||||||
PREFSMAN->m_iCenterImageTranslateX = PREFSMAN->m_iCenterImageTranslateY = 0;
|
PREFSMAN->m_iCenterImageTranslateX = PREFSMAN->m_iCenterImageTranslateY = 0;
|
||||||
PREFSMAN->m_fCenterImageScaleX = PREFSMAN->m_fCenterImageScaleY = 1;
|
PREFSMAN->m_fCenterImageAddWidth = PREFSMAN->m_fCenterImageAddHeight = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,29 +148,29 @@ void ScreenCenterImage::Input( const DeviceInput& DeviceI, const InputEventType
|
|||||||
|
|
||||||
void ScreenCenterImage::Move( Axis axis, float fDelta )
|
void ScreenCenterImage::Move( Axis axis, float fDelta )
|
||||||
{
|
{
|
||||||
float fValues[4] =
|
int *piValues[4] =
|
||||||
{
|
{
|
||||||
(float) PREFSMAN->m_iCenterImageTranslateX,
|
&PREFSMAN->m_iCenterImageTranslateX,
|
||||||
(float) PREFSMAN->m_iCenterImageTranslateY,
|
&PREFSMAN->m_iCenterImageTranslateY,
|
||||||
PREFSMAN->m_fCenterImageScaleX,
|
&PREFSMAN->m_fCenterImageAddWidth,
|
||||||
PREFSMAN->m_fCenterImageScaleY
|
&PREFSMAN->m_fCenterImageAddHeight
|
||||||
};
|
};
|
||||||
|
|
||||||
if( axis == AXIS_SCALE_X || axis == AXIS_SCALE_Y )
|
*piValues[axis] += lrintf( fDelta );
|
||||||
fDelta *= 0.001f;
|
|
||||||
|
|
||||||
fValues[axis] += fDelta;
|
|
||||||
|
|
||||||
PREFSMAN->m_iCenterImageTranslateX = lrintf( fValues[0] );
|
|
||||||
PREFSMAN->m_iCenterImageTranslateY = lrintf( fValues[1] );
|
|
||||||
PREFSMAN->m_fCenterImageScaleX = fValues[2];
|
|
||||||
PREFSMAN->m_fCenterImageScaleY = fValues[3];
|
|
||||||
|
|
||||||
DISPLAY->ChangeCentering(
|
DISPLAY->ChangeCentering(
|
||||||
PREFSMAN->m_iCenterImageTranslateX,
|
PREFSMAN->m_iCenterImageTranslateX,
|
||||||
PREFSMAN->m_iCenterImageTranslateY,
|
PREFSMAN->m_iCenterImageTranslateY,
|
||||||
PREFSMAN->m_fCenterImageScaleX,
|
PREFSMAN->m_fCenterImageAddWidth,
|
||||||
PREFSMAN->m_fCenterImageScaleY );
|
PREFSMAN->m_fCenterImageAddHeight );
|
||||||
|
|
||||||
|
CString sMessage =
|
||||||
|
ssprintf( "Centering: x=%d, y=%d, width=%d, height=%d",
|
||||||
|
PREFSMAN->m_iCenterImageTranslateX,
|
||||||
|
PREFSMAN->m_iCenterImageTranslateY,
|
||||||
|
PREFSMAN->m_fCenterImageAddWidth,
|
||||||
|
PREFSMAN->m_fCenterImageAddHeight );
|
||||||
|
SCREENMAN->SystemMessageNoAnimate( sMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenCenterImage::Update( float fDeltaTime )
|
void ScreenCenterImage::Update( float fDeltaTime )
|
||||||
|
|||||||
@@ -128,8 +128,8 @@ void ApplyGraphicOptions()
|
|||||||
DISPLAY->ChangeCentering(
|
DISPLAY->ChangeCentering(
|
||||||
PREFSMAN->m_iCenterImageTranslateX,
|
PREFSMAN->m_iCenterImageTranslateX,
|
||||||
PREFSMAN->m_iCenterImageTranslateY,
|
PREFSMAN->m_iCenterImageTranslateY,
|
||||||
PREFSMAN->m_fCenterImageScaleX,
|
PREFSMAN->m_fCenterImageAddWidth,
|
||||||
PREFSMAN->m_fCenterImageScaleY );
|
PREFSMAN->m_fCenterImageAddHeight );
|
||||||
|
|
||||||
bNeedReload |= TEXTUREMAN->SetPrefs(
|
bNeedReload |= TEXTUREMAN->SetPrefs(
|
||||||
RageTextureManagerPrefs(
|
RageTextureManagerPrefs(
|
||||||
@@ -1066,8 +1066,8 @@ int main(int argc, char* argv[])
|
|||||||
DISPLAY->ChangeCentering(
|
DISPLAY->ChangeCentering(
|
||||||
PREFSMAN->m_iCenterImageTranslateX,
|
PREFSMAN->m_iCenterImageTranslateX,
|
||||||
PREFSMAN->m_iCenterImageTranslateY,
|
PREFSMAN->m_iCenterImageTranslateY,
|
||||||
PREFSMAN->m_fCenterImageScaleX,
|
PREFSMAN->m_fCenterImageAddWidth,
|
||||||
PREFSMAN->m_fCenterImageScaleY );
|
PREFSMAN->m_fCenterImageAddHeight );
|
||||||
|
|
||||||
TEXTUREMAN = new RageTextureManager();
|
TEXTUREMAN = new RageTextureManager();
|
||||||
TEXTUREMAN->SetPrefs(
|
TEXTUREMAN->SetPrefs(
|
||||||
|
|||||||
Reference in New Issue
Block a user