diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 3adfc0e1ab..e571e644ff 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -54,7 +54,6 @@ int g_glVersion; int RageDisplay::GetFPS() const { return g_iFPS; } int RageDisplay::GetVPF() const { return g_iVPF; } int RageDisplay::GetDPF() const { return g_iDPF; } -DEVMODE SMGfx; static int g_iFramesRenderedSinceLastCheck, g_iVertsRenderedSinceLastCheck, @@ -371,7 +370,7 @@ void RageDisplay::Translate( float x, float y, float z ) RageMatrix matTemp; RageMatrixTranslation( &matTemp, x, y, z ); RageMatrix& matTop = GetTopModelMatrix(); - RageMatrixMultiply( &matTop, &matTemp, &matTop ); + sgPreMultMat4( matTop.m, matTemp.m ); } void RageDisplay::TranslateLocal( float x, float y, float z ) @@ -379,7 +378,7 @@ void RageDisplay::TranslateLocal( float x, float y, float z ) RageMatrix matTemp; RageMatrixTranslation( &matTemp, x, y, z ); RageMatrix& matTop = GetTopModelMatrix(); - RageMatrixMultiply( &matTop, &matTop, &matTemp ); + sgPostMultMat4( matTop.m, matTemp.m ); } void RageDisplay::Scale( float x, float y, float z ) @@ -387,7 +386,7 @@ void RageDisplay::Scale( float x, float y, float z ) RageMatrix matTemp; RageMatrixScaling( &matTemp, x, y, z ); RageMatrix& matTop = GetTopModelMatrix(); - RageMatrixMultiply( &matTop, &matTemp, &matTop ); + sgPreMultMat4( matTop.m, matTemp.m ); } void RageDisplay::RotateX( float r ) @@ -395,7 +394,7 @@ void RageDisplay::RotateX( float r ) RageMatrix matTemp; RageMatrixRotationX( &matTemp, r ); RageMatrix& matTop = GetTopModelMatrix(); - RageMatrixMultiply( &matTop, &matTemp, &matTop ); + sgPreMultMat4( matTop.m, matTemp.m ); } void RageDisplay::RotateY( float r ) @@ -403,7 +402,7 @@ void RageDisplay::RotateY( float r ) RageMatrix matTemp; RageMatrixRotationY( &matTemp, r ); RageMatrix& matTop = GetTopModelMatrix(); - RageMatrixMultiply( &matTop, &matTemp, &matTop ); + sgPreMultMat4( matTop.m, matTemp.m ); } void RageDisplay::RotateZ( float r ) @@ -411,7 +410,7 @@ void RageDisplay::RotateZ( float r ) RageMatrix matTemp; RageMatrixRotationZ( &matTemp, r ); RageMatrix& matTop = GetTopModelMatrix(); - RageMatrixMultiply( &matTop, &matTemp, &matTop ); + sgPreMultMat4( matTop.m, matTemp.m ); } void RageDisplay::SetTexture( RageTexture* pTexture ) diff --git a/stepmania/src/RageMath.cpp b/stepmania/src/RageMath.cpp index cf927971c7..07de489d8d 100644 --- a/stepmania/src/RageMath.cpp +++ b/stepmania/src/RageMath.cpp @@ -15,55 +15,89 @@ #include "RageTypes.h" #include "D3DX8Math.h" +#ifdef _DEBUG +#pragma comment(lib, "plib-1.6.0/sg_d.lib") +#pragma comment(lib, "plib-1.6.0/ul_d.lib") +#else +#pragma comment(lib, "plib-1.6.0/sg.lib") +#pragma comment(lib, "plib-1.6.0/ul.lib") +#endif void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV ) { - D3DXVec2Normalize( (D3DXVECTOR2*)pOut, (const D3DXVECTOR2*)pV ); + sgNormalizeVec2( (float*)pOut, (const float*)pV ); } void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM ) { - D3DXVec3TransformCoord( (D3DXVECTOR3*)pOut, (const D3DXVECTOR3*)pV, (const D3DXMATRIX*)pM ); + sgFullXformPnt3 ( (float*)pOut, (float*)pV, pM->m ); } void RageMatrixIdentity( RageMatrix* pOut ) { - D3DXMatrixIdentity( (D3DXMATRIX*)pOut ); + sgMakeIdentMat4( pOut->m ); } void RageMatrixMultiply( RageMatrix* pOut, const RageMatrix* pA, const RageMatrix* pB ) { - D3DXMatrixMultiply( (D3DXMATRIX*)pOut, (const D3DXMATRIX*)pA, (const D3DXMATRIX*)pB ); + sgMultMat4( pOut->m, pB->m, pA->m ); } void RageMatrixTranslation( RageMatrix* pOut, float x, float y, float z ) { - D3DXMatrixTranslation( (D3DXMATRIX*)pOut, x, y, z ); + RageMatrixIdentity(pOut); + pOut->m[3][0] = x; + pOut->m[3][1] = y; + pOut->m[3][2] = z; } void RageMatrixScaling( RageMatrix* pOut, float x, float y, float z ) { - D3DXMatrixScaling( (D3DXMATRIX*)pOut, x, y, z ); + RageMatrixIdentity(pOut); + pOut->m[0][0] = x; + pOut->m[1][1] = y; + pOut->m[2][2] = z; } void RageMatrixRotationX( RageMatrix* pOut, float theta ) -{ - D3DXMatrixRotationX( (D3DXMATRIX*)pOut, theta ); +{ /* UNTESTED */ + RageMatrixIdentity(pOut); + pOut->m[1][1] = cosf(theta); + pOut->m[2][2] = pOut->m[1][1]; + + pOut->m[2][1] = sinf(theta); + pOut->m[1][2] = -pOut->m[2][1]; } void RageMatrixRotationY( RageMatrix* pOut, float theta ) -{ - D3DXMatrixRotationY( (D3DXMATRIX*)pOut, theta ); +{ /* UNTESTED */ + RageMatrixIdentity(pOut); + pOut->m[0][0] = cosf(theta); + pOut->m[2][2] = pOut->m[0][0]; + + pOut->m[0][2] = sinf(theta); + pOut->m[2][0] = -pOut->m[0][2]; } void RageMatrixRotationZ( RageMatrix* pOut, float theta ) { - D3DXMatrixRotationZ( (D3DXMATRIX*)pOut, theta ); + RageMatrixIdentity(pOut); + pOut->m[0][0] = cosf(theta); + pOut->m[1][1] = pOut->m[0][0]; + + pOut->m[0][1] = sinf(theta); + pOut->m[1][0] = -pOut->m[0][1]; } void RageMatrixOrthoOffCenterLH( RageMatrix* pOut, float l, float r, float b, float t, float zn, float zf ) { - D3DXMatrixOrthoOffCenterLH( (D3DXMATRIX*)pOut, l, r, b, t, zn, zf ); + RageMatrixIdentity(pOut); + pOut->m[0][0] = 2 / (r-l); + pOut->m[1][1] = 2 / (t-b); + pOut->m[2][2] = -2 / (zn-zf); + pOut->m[3][0] = -(r+l)/(r-l); + pOut->m[3][1] = -(t+b)/(t-b); + pOut->m[3][2] = -(zf+zn)/(zn-zf); } void RageMatrixLookAtLH( RageMatrix* pOut, const RageVector3* pEye, const RageVector3* pAt, const RageVector3* pUp ) @@ -75,5 +109,3 @@ void RageMatrixPerspectiveFovLH( RageMatrix* pOut, float fovy, float Aspect, flo { D3DXMatrixPerspectiveFovLH( (D3DXMATRIX*)pOut, fovy, Aspect, zn, zf ); } - - diff --git a/stepmania/src/RageMath.h b/stepmania/src/RageMath.h index c4090e8163..d5a377e388 100644 --- a/stepmania/src/RageMath.h +++ b/stepmania/src/RageMath.h @@ -15,6 +15,7 @@ struct RageVector2; struct RageVector3; struct RageMatrix; +#include "plib-1.6.0/sg.h" void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV ); void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM );