Browse Source

Changed the screen_coords parameter of the effect function in pixel shaders so y+ is down instead of up (resolves issue #435.)

--HG--
branch : minor
Alex Szpakowski 11 years ago
parent
commit
8f40319817
1 changed files with 9 additions and 9 deletions
  1. 9 9
      src/modules/graphics/opengl/Shader.cpp

+ 9 - 9
src/modules/graphics/opengl/Shader.cpp

@@ -700,26 +700,26 @@ void Shader::checkSetScreenParams()
 		return;
 		return;
 
 
 	// In the shader, we do pixcoord.y = gl_FragCoord.y * params.z + params.w.
 	// In the shader, we do pixcoord.y = gl_FragCoord.y * params.z + params.w.
-	// This lets us flip pixcoord.y when needed, to be consistent (Canvases
-	// have flipped y-values for pixel coordinates.)
+	// This lets us flip pixcoord.y when needed, to be consistent (drawing with
+	// no Canvas active makes the y-values for pixel coordinates flipped.)
 	GLfloat params[] = {
 	GLfloat params[] = {
 		(GLfloat) view.w, (GLfloat) view.h,
 		(GLfloat) view.w, (GLfloat) view.h,
 		0.0f, 0.0f,
 		0.0f, 0.0f,
 	};
 	};
 
 
 	if (Canvas::current != nullptr)
 	if (Canvas::current != nullptr)
-	{
-		// gl_FragCoord.y is flipped in Canvases, so we un-flip:
-		// pixcoord.y = gl_FragCoord.y * -1.0 + height.
-		params[2] = -1.0f;
-		params[3] = (GLfloat) view.h;
-	}
-	else
 	{
 	{
 		// No flipping: pixcoord.y = gl_FragCoord.y * 1.0 + 0.0.
 		// No flipping: pixcoord.y = gl_FragCoord.y * 1.0 + 0.0.
 		params[2] = 1.0f;
 		params[2] = 1.0f;
 		params[3] = 0.0f;
 		params[3] = 0.0f;
 	}
 	}
+	else
+	{
+		// gl_FragCoord.y is flipped when drawing to the screen, so we un-flip:
+		// pixcoord.y = gl_FragCoord.y * -1.0 + height.
+		params[2] = -1.0f;
+		params[3] = (GLfloat) view.h;
+	}
 
 
 	sendBuiltinFloat(BUILTIN_SCREEN_SIZE, 4, params, 1);
 	sendBuiltinFloat(BUILTIN_SCREEN_SIZE, 4, params, 1);