diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index a75c08535b..45065ccfbb 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -320,10 +320,9 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties } } -void Actor::SetRenderStates() +void Actor::SetGlobalRenderStates() { // set Actor-defined render states - DISPLAY->SetTextureWrapping( m_bTextureWrapping ); DISPLAY->SetBlendMode( m_BlendMode ); DISPLAY->SetZWrite( m_bZWrite ); DISPLAY->SetZTestMode( m_ZTestMode ); @@ -332,6 +331,11 @@ void Actor::SetRenderStates() DISPLAY->SetCullMode( m_CullMode ); } +void Actor::SetTextureRenderStates() +{ + DISPLAY->SetTextureWrapping( m_bTextureWrapping ); +} + void Actor::EndDraw() { DISPLAY->PopMatrix(); diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index ad306eba36..dae02c90b2 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -71,7 +71,8 @@ public: void Draw(); // calls, NeedsDraw, BeginDraw, DrawPrimitives, EndDraw virtual bool EarlyAbortDraw() { return false; } // return true to early abort drawing of this Actor virtual void BeginDraw(); // pushes transform onto world matrix stack - virtual void SetRenderStates(); // Actor should call at beginning of their DrawPrimitives() after setting textures + virtual void SetGlobalRenderStates(); // Actor should call this at beginning of their DrawPrimitives() + virtual void SetTextureRenderStates(); // Actor should call this after setting a texture virtual void DrawPrimitives() {}; // Derivitives should override virtual void EndDraw(); // pops transform from world matrix stack diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index dfded2b6b2..68f27c70b1 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -328,6 +328,8 @@ void BitmapText::DrawChars() end++; DISPLAY->ClearAllTextures(); DISPLAY->SetTexture( 0, tex[start] ); + // don't bother setting texture render states for text. We never go outside of 0..1. + //Actor::SetTextureRenderStates(); RageSpriteVertex &start_vertex = verts[start*4]; int iNumVertsToDraw = (end-start)*4; DISPLAY->DrawQuads( &start_vertex, iNumVertsToDraw ); @@ -487,7 +489,7 @@ bool BitmapText::EarlyAbortDraw() // draw text at x, y using colorTop blended down to colorBottom, with size multiplied by scale void BitmapText::DrawPrimitives() { - Actor::SetRenderStates(); // set Actor-specified render states + Actor::SetGlobalRenderStates(); // set Actor-specified render states DISPLAY->SetTextureModeModulate(); /* Draw if we're not fully transparent or the zbuffer is enabled */ diff --git a/stepmania/src/GraphDisplay.cpp b/stepmania/src/GraphDisplay.cpp index 971898b397..2222db9e18 100644 --- a/stepmania/src/GraphDisplay.cpp +++ b/stepmania/src/GraphDisplay.cpp @@ -123,9 +123,12 @@ void GraphDisplay::Update( float fDeltaTime ) void GraphDisplay::DrawPrimitives() { + Actor::SetGlobalRenderStates(); // set Actor-specified render states + DISPLAY->ClearAllTextures(); DISPLAY->SetTexture( 0, m_pTexture ); - Actor::SetRenderStates(); // set Actor-specified render states + // don't bother setting texture render states for a null texture + //Actor::SetTextureRenderStates(); DISPLAY->DrawQuads( Slices, ARRAYSIZE(Slices) ); DISPLAY->SetTexture( 0, NULL ); diff --git a/stepmania/src/Model.cpp b/stepmania/src/Model.cpp index a2649afb1a..530fb4717e 100644 --- a/stepmania/src/Model.cpp +++ b/stepmania/src/Model.cpp @@ -317,12 +317,12 @@ void Model::DrawCelShaded() void Model::DrawPrimitives() { + Actor::SetGlobalRenderStates(); // set Actor-specified render states + /* Don't if we're fully transparent */ if( m_pTempState->diffuse[0].a < 0.001f && m_pTempState->glow.a < 0.001f ) return; - Actor::SetRenderStates(); // set Actor-specified render states - DISPLAY->Scale( 1, -1, 1 ); // flip Y so positive is up ////////////////////// @@ -359,7 +359,6 @@ void Model::DrawPrimitives() fScrollX += mat.diffuse.m_fTexOffsetX; float fScrollY = mat.diffuse.m_fTexVelocityY * mat.diffuse.GetSecondsIntoAnimation() / mat.diffuse.GetAnimationLengthSeconds(); fScrollY += mat.diffuse.m_fTexOffsetY; - DISPLAY->SetTextureWrapping( true ); DISPLAY->TextureTranslate( fScrollX, fScrollY, 0 ); } @@ -369,6 +368,7 @@ void Model::DrawPrimitives() { // render the diffuse texture DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); + Actor::SetTextureRenderStates(); // set Actor-specified render states DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); DrawMesh( i ); @@ -376,6 +376,8 @@ void Model::DrawPrimitives() if( mat.alpha.GetCurrentTexture() ) { DISPLAY->SetTexture( 0, mat.alpha.GetCurrentTexture() ); + Actor::SetTextureRenderStates(); // set Actor-specified render states + DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); // UGLY: This overrides the Actor's BlendMode DISPLAY->SetBlendMode( BLEND_ADD ); @@ -387,12 +389,14 @@ void Model::DrawPrimitives() { // render the diffuse texture with texture unit 1 DISPLAY->SetTexture( 0, 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() ); + Actor::SetTextureRenderStates(); // set Actor-specified render states DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); DISPLAY->SetTextureModeAdd(); DISPLAY->SetTextureFiltering( true ); @@ -450,6 +454,7 @@ void Model::DrawPrimitives() { msMaterial& mat = m_Materials[ pMesh->nMaterialIndex ]; DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); + Actor::SetTextureRenderStates(); // set Actor-specified render states } else { diff --git a/stepmania/src/Sprite.cpp b/stepmania/src/Sprite.cpp index e26d03514e..f5eac75e27 100644 --- a/stepmania/src/Sprite.cpp +++ b/stepmania/src/Sprite.cpp @@ -400,6 +400,8 @@ void TexCoordArrayFromRect(float fImageCoords[8], const RectF &rect) void Sprite::DrawTexture( const TweenState *state ) { + Actor::SetGlobalRenderStates(); // set Actor-specified render states + // bail if cropped all the way if( state->crop.left + state->crop.right >= 1 || state->crop.top + state->crop.bottom >= 1 ) @@ -456,7 +458,7 @@ void Sprite::DrawTexture( const TweenState *state ) // Must call this after setting the texture or else texture // parameters have no effect. - Actor::SetRenderStates(); // set Actor-specified render states + Actor::SetTextureRenderStates(); // set Actor-specified render states if( m_pTexture ) {