From 3f6e95b7d85d35064dfd57aa0e4faacd1e3f4eb0 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 5 Nov 2005 03:08:09 +0000 Subject: [PATCH] fix D3D texture coord generation --- stepmania/src/BitmapText.cpp | 2 +- stepmania/src/EnumHelper.h | 1 + stepmania/src/Model.cpp | 16 +-- stepmania/src/NoteDisplay.cpp | 6 +- stepmania/src/RageDisplay.h | 9 +- stepmania/src/RageDisplay_D3D.cpp | 165 ++++++++++++++++-------------- stepmania/src/RageDisplay_D3D.h | 2 +- stepmania/src/RageDisplay_Null.h | 2 +- stepmania/src/RageDisplay_OGL.cpp | 8 +- stepmania/src/RageDisplay_OGL.h | 2 +- stepmania/src/Sprite.cpp | 2 +- 11 files changed, 118 insertions(+), 97 deletions(-) diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index c4385e17f9..1e47bcd086 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -325,7 +325,7 @@ void BitmapText::DrawChars() while( end < iEndGlyph && m_pTextures[end] == m_pTextures[start] ) end++; DISPLAY->ClearAllTextures(); - DISPLAY->SetTexture( 0, m_pTextures[start] ); + DISPLAY->SetTexture( TextureUnit_1, m_pTextures[start] ); // don't bother setting texture render states for text. We never go outside of 0..1. //Actor::SetTextureRenderStates(); RageSpriteVertex &start_vertex = m_aVertices[start*4]; diff --git a/stepmania/src/EnumHelper.h b/stepmania/src/EnumHelper.h index 4373660c9b..4e2b7e0f83 100644 --- a/stepmania/src/EnumHelper.h +++ b/stepmania/src/EnumHelper.h @@ -33,6 +33,7 @@ static inline void enum_add( T &val, int iAmt ) } #define FOREACH_ENUM( e, max, var ) for( e var=(e)0; var( var, +1 ) ) +#define FOREACH_ENUM2( e, var ) for( e var=(e)0; var( var, +1 ) ) static const CString EMPTY_STRING; diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index eda34fc5a1..4368da43ac 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -366,7 +366,7 @@ void Model::DrawPrimitives() if( DISPLAY->GetNumTextureUnits() < 2 ) { // render the diffuse texture - DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); + DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ); Actor::SetTextureRenderStates(); // set Actor-specified render states DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); DrawMesh( i ); @@ -374,7 +374,7 @@ void Model::DrawPrimitives() // render the additive texture if( mat.alpha.GetCurrentTexture() ) { - DISPLAY->SetTexture( 0, mat.alpha.GetCurrentTexture() ); + DISPLAY->SetTexture( TextureUnit_1, mat.alpha.GetCurrentTexture() ); Actor::SetTextureRenderStates(); // set Actor-specified render states DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); @@ -387,14 +387,14 @@ void Model::DrawPrimitives() else { // render the diffuse texture with texture unit 1 - DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); + DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ); Actor::SetTextureRenderStates(); // set Actor-specified render states DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); // render the additive texture with texture unit 2 if( mat.alpha.GetCurrentTexture() ) { - DISPLAY->SetTexture( 1, mat.alpha.GetCurrentTexture() ); + DISPLAY->SetTexture( TextureUnit_2, mat.alpha.GetCurrentTexture() ); Actor::SetTextureRenderStates(); // set Actor-specified render states DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); DISPLAY->SetTextureModeAdd(); @@ -402,18 +402,18 @@ void Model::DrawPrimitives() } else { - DISPLAY->SetTexture( 1, NULL ); + DISPLAY->SetTexture( TextureUnit_2, NULL ); // set current texture back to 0 or else texture transform applied above // isn't used. Why?!? - DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); + DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ); } /* go */ DrawMesh( i ); // Turn off Environment mapping on tex unit 0. Is there a better way to reset? - DISPLAY->SetTexture( 0, NULL ); + DISPLAY->SetTexture( TextureUnit_1, NULL ); DISPLAY->SetSphereEnvironmentMapping( 0 ); } @@ -462,7 +462,7 @@ void Model::DrawPrimitives() if( pMesh->nMaterialIndex != -1 ) { msMaterial& mat = m_Materials[ pMesh->nMaterialIndex ]; - DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); + DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ); Actor::SetTextureRenderStates(); // set Actor-specified render states } else diff --git a/stepmania/src/NoteDisplay.cpp b/stepmania/src/NoteDisplay.cpp index 282c71988e..9e88e5da17 100644 --- a/stepmania/src/NoteDisplay.cpp +++ b/stepmania/src/NoteDisplay.cpp @@ -476,7 +476,7 @@ void NoteDisplay::DrawHoldTopCap( const TapNote& tn, int iCol, int iRow, bool bI RageTexture* pTexture = pSprTopCap->GetTexture(); const RectF *pRect = pSprTopCap->GetCurrentTextureCoordRect(); DISPLAY->ClearAllTextures(); - DISPLAY->SetTexture( 0, pTexture ); + DISPLAY->SetTexture( TextureUnit_1, pTexture ); DISPLAY->SetBlendMode( BLEND_NORMAL ); DISPLAY->SetCullMode( CULL_NONE ); DISPLAY->SetTextureWrapping(false); @@ -565,7 +565,7 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, int iRow, bool bIsB RageTexture* pTexture = pSprBody->GetTexture(); const RectF *pRect = pSprBody->GetCurrentTextureCoordRect(); DISPLAY->ClearAllTextures(); - DISPLAY->SetTexture( 0, pTexture ); + DISPLAY->SetTexture( TextureUnit_1, pTexture ); DISPLAY->SetBlendMode( BLEND_NORMAL ); DISPLAY->SetCullMode( CULL_NONE ); DISPLAY->SetTextureWrapping( true ); @@ -663,7 +663,7 @@ void NoteDisplay::DrawHoldBottomCap( const TapNote& tn, int iCol, int iRow, bool RageTexture* pTexture = pBottomCap->GetTexture(); const RectF *pRect = pBottomCap->GetCurrentTextureCoordRect(); DISPLAY->ClearAllTextures(); - DISPLAY->SetTexture( 0, pTexture ); + DISPLAY->SetTexture( TextureUnit_1, pTexture ); DISPLAY->SetBlendMode( BLEND_NORMAL ); DISPLAY->SetCullMode( CULL_NONE ); DISPLAY->SetTextureWrapping(false); diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 9e8751eba5..07fa20cf0d 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -8,7 +8,12 @@ const int REFRESH_DEFAULT = 0; struct RageSurface; -const int MAX_TEXTURE_UNITS = 2; +enum TextureUnit +{ + TextureUnit_1, + TextureUnit_2, + NUM_TextureUnit +}; // RageCompiledGeometry holds vertex data in a format that is most efficient // for the graphics API. @@ -162,7 +167,7 @@ public: virtual void DeleteTexture( unsigned uTexHandle ) = 0; virtual void ClearAllTextures() = 0; virtual int GetNumTextureUnits() = 0; - virtual void SetTexture( int iTextureUnitIndex, RageTexture* pTexture ) = 0; + virtual void SetTexture( TextureUnit tu, RageTexture* pTexture ) = 0; virtual void SetTextureModeModulate() = 0; virtual void SetTextureModeGlow() = 0; virtual void SetTextureModeAdd() = 0; diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 8e0a238e13..bb90cb338a 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -18,6 +18,7 @@ #include "PrefsManager.h" #include "RageSurface.h" #include "RageSurfaceUtils.h" +#include "EnumHelper.h" #if !defined(XBOX) #include "archutils/Win32/GraphicsWindow.h" @@ -59,8 +60,9 @@ D3DCAPS8 g_DeviceCaps; D3DDISPLAYMODE g_DesktopMode; D3DPRESENT_PARAMETERS g_d3dpp; int g_ModelMatrixCnt=0; -int g_iCurrentTextureIndex = 0; +TextureUnit g_currentTextureUnit = TextureUnit_1; static int g_iActualRefreshRateInHz = 60; +static bool g_bSphereMapping[NUM_TextureUnit] = { false, false }; static float g_fZBias = 0; /* Direct3D doesn't associate a palette with textures. @@ -783,24 +785,56 @@ void RageDisplay_D3D::SendCurrentMatrices() RageMatrixMultiply( &m, &m, GetWorldTop() ); g_pd3dDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX*)&m ); - /* - * Direct3D is expecting a 3x3 matrix loaded into the 4x4 in order to transform - * the 2-component texture coordinates. We currently only use translate and scale, - * and ignore the z component entirely, so convert the texture matrix from - * 4x4 to 3x3 by dropping z. - */ - const RageMatrix &tex1 = *GetTextureTop(); - const RageMatrix tex2 = RageMatrix - ( - tex1.m[0][0], tex1.m[0][1], tex1.m[0][3], 0, - tex1.m[1][0], tex1.m[1][1], tex1.m[1][3], 0, - tex1.m[3][0], tex1.m[3][1], tex1.m[3][3], 0, - 0, 0, 0, 0 - ); - g_pd3dDevice->SetTransform( D3DTS_TEXTURE0, (D3DMATRIX*)&tex2 ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU ); + FOREACH_ENUM2( TextureUnit, tu ) + { + // Optimization opportunity: Turn off texture transform if not using texture coords. + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 ); + + // If no texture is set for this texture unit, don't bother setting it up. + IDirect3DBaseTexture8* ppTexture = NULL; + g_pd3dDevice->GetTexture( g_currentTextureUnit, &ppTexture ); + if( ppTexture == NULL ) + continue; + + + if( g_bSphereMapping[tu] ) + { + static const RageMatrix tex = RageMatrix + ( + 0.50f, 0.0f, 0.0f, 0.0f, + 0.0f, -0.50f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.50, -0.50, 0.0f, 1.0f + ); + g_pd3dDevice->SetTransform( (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+tu), (D3DMATRIX*)&tex ); + + // Tell D3D to use transformed reflection vectors as texture co-ordinate 0 + // and then transform this coordinate by the specified texture matrix. + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL ); + } + else + { + /* + * Direct3D is expecting a 3x3 matrix loaded into the 4x4 in order to transform + * the 2-component texture coordinates. We currently only use translate and scale, + * and ignore the z component entirely, so convert the texture matrix from + * 4x4 to 3x3 by dropping z. + */ + + const RageMatrix &tex1 = *GetTextureTop(); + const RageMatrix tex2 = RageMatrix + ( + tex1.m[0][0], tex1.m[0][1], tex1.m[0][3], 0, + tex1.m[1][0], tex1.m[1][1], tex1.m[1][3], 0, + tex1.m[3][0], tex1.m[3][1], tex1.m[3][3], 0, + 0, 0, 0, 0 + ); + g_pd3dDevice->SetTransform( D3DTS_TEXTURE0, (D3DMATRIX*)&tex2 ); + + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU ); + } + } } class RageCompiledGeometrySWD3D : public RageCompiledGeometry @@ -1030,9 +1064,9 @@ void RageDisplay_D3D::DrawLineStrip( const RageSpriteVertex v[], int iNumVerts, void RageDisplay_D3D::ClearAllTextures() { - for( int i=0; i= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported + if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; if( pTexture == NULL ) { - g_pd3dDevice->SetTexture( g_iCurrentTextureIndex, NULL ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLOROP, D3DTOP_DISABLE ); + g_pd3dDevice->SetTexture( g_currentTextureUnit, NULL ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_DISABLE ); } else { unsigned uTexHandle = pTexture->GetTexHandle(); IDirect3DTexture8* pTex = (IDirect3DTexture8*)uTexHandle; - g_pd3dDevice->SetTexture( g_iCurrentTextureIndex, pTex ); + g_pd3dDevice->SetTexture( g_currentTextureUnit, pTex ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLOROP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_MODULATE ); // Set palette (if any) SetPalette(uTexHandle); @@ -1067,53 +1101,53 @@ void RageDisplay_D3D::SetTexture( int iTextureUnitIndex, RageTexture* pTexture ) } void RageDisplay_D3D::SetTextureModeModulate() { - if( g_iCurrentTextureIndex >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported + if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; // Use D3DTA_CURRENT instead of diffuse so that multitexturing works // properly. For stage 0, D3DTA_CURRENT is the diffuse color. - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLORARG2, D3DTA_CURRENT ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLOROP, D3DTOP_MODULATE ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); } void RageDisplay_D3D::SetTextureModeGlow() { - if( g_iCurrentTextureIndex >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported + if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLORARG2, D3DTA_CURRENT ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); } void RageDisplay_D3D::SetTextureModeAdd() { - if( g_iCurrentTextureIndex >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported + if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLORARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLORARG2, D3DTA_CURRENT ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_COLOROP, D3DTOP_ADD ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ALPHAOP, D3DTOP_ADD ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_ADD ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAOP, D3DTOP_ADD ); } void RageDisplay_D3D::SetTextureFiltering( bool b ) { - if( g_iCurrentTextureIndex >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported + if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_MINFILTER, b ? D3DTEXF_LINEAR : D3DTEXF_POINT ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_MAGFILTER, b ? D3DTEXF_LINEAR : D3DTEXF_POINT ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_MINFILTER, b ? D3DTEXF_LINEAR : D3DTEXF_POINT ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_MAGFILTER, b ? D3DTEXF_LINEAR : D3DTEXF_POINT ); } void RageDisplay_D3D::SetBlendMode( BlendMode mode ) @@ -1185,12 +1219,12 @@ void RageDisplay_D3D::ClearZBuffer() void RageDisplay_D3D::SetTextureWrapping( bool b ) { - if( g_iCurrentTextureIndex >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported + if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; int mode = b ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP; - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ADDRESSU, mode ); - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_ADDRESSV, mode ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ADDRESSU, mode ); + g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ADDRESSV, mode ); } void RageDisplay_D3D::SetMaterial( @@ -1431,28 +1465,9 @@ RageMatrix RageDisplay_D3D::GetOrthoMatrix( float l, float r, float b, float t, void RageDisplay_D3D::SetSphereEnvironmentMapping( bool b ) { - if( g_iCurrentTextureIndex >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported - return; - - // http://www.gamasutra.com/features/20000811/wyatt_03.htm - - if( b ) - { - static const RageMatrix tex = RageMatrix - ( - 0.40f, 0.0f, 0.0f, 0.0f, - 0.0f, -0.40f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.50, -0.50, 0.0f, 1.0f - ); - g_pd3dDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+g_iCurrentTextureIndex), (D3DMATRIX*)&tex); - } - - // Tell D3D to use transformed reflection vectors as texture co-ordinate 0 - // and then transform this coordinate by the specified texture matrix, also - // tell D3D that only the first two coordinates of the output are valid. - g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_TEXCOORDINDEX, b ? D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR : D3DTSS_TCI_PASSTHRU ); + g_bSphereMapping[g_currentTextureUnit] = b; } + /* * Copyright (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index c90966578d..e8d6e88a96 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -32,7 +32,7 @@ public: void DeleteTexture( unsigned uTexHandle ); void ClearAllTextures(); int GetNumTextureUnits(); - void SetTexture( int iTextureUnitIndex, RageTexture* pTexture ); + void SetTexture( TextureUnit tu, RageTexture* pTexture ); void SetTextureModeModulate(); void SetTextureModeGlow(); void SetTextureModeAdd(); diff --git a/stepmania/src/RageDisplay_Null.h b/stepmania/src/RageDisplay_Null.h index 2c66cab366..a133c1f4d3 100644 --- a/stepmania/src/RageDisplay_Null.h +++ b/stepmania/src/RageDisplay_Null.h @@ -29,7 +29,7 @@ public: void DeleteTexture( unsigned uTexHandle ) { } void ClearAllTextures() { } int GetNumTextureUnits() { return 1; } - void SetTexture( int iTextureUnitIndex, RageTexture* pTexture ) { } + void SetTexture( TextureUnit tu, RageTexture* pTexture ) { } void SetTextureModeModulate() { } void SetTextureModeGlow() { } void SetTextureModeAdd() { } diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 376dacb8a7..16deb112dd 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -1401,7 +1401,7 @@ void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNu void RageDisplay_OGL::ClearAllTextures() { - for( int i=0; iClearAllTextures(); - DISPLAY->SetTexture( 0, m_pTexture ); + DISPLAY->SetTexture( TextureUnit_1, m_pTexture ); // Must call this after setting the texture or else texture // parameters have no effect.