separate Z-write and Z-test flags

This commit is contained in:
Glenn Maynard
2003-11-18 20:33:18 +00:00
parent 18ec02efab
commit e21f149d3b
10 changed files with 81 additions and 28 deletions
+6 -2
View File
@@ -54,7 +54,8 @@ void Actor::Reset()
m_bTextureWrapping = false;
m_BlendMode = BLEND_NORMAL;
m_bClearZBuffer = false;
m_bUseZBuffer = false;
m_bZTest = false;
m_bZWrite = false;
m_bUseBackfaceCull = false;
}
@@ -204,7 +205,8 @@ void Actor::SetRenderStates()
// set Actor-defined render states
DISPLAY->SetTextureWrapping( m_bTextureWrapping );
DISPLAY->SetBlendMode( m_BlendMode );
DISPLAY->SetZBuffer( m_bUseZBuffer );
DISPLAY->SetZWrite( m_bZWrite );
DISPLAY->SetZTest( m_bZTest );
if( m_bClearZBuffer )
DISPLAY->ClearZBuffer();
DISPLAY->SetBackfaceCull( m_bUseBackfaceCull );
@@ -821,6 +823,8 @@ void Actor::HandleCommand( const CStringArray &asTokens )
else if( sName=="additiveblend" ) SetBlendMode( bParam(1) ? BLEND_ADD : BLEND_NORMAL );
else if( sName=="blend" ) SetBlendMode( sParam(1) );
else if( sName=="zbuffer" ) SetUseZBuffer( bParam(1) );
else if( sName=="ztest" ) SetZTest( bParam(1) );
else if( sName=="zwrite" ) SetZWrite( bParam(1) );
else if( sName=="clearzbuffer" ) SetClearZBuffer( bParam(1) );
else if( sName=="hidden" ) SetHidden( bParam(1) );
else if( sName=="playcommand" ) sParam(1); /* nop: only BGAnimation handles this but everyone receives it */
+4 -2
View File
@@ -272,7 +272,9 @@ public:
virtual void SetBlendMode( CString );
virtual void SetTextureWrapping( bool b ) { m_bTextureWrapping = b; }
virtual void SetClearZBuffer( bool b ) { m_bClearZBuffer = b; }
virtual void SetUseZBuffer( bool b ) { m_bUseZBuffer = b; }
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; }
//
@@ -352,7 +354,7 @@ protected:
bool m_bTextureWrapping;
BlendMode m_BlendMode;
bool m_bClearZBuffer;
bool m_bUseZBuffer;
bool m_bZTest, m_bZWrite;
bool m_bUseBackfaceCull;
};
+12 -3
View File
@@ -87,13 +87,22 @@ void ActorFrame::SetDiffuse( RageColor c )
m_SubActors[i]->SetDiffuse(c );
}
void ActorFrame::SetUseZBuffer( bool b )
void ActorFrame::SetZTest( bool b )
{
Actor::SetUseZBuffer( b );
Actor::SetZTest( b );
// set all sub-Actors
for( unsigned i=0; i<m_SubActors.size(); i++ )
m_SubActors[i]->SetUseZBuffer( b );
m_SubActors[i]->SetZTest( b );
}
void ActorFrame::SetZWrite( bool b )
{
Actor::SetZWrite( b );
// set all sub-Actors
for( unsigned i=0; i<m_SubActors.size(); i++ )
m_SubActors[i]->SetZWrite( b );
}
void ActorFrame::FinishTweening()
+2 -1
View File
@@ -28,7 +28,8 @@ public:
virtual void SetDiffuse( RageColor c );
virtual void SetUseZBuffer( bool b );
virtual void SetZTest( bool b );
virtual void SetZWrite( bool b );
virtual void FinishTweening();
virtual void HurryTweening( float factor );
+1 -1
View File
@@ -27,7 +27,7 @@ Model::Model ()
{
m_pBones = NULL;
m_bTextureWrapping = true;
m_bUseZBuffer = true;
SetUseZBuffer( true );
m_pCurAnimation = NULL;
m_bRevertToDefaultAnimation = false;
m_fDefaultAnimationRate = 1;
+5 -2
View File
@@ -166,9 +166,12 @@ public:
virtual int GetMaxTextureSize() const = 0;
virtual void SetTextureFiltering( bool b ) = 0;
virtual bool IsZBufferEnabled() const = 0;
virtual void SetZBuffer( bool b ) = 0;
virtual bool IsZTestEnabled() const = 0;
virtual bool IsZWriteEnabled() const = 0;
virtual void SetZWrite( bool b ) = 0;
virtual void SetZTest( bool b ) = 0;
virtual void ClearZBuffer() = 0;
void SetZBuffer( bool b ) { SetZWrite(b); SetZTest(b); } // shortcut
virtual void SetBackfaceCull( bool b ) = 0;
+17 -5
View File
@@ -884,19 +884,31 @@ void RageDisplay_D3D::SetBlendMode( BlendMode mode )
}
}
bool RageDisplay_D3D::IsZBufferEnabled() const
bool RageDisplay_D3D::IsZWriteEnabled() const
{
DWORD b;
g_pd3dDevice->GetRenderState( D3DRS_ZENABLE, &b );
g_pd3dDevice->GetRenderState( D3DRS_ZWRITEENABLE, &b );
return b!=0;
}
void RageDisplay_D3D::SetZBuffer( bool b )
bool RageDisplay_D3D::IsZTestEnabled() const
{
DWORD b;
g_pd3dDevice->GetRenderState( D3DRS_ZFUNC, &b );
return b!=D3DCMP_ALWAYS;
}
void RageDisplay_D3D::SetZWrite( bool b )
{
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, b ? D3DZB_TRUE : D3DZB_FALSE );
g_pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, b );
}
void RageDisplay_D3D::SetZTest( bool b )
{
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
g_pd3dDevice->SetRenderState( D3DRS_ZFUNC, b ? D3DCMP_LESSEQUAL : D3DCMP_ALWAYS );
}
void RageDisplay_D3D::ClearZBuffer()
{
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
+4 -2
View File
@@ -45,8 +45,10 @@ public:
void SetTextureWrapping( bool b );
int GetMaxTextureSize() const;
void SetTextureFiltering( bool b);
bool IsZBufferEnabled() const;
void SetZBuffer( bool b );
bool IsZWriteEnabled() const;
bool IsZTestEnabled() const;
void SetZWrite( bool b );
void SetZTest( bool b );
void ClearZBuffer();
void SetBackfaceCull( bool b );
void SetAlphaTest( bool b );
+26 -8
View File
@@ -683,6 +683,7 @@ int RageDisplay_OGL::GetMaxTextureSize() const
void RageDisplay_OGL::BeginFrame()
{
glClearColor( 0,0,0,1 );
SetZWrite( true );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
@@ -1033,6 +1034,7 @@ void RageDisplay_OGL::SetBlendMode( BlendMode mode )
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
break;
case BLEND_NO_EFFECT:
/* XXX: Would it be faster and have the same effect to say glDisable(GL_COLOR_WRITEMASK)? */
glBlendFunc( GL_ZERO, GL_ONE );
/* This is almost exclusively used to draw masks to the Z-buffer. Make sure
@@ -1044,24 +1046,40 @@ void RageDisplay_OGL::SetBlendMode( BlendMode mode )
}
}
bool RageDisplay_OGL::IsZBufferEnabled() const
bool RageDisplay_OGL::IsZWriteEnabled() const
{
bool a;
glGetBooleanv( GL_DEPTH_TEST, (unsigned char*)&a );
glGetBooleanv( GL_DEPTH_WRITEMASK, (unsigned char*)&a );
return a;
}
void RageDisplay_OGL::SetZBuffer( bool b )
bool RageDisplay_OGL::IsZTestEnabled() const
{
glDepthFunc(GL_LEQUAL);
if( b )
glEnable( GL_DEPTH_TEST );
else
glDisable( GL_DEPTH_TEST );
GLenum a;
glGetIntegerv( GL_DEPTH_FUNC, (int*)&a );
return a != GL_ALWAYS;
}
void RageDisplay_OGL::ClearZBuffer()
{
bool write = IsZWriteEnabled();
SetZWrite( true );
glClear( GL_DEPTH_BUFFER_BIT );
SetZWrite( write );
}
void RageDisplay_OGL::SetZWrite( bool b )
{
glDepthMask( b );
}
void RageDisplay_OGL::SetZTest( bool b )
{
glEnable( GL_DEPTH_TEST );
if( b )
glDepthFunc( GL_LEQUAL );
else
glDepthFunc( GL_ALWAYS );
}
void RageDisplay_OGL::SetTextureWrapping( bool b )
+4 -2
View File
@@ -31,8 +31,10 @@ public:
void SetTextureWrapping( bool b );
int GetMaxTextureSize() const;
void SetTextureFiltering( bool b);
bool IsZBufferEnabled() const;
void SetZBuffer( bool b );
bool IsZWriteEnabled() const;
bool IsZTestEnabled() const;
void SetZWrite( bool b );
void SetZTest( bool b );
void ClearZBuffer();
void SetBackfaceCull( bool b );
void SetAlphaTest( bool b );