fix Model doesn't obey m_bTextureWrapping

This commit is contained in:
Chris Danford
2005-02-27 08:31:41 +00:00
parent 8c31d9cdd9
commit 4a2499b0fb
6 changed files with 26 additions and 9 deletions
+6 -2
View File
@@ -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 // set Actor-defined render states
DISPLAY->SetTextureWrapping( m_bTextureWrapping );
DISPLAY->SetBlendMode( m_BlendMode ); DISPLAY->SetBlendMode( m_BlendMode );
DISPLAY->SetZWrite( m_bZWrite ); DISPLAY->SetZWrite( m_bZWrite );
DISPLAY->SetZTestMode( m_ZTestMode ); DISPLAY->SetZTestMode( m_ZTestMode );
@@ -332,6 +331,11 @@ void Actor::SetRenderStates()
DISPLAY->SetCullMode( m_CullMode ); DISPLAY->SetCullMode( m_CullMode );
} }
void Actor::SetTextureRenderStates()
{
DISPLAY->SetTextureWrapping( m_bTextureWrapping );
}
void Actor::EndDraw() void Actor::EndDraw()
{ {
DISPLAY->PopMatrix(); DISPLAY->PopMatrix();
+2 -1
View File
@@ -71,7 +71,8 @@ public:
void Draw(); // calls, NeedsDraw, BeginDraw, DrawPrimitives, EndDraw void Draw(); // calls, NeedsDraw, BeginDraw, DrawPrimitives, EndDraw
virtual bool EarlyAbortDraw() { return false; } // return true to early abort drawing of this Actor 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 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 DrawPrimitives() {}; // Derivitives should override
virtual void EndDraw(); // pops transform from world matrix stack virtual void EndDraw(); // pops transform from world matrix stack
+3 -1
View File
@@ -328,6 +328,8 @@ void BitmapText::DrawChars()
end++; end++;
DISPLAY->ClearAllTextures(); DISPLAY->ClearAllTextures();
DISPLAY->SetTexture( 0, tex[start] ); 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]; RageSpriteVertex &start_vertex = verts[start*4];
int iNumVertsToDraw = (end-start)*4; int iNumVertsToDraw = (end-start)*4;
DISPLAY->DrawQuads( &start_vertex, iNumVertsToDraw ); 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 // draw text at x, y using colorTop blended down to colorBottom, with size multiplied by scale
void BitmapText::DrawPrimitives() void BitmapText::DrawPrimitives()
{ {
Actor::SetRenderStates(); // set Actor-specified render states Actor::SetGlobalRenderStates(); // set Actor-specified render states
DISPLAY->SetTextureModeModulate(); DISPLAY->SetTextureModeModulate();
/* Draw if we're not fully transparent or the zbuffer is enabled */ /* Draw if we're not fully transparent or the zbuffer is enabled */
+4 -1
View File
@@ -123,9 +123,12 @@ void GraphDisplay::Update( float fDeltaTime )
void GraphDisplay::DrawPrimitives() void GraphDisplay::DrawPrimitives()
{ {
Actor::SetGlobalRenderStates(); // set Actor-specified render states
DISPLAY->ClearAllTextures(); DISPLAY->ClearAllTextures();
DISPLAY->SetTexture( 0, m_pTexture ); 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->DrawQuads( Slices, ARRAYSIZE(Slices) );
DISPLAY->SetTexture( 0, NULL ); DISPLAY->SetTexture( 0, NULL );
+8 -3
View File
@@ -317,12 +317,12 @@ void Model::DrawCelShaded()
void Model::DrawPrimitives() void Model::DrawPrimitives()
{ {
Actor::SetGlobalRenderStates(); // set Actor-specified render states
/* Don't if we're fully transparent */ /* Don't if we're fully transparent */
if( m_pTempState->diffuse[0].a < 0.001f && m_pTempState->glow.a < 0.001f ) if( m_pTempState->diffuse[0].a < 0.001f && m_pTempState->glow.a < 0.001f )
return; return;
Actor::SetRenderStates(); // set Actor-specified render states
DISPLAY->Scale( 1, -1, 1 ); // flip Y so positive is up DISPLAY->Scale( 1, -1, 1 ); // flip Y so positive is up
////////////////////// //////////////////////
@@ -359,7 +359,6 @@ void Model::DrawPrimitives()
fScrollX += mat.diffuse.m_fTexOffsetX; fScrollX += mat.diffuse.m_fTexOffsetX;
float fScrollY = mat.diffuse.m_fTexVelocityY * mat.diffuse.GetSecondsIntoAnimation() / mat.diffuse.GetAnimationLengthSeconds(); float fScrollY = mat.diffuse.m_fTexVelocityY * mat.diffuse.GetSecondsIntoAnimation() / mat.diffuse.GetAnimationLengthSeconds();
fScrollY += mat.diffuse.m_fTexOffsetY; fScrollY += mat.diffuse.m_fTexOffsetY;
DISPLAY->SetTextureWrapping( true );
DISPLAY->TextureTranslate( fScrollX, fScrollY, 0 ); DISPLAY->TextureTranslate( fScrollX, fScrollY, 0 );
} }
@@ -369,6 +368,7 @@ void Model::DrawPrimitives()
{ {
// render the diffuse texture // render the diffuse texture
DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() );
Actor::SetTextureRenderStates(); // set Actor-specified render states
DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped );
DrawMesh( i ); DrawMesh( i );
@@ -376,6 +376,8 @@ void Model::DrawPrimitives()
if( mat.alpha.GetCurrentTexture() ) if( mat.alpha.GetCurrentTexture() )
{ {
DISPLAY->SetTexture( 0, mat.alpha.GetCurrentTexture() ); DISPLAY->SetTexture( 0, mat.alpha.GetCurrentTexture() );
Actor::SetTextureRenderStates(); // set Actor-specified render states
DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped );
// UGLY: This overrides the Actor's BlendMode // UGLY: This overrides the Actor's BlendMode
DISPLAY->SetBlendMode( BLEND_ADD ); DISPLAY->SetBlendMode( BLEND_ADD );
@@ -387,12 +389,14 @@ void Model::DrawPrimitives()
{ {
// render the diffuse texture with texture unit 1 // render the diffuse texture with texture unit 1
DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() );
Actor::SetTextureRenderStates(); // set Actor-specified render states
DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped ); DISPLAY->SetSphereEnvironmentMapping( mat.diffuse.m_bSphereMapped );
// render the additive texture with texture unit 2 // render the additive texture with texture unit 2
if( mat.alpha.GetCurrentTexture() ) if( mat.alpha.GetCurrentTexture() )
{ {
DISPLAY->SetTexture( 1, mat.alpha.GetCurrentTexture() ); DISPLAY->SetTexture( 1, mat.alpha.GetCurrentTexture() );
Actor::SetTextureRenderStates(); // set Actor-specified render states
DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped ); DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped );
DISPLAY->SetTextureModeAdd(); DISPLAY->SetTextureModeAdd();
DISPLAY->SetTextureFiltering( true ); DISPLAY->SetTextureFiltering( true );
@@ -450,6 +454,7 @@ void Model::DrawPrimitives()
{ {
msMaterial& mat = m_Materials[ pMesh->nMaterialIndex ]; msMaterial& mat = m_Materials[ pMesh->nMaterialIndex ];
DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() );
Actor::SetTextureRenderStates(); // set Actor-specified render states
} }
else else
{ {
+3 -1
View File
@@ -400,6 +400,8 @@ void TexCoordArrayFromRect(float fImageCoords[8], const RectF &rect)
void Sprite::DrawTexture( const TweenState *state ) void Sprite::DrawTexture( const TweenState *state )
{ {
Actor::SetGlobalRenderStates(); // set Actor-specified render states
// bail if cropped all the way // bail if cropped all the way
if( state->crop.left + state->crop.right >= 1 || if( state->crop.left + state->crop.right >= 1 ||
state->crop.top + state->crop.bottom >= 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 // Must call this after setting the texture or else texture
// parameters have no effect. // parameters have no effect.
Actor::SetRenderStates(); // set Actor-specified render states Actor::SetTextureRenderStates(); // set Actor-specified render states
if( m_pTexture ) if( m_pTexture )
{ {