Commits

Assaf Raman committed 35ba38f

Fixed stencil buffer bug - caused by a naming confusion of the meaning of the word "mask", in the GL function glStencilFunc - the parameter "mask" actually mean mask, but in the function "glStencilMask" the parameter "mask" actually mean the ref value that will be written to the buffer.
The issue was found when running the same code on both D3D9 render system and OpenGL render system and seeing different visual result. After the fix – the results are the same.
Credit to Mattan for fixing this issue.

Comments (0)

Files changed (1)

RenderSystems/GL/src/OgreGLRenderSystem.cpp

 		bool twoSidedOperation)
 	{
 		bool flip;
-		mStencilMask = mask;
+		mStencilMask = refValue;
 
 		if (twoSidedOperation)
 		{
 				glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
 				// Back
 				glActiveStencilFaceEXT(GL_BACK);
-				glStencilMask(mask);
+				glStencilMask(refValue);
 				glStencilFunc(convertCompareFunction(func), refValue, mask);
 				glStencilOp(
 					convertStencilOp(stencilFailOp, !flip), 
 					convertStencilOp(passOp, !flip));
 				// Front
 				glActiveStencilFaceEXT(GL_FRONT);
-				glStencilMask(mask);
+				glStencilMask(refValue);
 				glStencilFunc(convertCompareFunction(func), refValue, mask);
 				glStencilOp(
 					convertStencilOp(stencilFailOp, flip),
                 glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
 
 			flip = false;
-			glStencilMask(mask);
+			glStencilMask(refValue);
 			glStencilFunc(convertCompareFunction(func), refValue, mask);
 			glStencilOp(
 				convertStencilOp(stencilFailOp, flip),