瀏覽代碼

Fixed RenderState issue where the default GL blend mode was assumed to be (GL_ONE,GL_ONE), instead of (GL_ONE,GL_ZERO). This was preventing explicit state changes of (GL_ONE,GL_ONE) from being applied, since no change was detected.

Steve Grenier 13 年之前
父節點
當前提交
afb2d1f220
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7 5
      gameplay/src/RenderState.cpp

+ 7 - 5
gameplay/src/RenderState.cpp

@@ -361,7 +361,7 @@ void RenderState::cloneInto(RenderState* renderState, NodeCloneContext& context)
 
 RenderState::StateBlock::StateBlock()
     : _cullFaceEnabled(false), _depthTestEnabled(false), _depthWriteEnabled(false),
-      _blendEnabled(false), _blendSrc(RenderState::BLEND_ONE), _blendDst(RenderState::BLEND_ONE),
+      _blendEnabled(false), _blendSrc(RenderState::BLEND_ONE), _blendDst(RenderState::BLEND_ZERO),
       _bits(0L)
 {
 }
@@ -455,10 +455,10 @@ void RenderState::StateBlock::restore(long stateOverrideBits)
     }
     if (!(stateOverrideBits & RS_BLEND_FUNC) && (_defaultState->_bits & RS_BLEND_FUNC))
     {
-        GL_ASSERT( glBlendFunc(GL_ONE, GL_ONE) );
+        GL_ASSERT( glBlendFunc(GL_ONE, GL_ZERO) );
         _defaultState->_bits &= ~RS_BLEND_FUNC;
         _defaultState->_blendSrc = RenderState::BLEND_ONE;
-        _defaultState->_blendDst = RenderState::BLEND_ONE;
+        _defaultState->_blendDst = RenderState::BLEND_ZERO;
     }
     if (!(stateOverrideBits & RS_CULL_FACE) && (_defaultState->_bits & RS_CULL_FACE))
     {
@@ -593,8 +593,9 @@ void RenderState::StateBlock::setBlend(bool enabled)
 void RenderState::StateBlock::setBlendSrc(Blend blend)
 {
     _blendSrc = blend;
-    if (_blendSrc == BLEND_ONE && _blendDst == BLEND_ONE)
+    if (_blendSrc == BLEND_ONE && _blendDst == BLEND_ZERO)
     {
+        // Default blend func
         _bits &= ~RS_BLEND_FUNC;
     }
     else
@@ -606,8 +607,9 @@ void RenderState::StateBlock::setBlendSrc(Blend blend)
 void RenderState::StateBlock::setBlendDst(Blend blend)
 {
     _blendDst = blend;
-    if (_blendSrc == BLEND_ONE && _blendDst == BLEND_ONE)
+    if (_blendSrc == BLEND_ONE && _blendDst == BLEND_ZERO)
     {
+        // Default blend func
         _bits &= ~RS_BLEND_FUNC;
     }
     else