add "draw on z fail" mode

This commit is contained in:
Chris Danford
2004-05-15 09:26:21 +00:00
parent 0a59a81d66
commit 9ec4c6be91
11 changed files with 50 additions and 18 deletions
+17 -2
View File
@@ -59,7 +59,7 @@ void Actor::Reset()
m_bTextureWrapping = false;
m_BlendMode = BLEND_NORMAL;
m_bClearZBuffer = false;
m_bZTest = false;
m_ZTestMode = ZTEST_OFF;
m_bZWrite = false;
m_CullMode = CULL_NONE;
}
@@ -228,7 +228,7 @@ void Actor::SetRenderStates()
DISPLAY->SetTextureWrapping( m_bTextureWrapping );
DISPLAY->SetBlendMode( m_BlendMode );
DISPLAY->SetZWrite( m_bZWrite );
DISPLAY->SetZTest( m_bZTest );
DISPLAY->SetZTestMode( m_ZTestMode );
if( m_bClearZBuffer )
DISPLAY->ClearZBuffer();
DISPLAY->SetCullMode( m_CullMode );
@@ -730,6 +730,7 @@ void Actor::HandleCommand( const ParsedCommand &command )
else if( sName=="blend" ) SetBlendMode( sParam(1) );
else if( sName=="zbuffer" ) SetUseZBuffer( bParam(1) );
else if( sName=="ztest" ) SetZTest( bParam(1) );
else if( sName=="ztestmode" ) SetZTestMode( sParam(1) );
else if( sName=="zwrite" ) SetZWrite( bParam(1) );
else if( sName=="clearzbuffer" ) SetClearZBuffer( bParam(1) );
else if( sName=="backfacecull" ) SetCullMode( bParam(1) ? CULL_BACK : CULL_NONE );
@@ -884,6 +885,20 @@ void Actor::SetCullMode( CString s )
else ASSERT(0);
}
void Actor::SetZTestMode( CString s )
{
s.MakeLower();
// for metrics backward compatibility
if (s=="1") SetZTestMode( ZTEST_WRITE_ON_PASS );
else if(s=="0") SetZTestMode( ZTEST_OFF );
else if(s=="off") SetZTestMode( ZTEST_OFF );
else if(s=="writeonpass") SetZTestMode( ZTEST_WRITE_ON_PASS );
else if(s=="writeonfail") SetZTestMode( ZTEST_WRITE_ON_FAIL );
else ASSERT(0);
}
void Actor::CopyTweening( const Actor &from )
{
m_current = from.m_current;
+8 -5
View File
@@ -297,8 +297,10 @@ public:
void SetBlendMode( CString );
void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; }
void SetClearZBuffer( bool b ) { m_bClearZBuffer = b; }
void SetUseZBuffer( bool b ) { SetZTest(b); SetZWrite(b); }
virtual void SetZTest( bool b ) { m_bZTest = b; }
void SetUseZBuffer( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); SetZWrite(b); }
virtual void SetZTestMode( ZTestMode mode ) { m_ZTestMode = mode; }
virtual void SetZTestMode( CString );
void SetZTest( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); }
virtual void SetZWrite( bool b ) { m_bZWrite = b; }
virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; }
virtual void SetCullMode( CString );
@@ -387,10 +389,11 @@ protected:
//
// render states
//
bool m_bTextureWrapping;
bool m_bTextureWrapping;
BlendMode m_BlendMode;
bool m_bClearZBuffer;
bool m_bZTest, m_bZWrite;
bool m_bClearZBuffer;
ZTestMode m_ZTestMode;
bool m_bZWrite;
CullMode m_CullMode;
};
+1 -1
View File
@@ -103,7 +103,7 @@ void ActorFrame::Update( float fDeltaTime )
}
PropagateActorFrameCommand( SetDiffuse, RageColor )
PropagateActorFrameCommand( SetZTest, bool )
PropagateActorFrameCommand( SetZTestMode, ZTestMode )
PropagateActorFrameCommand( SetZWrite, bool )
PropagateActorFrameCommand( HurryTweening, float )
+1 -1
View File
@@ -35,7 +35,7 @@ public:
virtual void SetDiffuse( RageColor c );
virtual void SetDiffuseAlpha( float f );
virtual void SetZTest( bool b );
virtual void SetZTestMode( ZTestMode mode );
virtual void SetZWrite( bool b );
virtual void FinishTweening();
virtual void HurryTweening( float factor );
+2 -1
View File
@@ -195,7 +195,8 @@ public:
virtual bool IsZTestEnabled() const = 0;
virtual bool IsZWriteEnabled() const = 0;
virtual void SetZWrite( bool b ) = 0;
virtual void SetZTest( bool b ) = 0;
void SetZTest( bool b ) { SetZTestMode(b?ZTEST_WRITE_ON_PASS:ZTEST_OFF); }
virtual void SetZTestMode( ZTestMode mode ) = 0;
virtual void ClearZBuffer() = 0;
void SetZBuffer( bool b ) { SetZWrite(b); SetZTest(b); } // shortcut
+9 -2
View File
@@ -1045,10 +1045,17 @@ void RageDisplay_D3D::SetZWrite( bool b )
g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, b );
}
void RageDisplay_D3D::SetZTest( bool b )
void RageDisplay_D3D::SetZTestMode( ZTestMode mode )
{
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
g_pd3dDevice->SetRenderState( D3DRS_ZFUNC, b ? D3DCMP_LESSEQUAL : D3DCMP_ALWAYS );
DWORD dw;
switch( mode )
{
case ZTEST_OFF: dw = D3DCMP_ALWAYS; break;
case ZTEST_WRITE_ON_PASS: dw = D3DCMP_LESSEQUAL; break;
case ZTEST_WRITE_ON_FAIL: dw = D3DCMP_GREATER; break;
default: ASSERT( 0 );
}
}
void RageDisplay_D3D::ClearZBuffer()
+1
View File
@@ -54,6 +54,7 @@ public:
bool IsZTestEnabled() const;
void SetZWrite( bool b );
void SetZTest( bool b );
void SetZTestMode( ZTestMode mode );
void ClearZBuffer();
void SetCullMode( CullMode mode );
void SetAlphaTest( bool b );
+1 -1
View File
@@ -41,7 +41,7 @@ public:
bool IsZWriteEnabled() const { return false; }
bool IsZTestEnabled() const { return false; }
void SetZWrite( bool b ) { }
void SetZTest( bool b ) { }
void SetZTestMode( ZTestMode mode ) { }
void ClearZBuffer() { }
void SetCullMode( CullMode mode ) { }
void SetAlphaTest( bool b ) { }
+8 -5
View File
@@ -1480,13 +1480,16 @@ void RageDisplay_OGL::SetZWrite( bool b )
glDepthMask( b );
}
void RageDisplay_OGL::SetZTest( bool b )
void RageDisplay_OGL::SetZTestMode( ZTestMode mode )
{
glEnable( GL_DEPTH_TEST );
if( b )
glDepthFunc( GL_LEQUAL );
else
glDepthFunc( GL_ALWAYS );
switch( mode )
{
case ZTEST_OFF: glDepthFunc( GL_ALWAYS ); break;
case ZTEST_WRITE_ON_PASS: glDepthFunc( GL_LEQUAL ); break;
case ZTEST_WRITE_ON_FAIL: glDepthFunc( GL_GREATER ); break;
default: ASSERT( 0 );
}
}
void RageDisplay_OGL::SetTextureWrapping( bool b )
+1
View File
@@ -43,6 +43,7 @@ public:
bool IsZTestEnabled() const;
void SetZWrite( bool b );
void SetZTest( bool b );
void SetZTestMode( ZTestMode mode );
void ClearZBuffer();
void SetCullMode( CullMode mode );
void SetAlphaTest( bool b );
+1
View File
@@ -8,6 +8,7 @@
enum GlowMode { GLOW_BRIGHTEN, GLOW_WHITEN };
enum BlendMode { BLEND_NORMAL, BLEND_ADD, BLEND_NO_EFFECT, BLEND_INVALID };
enum CullMode { CULL_BACK, CULL_FRONT, CULL_NONE };
enum ZTestMode { ZTEST_OFF, ZTEST_WRITE_ON_PASS, ZTEST_WRITE_ON_FAIL };
struct RageVector2