diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index 60043019f9..6a38ac93d0 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -359,14 +359,14 @@ void Model::DrawPrimitives() // render the diffuse texture with texture unit 1 DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ? mat.diffuse.GetCurrentTexture()->GetTexHandle() : 0 ); Actor::SetTextureRenderStates(); // set Actor-specified render states - DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); + DISPLAY->SetSphereEnvironmentMapping( TextureUnit_1, mat.diffuse.m_bSphereMapped ); // render the additive texture with texture unit 2 if( mat.alpha.GetCurrentTexture() ) { 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->SetSphereEnvironmentMapping( TextureUnit_2, mat.alpha.m_bSphereMapped ); DISPLAY->SetTextureMode( TextureUnit_2, TextureMode_Add ); DISPLAY->SetTextureFiltering( TextureUnit_2, true ); } @@ -382,16 +382,15 @@ void Model::DrawPrimitives() /* go */ DrawMesh( i ); - // Turn off Environment mapping on tex unit 0. Is there a better way to reset? - DISPLAY->SetTexture( TextureUnit_1, 0 ); - DISPLAY->SetSphereEnvironmentMapping( 0 ); + // Turn off environment mapping on tex unit 0. + DISPLAY->SetSphereEnvironmentMapping( TextureUnit_1, 0 ); } else { // render the diffuse texture DISPLAY->SetTexture( TextureUnit_1, mat.diffuse.GetCurrentTexture() ? mat.diffuse.GetCurrentTexture()->GetTexHandle() : 0 ); Actor::SetTextureRenderStates(); // set Actor-specified render states - DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); + DISPLAY->SetSphereEnvironmentMapping( TextureUnit_1, mat.diffuse.m_bSphereMapped ); DrawMesh( i ); // render the additive texture @@ -400,7 +399,7 @@ void Model::DrawPrimitives() DISPLAY->SetTexture( TextureUnit_1, mat.alpha.GetCurrentTexture() ? mat.alpha.GetCurrentTexture()->GetTexHandle() : 0 ); Actor::SetTextureRenderStates(); // set Actor-specified render states - DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); + DISPLAY->SetSphereEnvironmentMapping( TextureUnit_1, mat.alpha.m_bSphereMapped ); // UGLY: This overrides the Actor's BlendMode DISPLAY->SetBlendMode( BLEND_ADD ); DISPLAY->SetTextureFiltering( TextureUnit_1, true ); @@ -420,11 +419,11 @@ void Model::DrawPrimitives() static const float shininess = 1; DISPLAY->SetMaterial( emissive, ambient, diffuse, specular, shininess ); DISPLAY->ClearAllTextures(); - DISPLAY->SetSphereEnvironmentMapping( false ); + DISPLAY->SetSphereEnvironmentMapping( TextureUnit_1, false ); DrawMesh( i ); } - DISPLAY->SetSphereEnvironmentMapping( false ); + DISPLAY->SetSphereEnvironmentMapping( TextureUnit_1, false ); DISPLAY->SetBlendMode( BLEND_NORMAL ); } } diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 547664621f..b094af90a1 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -255,7 +255,7 @@ public: const RageColor &specular, const RageVector3 &dir ) = 0; - virtual void SetSphereEnvironmentMapping( bool b ) = 0; + virtual void SetSphereEnvironmentMapping( TextureUnit tu, bool b ) = 0; virtual RageCompiledGeometry* CreateCompiledGeometry() = 0; virtual void DeleteCompiledGeometry( RageCompiledGeometry* p ) = 0; diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 3aff4451d5..b2f49e5563 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -1527,9 +1527,9 @@ RageMatrix RageDisplay_D3D::GetOrthoMatrix( float l, float r, float b, float t, return m; } -void RageDisplay_D3D::SetSphereEnvironmentMapping( bool b ) +void RageDisplay_D3D::SetSphereEnvironmentMapping( TextureUnit tu, bool b ) { - g_bSphereMapping[g_currentTextureUnit] = b; + g_bSphereMapping[tu] = b; } /* diff --git a/stepmania/src/RageDisplay_D3D.h b/stepmania/src/RageDisplay_D3D.h index 16956a0cb4..7012d7494e 100644 --- a/stepmania/src/RageDisplay_D3D.h +++ b/stepmania/src/RageDisplay_D3D.h @@ -64,7 +64,7 @@ public: const RageColor &specular, const RageVector3 &dir ); - void SetSphereEnvironmentMapping( bool b ); + void SetSphereEnvironmentMapping( TextureUnit tu, bool b ); RageCompiledGeometry* CreateCompiledGeometry(); void DeleteCompiledGeometry( RageCompiledGeometry* p ); diff --git a/stepmania/src/RageDisplay_Null.h b/stepmania/src/RageDisplay_Null.h index 62ed1d9d17..267d910a7d 100644 --- a/stepmania/src/RageDisplay_Null.h +++ b/stepmania/src/RageDisplay_Null.h @@ -61,7 +61,7 @@ public: const RageColor &specular, const RageVector3 &dir ) { } - void SetSphereEnvironmentMapping( bool b ) { } + void SetSphereEnvironmentMapping( TextureUnit tu, bool b ) { } RageCompiledGeometry* CreateCompiledGeometry(); void DeleteCompiledGeometry( RageCompiledGeometry* p ); diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 07b2529d9e..14fd7ddcb1 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -2222,8 +2222,11 @@ bool RageDisplay_OGL::SupportsPerVertexMatrixScale() return GLExt.glGenBuffersARB && g_bTextureMatrixShader != 0; } -void RageDisplay_OGL::SetSphereEnvironmentMapping( bool b ) +void RageDisplay_OGL::SetSphereEnvironmentMapping( TextureUnit tu, bool b ) { + if( !SetTextureUnit( tu ) ) + return; + if( b ) { glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP ); diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index 61c438b282..138619b52e 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -74,7 +74,7 @@ public: const RageColor &specular, const RageVector3 &dir ); - void SetSphereEnvironmentMapping( bool b ); + void SetSphereEnvironmentMapping( TextureUnit tu, bool b ); RageCompiledGeometry* CreateCompiledGeometry(); void DeleteCompiledGeometry( RageCompiledGeometry* p );