diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index f98defa94d..3fc836c570 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -513,7 +513,7 @@ bool BitmapText::EarlyAbortDraw() const void BitmapText::DrawPrimitives() { Actor::SetGlobalRenderStates(); // set Actor-specified render states - DISPLAY->SetTextureMode( TextureMode_Modulate ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate ); /* Draw if we're not fully transparent or the zbuffer is enabled */ if( m_pTempState->diffuse[0].a != 0 ) @@ -601,7 +601,7 @@ void BitmapText::DrawPrimitives() /* render the glow pass */ if( m_pTempState->glow.a > 0.0001f ) { - DISPLAY->SetTextureMode( TextureMode_Glow ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow ); for( unsigned i=0; iglow; @@ -773,7 +773,7 @@ void ColorBitmapText::SimpleAddLine( const RString &sAddition, const int iWidthP void ColorBitmapText::DrawPrimitives( ) { Actor::SetGlobalRenderStates(); // set Actor-specified render states - DISPLAY->SetTextureMode( TextureMode_Modulate ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate ); /* Draw if we're not fully transparent or the zbuffer is enabled */ if( m_pTempState->diffuse[0].a != 0 ) @@ -822,7 +822,7 @@ void ColorBitmapText::DrawPrimitives( ) /* render the glow pass */ if( m_pTempState->glow.a > 0.0001f ) { - DISPLAY->SetTextureMode( TextureMode_Glow ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow ); for( unsigned i=0; iglow; diff --git a/stepmania/src/GraphDisplay.cpp b/stepmania/src/GraphDisplay.cpp index 3d388dadd6..8b16b1f9b7 100644 --- a/stepmania/src/GraphDisplay.cpp +++ b/stepmania/src/GraphDisplay.cpp @@ -132,7 +132,7 @@ public: // parameters have no effect. Actor::SetTextureRenderStates(); - DISPLAY->SetTextureMode( TextureMode_Modulate ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate ); DISPLAY->DrawQuadStrip( m_Slices, ARRAYLEN(m_Slices) ); } diff --git a/stepmania/src/GrooveRadar.cpp b/stepmania/src/GrooveRadar.cpp index 3a90346b67..db8850e4ae 100644 --- a/stepmania/src/GrooveRadar.cpp +++ b/stepmania/src/GrooveRadar.cpp @@ -160,7 +160,7 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives() const float fRadius = GetUnzoomedWidth()/2.0f*1.1f; DISPLAY->ClearAllTextures(); - DISPLAY->SetTextureMode( TextureMode_Modulate ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate ); RageSpriteVertex v[12]; // needed to draw 5 fan primitives and 10 strip primitives if( !m_bValuesVisible ) diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index 51581c3278..ba6240a2a9 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -322,7 +322,7 @@ void Model::DrawPrimitives() ////////////////////// if( m_pTempState->diffuse[0].a > 0 ) { - DISPLAY->SetTextureMode( TextureMode_Modulate ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate ); for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i ) { @@ -367,7 +367,7 @@ void Model::DrawPrimitives() DISPLAY->SetTexture( TextureUnit_2, mat.alpha.GetCurrentTexture() ? mat.alpha.GetCurrentTexture()->GetTexHandle() : 0 ); Actor::SetTextureRenderStates(); // set Actor-specified render states DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); - DISPLAY->SetTextureMode( TextureMode_Add ); + DISPLAY->SetTextureMode( TextureUnit_2, TextureMode_Add ); DISPLAY->SetTextureFiltering( true ); } else @@ -434,7 +434,7 @@ void Model::DrawPrimitives() ////////////////////// if( m_pTempState->glow.a > 0.0001f ) { - DISPLAY->SetTextureMode( TextureMode_Glow ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow ); for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i ) { diff --git a/stepmania/src/NoteDisplay.cpp b/stepmania/src/NoteDisplay.cpp index 0a10350f4d..d2b5d503db 100644 --- a/stepmania/src/NoteDisplay.cpp +++ b/stepmania/src/NoteDisplay.cpp @@ -515,9 +515,9 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, float fBeat, bool b } if( bGlow ) - DISPLAY->SetTextureMode( TextureMode_Glow ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow ); else - DISPLAY->SetTextureMode( TextureMode_Modulate ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate ); const bool bWavyPartsNeedZBuffer = ArrowEffects::NeedZBuffer( m_pPlayerState ); DISPLAY->SetZTestMode( bWavyPartsNeedZBuffer?ZTEST_WRITE_ON_PASS:ZTEST_OFF ); diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index ff66fd0fca..9fd3a531bc 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -203,7 +203,7 @@ public: virtual void ClearAllTextures() = 0; virtual int GetNumTextureUnits() = 0; virtual void SetTexture( TextureUnit tu, unsigned iTexture ) = 0; - virtual void SetTextureMode( TextureMode tm ) = 0; + virtual void SetTextureMode( TextureUnit tu, TextureMode tm ) = 0; virtual void SetTextureWrapping( bool b ) = 0; virtual int GetMaxTextureSize() const = 0; virtual void SetTextureFiltering( bool b ) = 0; diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 5d540d2b98..2e07c826e8 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -1131,34 +1131,34 @@ void RageDisplay_D3D::SetTexture( TextureUnit tu, unsigned iTexture ) g_currentTextureUnit = tu; // g_DeviceCaps.MaxSimultaneousTextures = 1; - if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported + if( tu >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; if( iTexture == 0 ) { - g_pd3dDevice->SetTexture( g_currentTextureUnit, NULL ); + g_pd3dDevice->SetTexture( tu, NULL ); // Intentionally commented out. Don't mess with texture stage state when just setting the texture. // Model sets its texture modes before setting the final texture. - //g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_DISABLE ); + //g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_DISABLE ); } else { IDirect3DTexture8* pTex = (IDirect3DTexture8*) iTexture; - g_pd3dDevice->SetTexture( g_currentTextureUnit, pTex ); + g_pd3dDevice->SetTexture( tu, pTex ); // Intentionally commented out. Don't mess with texture stage state when just setting the texture. // Model sets its texture modes before setting the final texture. - //g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_MODULATE ); + //g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_MODULATE ); // Set palette (if any) SetPalette( iTexture ); } } -void RageDisplay_D3D::SetTextureMode( TextureMode tm ) +void RageDisplay_D3D::SetTextureMode( TextureUnit tu, TextureMode tm ) { - if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported + if( tu >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported return; switch( tm ) @@ -1167,28 +1167,28 @@ void RageDisplay_D3D::SetTextureMode( TextureMode tm ) // Use D3DTA_CURRENT instead of diffuse so that multitexturing works // properly. For stage 0, D3DTA_CURRENT is the diffuse color. - 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 ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); break; case TextureMode_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_MODULATE ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_ADD ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); break; case TextureMode_Glow: - 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 ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); + g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); break; } } diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index 4808ee107c..71e4fa4fd8 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -36,7 +36,7 @@ public: void ClearAllTextures(); int GetNumTextureUnits(); void SetTexture( TextureUnit tu, unsigned iTexture ); - void SetTextureMode( TextureMode tm ); + void SetTextureMode( TextureUnit tu, TextureMode tm ); void SetTextureWrapping( bool b ); int GetMaxTextureSize() const; void SetTextureFiltering( bool b); diff --git a/stepmania/src/RageDisplay_Null.h b/stepmania/src/RageDisplay_Null.h index 4b11c21770..702ac792d1 100644 --- a/stepmania/src/RageDisplay_Null.h +++ b/stepmania/src/RageDisplay_Null.h @@ -33,7 +33,7 @@ public: void ClearAllTextures() { } int GetNumTextureUnits() { return 1; } void SetTexture( TextureUnit tu, unsigned iTexture ) { } - void SetTextureMode( TextureMode tm ) { } + void SetTextureMode( TextureUnit tu, TextureMode tm ) { } void SetTextureWrapping( bool b ) { } int GetMaxTextureSize() const { return 2048; } void SetTextureFiltering( bool b) { } diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index ffcf9f837e..cd46654f32 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -1358,6 +1358,18 @@ void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNu glDisable( GL_POINT_SMOOTH ); } +static bool SetTextureUnit( TextureUnit tu ) +{ + // If multitexture isn't supported, ignore all textures except for 0. + if( GLExt.glActiveTextureARB == NULL ) + return false; + + if( (int) tu > g_iMaxTextureUnits ) + return false; + GLExt.glActiveTextureARB( enum_add2(GL_TEXTURE0_ARB, tu) ); + return true; +} + void RageDisplay_OGL::ClearAllTextures() { FOREACH_ENUM( TextureUnit, i ) @@ -1379,26 +1391,8 @@ int RageDisplay_OGL::GetNumTextureUnits() void RageDisplay_OGL::SetTexture( TextureUnit tu, unsigned iTexture ) { - if( GLExt.glActiveTextureARB == NULL ) - { - // multitexture isn't supported. Ignore all textures except for 0. - if( tu != 0 ) - return; - } - else - { - switch( tu ) - { - case 0: - GLExt.glActiveTextureARB(GL_TEXTURE0_ARB); - break; - case 1: - GLExt.glActiveTextureARB(GL_TEXTURE1_ARB); - break; - default: - ASSERT(0); - } - } + if( !SetTextureUnit( tu ) ) + return; if( iTexture ) { @@ -1411,8 +1405,11 @@ void RageDisplay_OGL::SetTexture( TextureUnit tu, unsigned iTexture ) } } -void RageDisplay_OGL::SetTextureMode( TextureMode tm ) +void RageDisplay_OGL::SetTextureMode( TextureUnit tu, TextureMode tm ) { + if( !SetTextureUnit( tu ) ) + return; + switch( tm ) { case TextureMode_Modulate: diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index 9d17e9115f..d77c544567 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -43,7 +43,7 @@ public: void ClearAllTextures(); int GetNumTextureUnits(); void SetTexture( TextureUnit tu, unsigned iTexture ); - void SetTextureMode( TextureMode tm ); + void SetTextureMode( TextureUnit tu, TextureMode tm ); void SetTextureWrapping( bool b ); int GetMaxTextureSize() const; void SetTextureFiltering( bool b); diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index 775034e71e..6d0cf2ce5c 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -503,7 +503,7 @@ void Sprite::DrawTexture( const TweenState *state ) state->diffuse[2].a > 0 || state->diffuse[3].a > 0 ) { - DISPLAY->SetTextureMode( TextureMode_Modulate ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate ); ////////////////////// // render the shadow @@ -532,7 +532,7 @@ void Sprite::DrawTexture( const TweenState *state ) ////////////////////// if( state->glow.a > 0.0001f ) { - DISPLAY->SetTextureMode( TextureMode_Glow ); + DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow ); v[0].c = v[1].c = v[2].c = v[3].c = state->glow; DISPLAY->DrawQuad( v ); }