add front face culling

This commit is contained in:
Chris Danford
2004-02-04 11:05:33 +00:00
parent 9502f1c262
commit 3ca8601390
12 changed files with 58 additions and 20 deletions
+13 -3
View File
@@ -62,7 +62,7 @@ void Actor::Reset()
m_bClearZBuffer = false;
m_bZTest = false;
m_bZWrite = false;
m_bUseBackfaceCull = false;
m_CullMode = CULL_NONE;
}
Actor::Actor()
@@ -230,7 +230,7 @@ void Actor::SetRenderStates()
DISPLAY->SetZTest( m_bZTest );
if( m_bClearZBuffer )
DISPLAY->ClearZBuffer();
DISPLAY->SetBackfaceCull( m_bUseBackfaceCull );
DISPLAY->SetCullMode( m_CullMode );
}
void Actor::EndDraw()
@@ -823,7 +823,8 @@ void Actor::HandleCommand( const ParsedCommand &command )
else if( sName=="ztest" ) SetZTest( bParam(1) );
else if( sName=="zwrite" ) SetZWrite( bParam(1) );
else if( sName=="clearzbuffer" ) SetClearZBuffer( bParam(1) );
else if( sName=="backfacecull" ) SetUseBackfaceCull( bParam(1) );
else if( sName=="backfacecull" ) SetCullMode( bParam(1) ? CULL_BACK : CULL_NONE );
else if( sName=="cullmode" ) SetCullMode( sParam(1) );
else if( sName=="hidden" ) SetHidden( bParam(1) );
else if( sName=="hibernate" ) SetHibernate( fParam(1) );
else if( sName=="playcommand" ) PlayCommand( sParam(1) );
@@ -957,6 +958,15 @@ void Actor::SetBlendMode( CString s )
else ASSERT(0);
}
void Actor::SetCullMode( CString s )
{
s.MakeLower();
if (s=="back") SetCullMode( CULL_BACK );
else if(s=="front") SetCullMode( CULL_FRONT );
else if(s=="none") SetCullMode( CULL_NONE );
else ASSERT(0);
}
void Actor::CopyTweening( const Actor &from )
{
m_current = from.m_current;
+3 -2
View File
@@ -287,7 +287,8 @@ public:
virtual void SetUseZBuffer( bool b ) { SetZTest(b); SetZWrite(b); }
virtual void SetZTest( bool b ) { m_bZTest = b; }
virtual void SetZWrite( bool b ) { m_bZWrite = b; }
virtual void SetUseBackfaceCull( bool b ) { m_bUseBackfaceCull = b; }
virtual void SetCullMode( CullMode mode ) { m_CullMode = mode; }
virtual void SetCullMode( CString );
//
// fade command
@@ -381,7 +382,7 @@ protected:
BlendMode m_BlendMode;
bool m_bClearZBuffer;
bool m_bZTest, m_bZWrite;
bool m_bUseBackfaceCull;
CullMode m_CullMode;
};
#endif
+2 -1
View File
@@ -151,7 +151,8 @@ void ActorFrame::DeleteAllChildren()
void ActorFrame::HandleCommand( const ParsedCommand &command )
{
Actor::HandleCommand( command );
// don't propograte to children
// don't propograte most commands to children
}
void ActorFrame::GainingFocus( float fRate, bool bRewindMovie, bool bLoop )
+3 -3
View File
@@ -495,7 +495,7 @@ void NoteDisplay::DrawHoldTopCap( const HoldNote& hn, const bool bIsBeingHeld, f
DISPLAY->ClearAllTextures();
DISPLAY->SetTexture( 0, pTexture );
DISPLAY->SetBlendMode( BLEND_NORMAL );
DISPLAY->SetBackfaceCull( false );
DISPLAY->SetCullMode( CULL_NONE );
DISPLAY->SetTextureWrapping(false);
const float fFrameWidth = pSprTopCap->GetUnzoomedWidth();
@@ -567,7 +567,7 @@ void NoteDisplay::DrawHoldBody( const HoldNote& hn, const bool bIsBeingHeld, flo
DISPLAY->ClearAllTextures();
DISPLAY->SetTexture( 0, pTexture );
DISPLAY->SetBlendMode( BLEND_NORMAL );
DISPLAY->SetBackfaceCull( false );
DISPLAY->SetCullMode( CULL_NONE );
DISPLAY->SetTextureWrapping( true );
@@ -670,7 +670,7 @@ void NoteDisplay::DrawHoldBottomCap( const HoldNote& hn, const bool bIsBeingHeld
DISPLAY->ClearAllTextures();
DISPLAY->SetTexture( 0, pTexture );
DISPLAY->SetBlendMode( BLEND_NORMAL );
DISPLAY->SetBackfaceCull( false );
DISPLAY->SetCullMode( CULL_NONE );
DISPLAY->SetTextureWrapping(false);
const float fFrameWidth = pBottomCap->GetUnzoomedWidth();
+1 -1
View File
@@ -205,7 +205,7 @@ void RageDisplay::DrawCircle( const RageSpriteVertex &p, float radius )
void RageDisplay::SetDefaultRenderStates()
{
SetLighting( false );
SetBackfaceCull( false );
SetCullMode( CULL_NONE );
SetZBuffer( false );
SetAlphaTest( true );
SetBlendMode( BLEND_NORMAL );
+1 -1
View File
@@ -177,7 +177,7 @@ public:
virtual void ClearZBuffer() = 0;
void SetZBuffer( bool b ) { SetZWrite(b); SetZTest(b); } // shortcut
virtual void SetBackfaceCull( bool b ) = 0;
virtual void SetCullMode( CullMode mode ) = 0;
virtual void SetAlphaTest( bool b ) = 0;
+15 -2
View File
@@ -1049,9 +1049,22 @@ void RageDisplay_D3D::SetLightDirectional(
g_pd3dDevice->SetLight( index, &light );
}
void RageDisplay_D3D::SetBackfaceCull( bool b )
void RageDisplay_D3D::SetCullMode( CullMode mode )
{
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, b ? D3DCULL_CW : D3DCULL_NONE );
switch( mode )
{
case CULL_BACK:
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
break;
case CULL_FRONT:
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
break;
case CULL_NONE:
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
break;
default:
ASSERT(0);
}
}
void RageDisplay_D3D::DeleteTexture( unsigned uTexHandle )
+1 -1
View File
@@ -55,7 +55,7 @@ public:
void SetZWrite( bool b );
void SetZTest( bool b );
void ClearZBuffer();
void SetBackfaceCull( bool b );
void SetCullMode( CullMode mode );
void SetAlphaTest( bool b );
void SetMaterial(
const RageColor &emissive,
+15 -3
View File
@@ -1218,12 +1218,24 @@ void RageDisplay_OGL::SetLightDirectional(
glPopMatrix();
}
void RageDisplay_OGL::SetBackfaceCull( bool b )
void RageDisplay_OGL::SetCullMode( CullMode mode )
{
if( b )
switch( mode )
{
case CULL_BACK:
glEnable( GL_CULL_FACE );
else
glCullFace( GL_BACK );
break;
case CULL_FRONT:
glEnable( GL_CULL_FACE );
glCullFace( GL_FRONT );
break;
case CULL_NONE:
glDisable( GL_CULL_FACE );
break;
default:
ASSERT(0);
}
}
const RageDisplay::PixelFormatDesc *RageDisplay_OGL::GetPixelFormatDesc(PixelFormat pf) const
+1 -1
View File
@@ -41,7 +41,7 @@ public:
void SetZWrite( bool b );
void SetZTest( bool b );
void ClearZBuffer();
void SetBackfaceCull( bool b );
void SetCullMode( CullMode mode );
void SetAlphaTest( bool b );
void SetMaterial(
const RageColor &emissive,
+1
View File
@@ -17,6 +17,7 @@
* put this here. */
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 };
struct RageVector2
+2 -2
View File
@@ -173,7 +173,7 @@ ScreenSelectMusic::ScreenSelectMusic( CString sClassName ) : Screen( sClassName
m_sprCDTitleFront.SetName( "CDTitle" );
m_sprCDTitleFront.Load( THEME->GetPathToG("ScreenSelectMusic fallback cdtitle") );
m_sprCDTitleFront.SetUseBackfaceCull(true);
m_sprCDTitleFront.SetCullMode( CULL_BACK );
m_sprCDTitleFront.SetDiffuse( RageColor(1,1,1,1) );
m_sprCDTitleFront.SetEffectSpin( RageVector3(0, 360/CDTITLE_SPIN_SECONDS, 0) );
SET_XY( m_sprCDTitleFront );
@@ -182,7 +182,7 @@ ScreenSelectMusic::ScreenSelectMusic( CString sClassName ) : Screen( sClassName
m_sprCDTitleBack.SetName( "CDTitle" );
m_sprCDTitleBack.Load( THEME->GetPathToG("ScreenSelectMusic fallback cdtitle") );
FlipSpriteHorizontally(m_sprCDTitleBack);
m_sprCDTitleBack.SetUseBackfaceCull(true);
m_sprCDTitleBack.SetCullMode( CULL_BACK );
m_sprCDTitleBack.SetDiffuse( RageColor(0.2f,0.2f,0.2f,1) );
m_sprCDTitleBack.SetRotationY( 180 );
m_sprCDTitleBack.SetEffectSpin( RageVector3(0, 360/CDTITLE_SPIN_SECONDS, 0) );