瀏覽代碼

Bugfix: OpenGL stencil operations on back faces are now applied properly

BearishSun 8 年之前
父節點
當前提交
7e7dbd580d
共有 2 個文件被更改,包括 14 次插入17 次删除
  1. 12 12
      Source/BansheeGLRenderAPI/BsGLRenderAPI.cpp
  2. 2 5
      Source/BansheeGLRenderAPI/BsGLRenderAPI.h

+ 12 - 12
Source/BansheeGLRenderAPI/BsGLRenderAPI.cpp

@@ -2018,9 +2018,9 @@ namespace bs { namespace ct
 		{
 			glStencilOpSeparate(
 				GL_BACK,
-				convertStencilOp(stencilFailOp, true),
-				convertStencilOp(depthFailOp, true),
-				convertStencilOp(passOp, true));
+				convertStencilOp(stencilFailOp),
+				convertStencilOp(depthFailOp),
+				convertStencilOp(passOp));
 			BS_CHECK_GL_ERROR();
 		}
 	}
@@ -2227,7 +2227,7 @@ namespace bs { namespace ct
 		return curAniso ? curAniso : 1;
 	}
 
-	GLint GLRenderAPI::convertStencilOp(StencilOperation op, bool invert) const
+	GLint GLRenderAPI::convertStencilOp(StencilOperation op) const
 	{
 		switch (op)
 		{
@@ -2238,17 +2238,17 @@ namespace bs { namespace ct
 		case SOP_REPLACE:
 			return GL_REPLACE;
 		case SOP_INCREMENT:
-			return invert ? GL_DECR : GL_INCR;
+			return GL_INCR;
 		case SOP_DECREMENT:
-			return invert ? GL_INCR : GL_DECR;
+			return GL_DECR;
 		case SOP_INCREMENT_WRAP:
-			return invert ? GL_DECR_WRAP_EXT : GL_INCR_WRAP_EXT;
+			return GL_INCR_WRAP_EXT;
 		case SOP_DECREMENT_WRAP:
-			return invert ? GL_INCR_WRAP_EXT : GL_DECR_WRAP_EXT;
+			return GL_DECR_WRAP_EXT;
 		case SOP_INVERT:
 			return GL_INVERT;
-		};
-		// to keep compiler happy
+		}
+
 		return SOP_KEEP;
 	}
 
@@ -2272,7 +2272,7 @@ namespace bs { namespace ct
 			return GL_GEQUAL;
 		case CMPF_GREATER:
 			return GL_GREATER;
-		};
+		}
 
 		return GL_ALWAYS;
 	}
@@ -2349,7 +2349,7 @@ namespace bs { namespace ct
 			return GL_ONE_MINUS_DST_ALPHA;
 		case BF_INV_SOURCE_ALPHA:
 			return GL_ONE_MINUS_SRC_ALPHA;
-		};
+		}
 
 		return GL_ONE;
 	}

+ 2 - 5
Source/BansheeGLRenderAPI/BsGLRenderAPI.h

@@ -358,11 +358,8 @@ namespace bs { namespace ct
 		/**	Converts the engine depth/stencil compare function into OpenGL representation. */
 		GLint convertCompareFunction(CompareFunction func) const;
 
-		/**
-		 * Convers the engine stencil operation in OpenGL representation. Optionally inverts the operation (increment
-		 * becomes decrement, etc.).
-		 */
-		GLint convertStencilOp(StencilOperation op, bool invert = false) const;
+		/** Convers the engine stencil operation in OpenGL representation. */
+		GLint convertStencilOp(StencilOperation op) const;
 
 	private:
 		/** Information about a currently bound texture. */