From: <cn...@us...> - 2009-11-13 07:44:19
|
Revision: 616 http://hgengine.svn.sourceforge.net/hgengine/?rev=616&view=rev Author: cnlohr Date: 2009-11-13 07:44:12 +0000 (Fri, 13 Nov 2009) Log Message: ----------- add new state changers Modified Paths: -------------- Mercury2/src/StateChanger.cpp Modified: Mercury2/src/StateChanger.cpp =================================================================== --- Mercury2/src/StateChanger.cpp 2009-11-13 07:43:08 UTC (rev 615) +++ Mercury2/src/StateChanger.cpp 2009-11-13 07:44:12 UTC (rev 616) @@ -78,7 +78,41 @@ REGISTER_STATECHANGE( LightingSwitch ); +///State changer for enabling/disabling lighting +class DepthTest : public StateChange +{ +public: + DepthTest( const MVector< MString > & sParameters ) : StateChange( sParameters ) + { + if( sParameters.size() < 1 ) + { + LOG.Write( ssprintf( "Error: DepthTest state has invalid number of parameters(%d).", sParameters.size() ) ); + return; + } + bEnable = StrToBool( sParameters[0] ); + } + + void Stringify( MString & sOut ) + { + sOut = ssprintf( "%f", bEnable ); + } + + void Activate() + { + if( bEnable ) + glEnable( GL_DEPTH_TEST ); + else + glDisable( GL_DEPTH_TEST ); + } + + STATECHANGE_RTTI( DepthTest ); + bool bEnable; +}; + +REGISTER_STATECHANGE( DepthTest ); + + //////////////////////////////////////STATE CHANGE CHUNK////////////////////////////////////// StateChangeRegister * StateChangeRegister::m_Instance; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-12-29 15:52:14
|
Revision: 646 http://hgengine.svn.sourceforge.net/hgengine/?rev=646&view=rev Author: axlecrusher Date: 2009-12-29 15:52:06 +0000 (Tue, 29 Dec 2009) Log Message: ----------- enable writing blend state Modified Paths: -------------- Mercury2/src/StateChanger.cpp Modified: Mercury2/src/StateChanger.cpp =================================================================== --- Mercury2/src/StateChanger.cpp 2009-12-28 22:26:28 UTC (rev 645) +++ Mercury2/src/StateChanger.cpp 2009-12-29 15:52:06 UTC (rev 646) @@ -167,8 +167,7 @@ void Stringify( MString & sOut ) { - //XXX -// sOut = ssprintf( "%f", bEnable ); + sOut = BlendToString(m_src) + "," + BlendToString(m_dest); } #define STRTOGL(x,s) if (x==#s) return GL_##s; @@ -191,6 +190,29 @@ STRTOGL(s, SRC_ALPHA_SATURATE); } + #define GLTOSTR(x,s) case GL_##s: return #s; + MString BlendToString(int blend) + { + switch (blend) + { + GLTOSTR(blend, ZERO); + GLTOSTR(blend, ONE); + GLTOSTR(blend, SRC_COLOR); + GLTOSTR(blend, ONE_MINUS_SRC_COLOR); + GLTOSTR(blend, DST_COLOR); + GLTOSTR(blend, ONE_MINUS_DST_COLOR); + GLTOSTR(blend, SRC_ALPHA); + GLTOSTR(blend, ONE_MINUS_SRC_ALPHA); + GLTOSTR(blend, DST_ALPHA); + GLTOSTR(blend, ONE_MINUS_DST_ALPHA); + GLTOSTR(blend, CONSTANT_COLOR); + GLTOSTR(blend, ONE_MINUS_CONSTANT_COLOR); + GLTOSTR(blend, CONSTANT_ALPHA); + GLTOSTR(blend, ONE_MINUS_CONSTANT_ALPHA); + GLTOSTR(blend, SRC_ALPHA_SATURATE); + }; + } + void Activate() { GLCALL( glBlendFunc(m_src,m_dest) ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2010-02-23 07:39:20
|
Revision: 675 http://hgengine.svn.sourceforge.net/hgengine/?rev=675&view=rev Author: cnlohr Date: 2010-02-23 07:39:14 +0000 (Tue, 23 Feb 2010) Log Message: ----------- whoops! Forgot to initialize values Modified Paths: -------------- Mercury2/src/StateChanger.cpp Modified: Mercury2/src/StateChanger.cpp =================================================================== --- Mercury2/src/StateChanger.cpp 2010-02-23 05:53:27 UTC (rev 674) +++ Mercury2/src/StateChanger.cpp 2010-02-23 07:39:14 UTC (rev 675) @@ -375,7 +375,7 @@ REGISTER_ASSET_TYPE(StateChanger); StateChanger::StateChanger( const MString & key, bool bInstanced ) - :MercuryAsset( key, bInstanced ) + :MercuryAsset( key, bInstanced ), m_isEnduring(0) { //Make sure our state stack is correctly sized if( m_StateSet.size() < (unsigned)StateChangeRegister::Instance().GetStateCount() ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2010-05-23 12:37:27
|
Revision: 746 http://hgengine.svn.sourceforge.net/hgengine/?rev=746&view=rev Author: axlecrusher Date: 2010-05-23 12:37:21 +0000 (Sun, 23 May 2010) Log Message: ----------- try to minimize state changes Modified Paths: -------------- Mercury2/src/StateChanger.cpp Modified: Mercury2/src/StateChanger.cpp =================================================================== --- Mercury2/src/StateChanger.cpp 2010-05-22 19:13:36 UTC (rev 745) +++ Mercury2/src/StateChanger.cpp 2010-05-23 12:37:21 UTC (rev 746) @@ -106,18 +106,37 @@ { if( bEnable ) { - GLCALL( glEnable( GL_DEPTH_TEST ) ); + if (m_lastState != ON) + { + GLCALL( glEnable( GL_DEPTH_TEST ) ); + m_lastState = ON; + } } else { - GLCALL( glDisable( GL_DEPTH_TEST ) ); + if (m_lastState != OFF) + { + GLCALL( glDisable( GL_DEPTH_TEST ) ); + m_lastState = OFF; + } } } STATECHANGE_RTTI( DepthTest ); - bool bEnable; + + private: + bool bEnable; + enum LastDepthState + { + UNKNOWN, + ON, + OFF + }; + static LastDepthState m_lastState; }; +DepthTest::LastDepthState DepthTest::m_lastState = UNKNOWN; + REGISTER_STATECHANGE( DepthTest ); class DepthWrite : public StateChange @@ -262,13 +281,24 @@ void Activate() { - GLCALL( glBlendFunc(m_src,m_dest) ); + if ((m_src != m_lastSrc)||(m_dest!=m_lastDest)) + { + GLCALL( glBlendFunc(m_src,m_dest) ); + m_lastSrc = m_src; + m_lastDest = m_dest; + } } STATECHANGE_RTTI( BlendFunc ); - int m_src, m_dest; + + private: + int m_src, m_dest; + static long m_lastSrc, m_lastDest; }; +long BlendFunc::m_lastSrc = 0; +long BlendFunc::m_lastDest = 0; + REGISTER_STATECHANGE( BlendFunc ); ///Change the alpha blending function (can be useful for non-shader farcry-like foliage) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2010-06-29 03:48:00
|
Revision: 752 http://hgengine.svn.sourceforge.net/hgengine/?rev=752&view=rev Author: cnlohr Date: 2010-06-29 03:47:54 +0000 (Tue, 29 Jun 2010) Log Message: ----------- fix light ID update Modified Paths: -------------- Mercury2/src/StateChanger.cpp Modified: Mercury2/src/StateChanger.cpp =================================================================== --- Mercury2/src/StateChanger.cpp 2010-06-08 02:18:41 UTC (rev 751) +++ Mercury2/src/StateChanger.cpp 2010-06-29 03:47:54 UTC (rev 752) @@ -396,10 +396,10 @@ void Activate() { GLCALL( glEnable(GL_LIGHT0 + iLight) ); - GLCALL( glLightfv(GL_LIGHT0, GL_POSITION, &fParams[0]) ); - GLCALL( glLightfv(GL_LIGHT0, GL_DIFFUSE, &fParams[4]) ); - GLCALL( glLightfv(GL_LIGHT0, GL_AMBIENT, &fParams[8]) ); - GLCALL( glLightfv(GL_LIGHT0, GL_SPECULAR, &fParams[12]) ); + GLCALL( glLightfv(GL_LIGHT0 + iLight, GL_POSITION, &fParams[0]) ); + GLCALL( glLightfv(GL_LIGHT0 + iLight, GL_DIFFUSE, &fParams[4]) ); + GLCALL( glLightfv(GL_LIGHT0 + iLight, GL_AMBIENT, &fParams[8]) ); + GLCALL( glLightfv(GL_LIGHT0 + iLight, GL_SPECULAR, &fParams[12]) ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |