From 8f40319817a72902f7196fff195e8876550c6ec4 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 1 Apr 2014 21:08:12 -0300 Subject: [PATCH] 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 --- src/modules/graphics/opengl/Shader.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/graphics/opengl/Shader.cpp b/src/modules/graphics/opengl/Shader.cpp index ac7ee2de0..910d51fa2 100644 --- a/src/modules/graphics/opengl/Shader.cpp +++ b/src/modules/graphics/opengl/Shader.cpp @@ -700,26 +700,26 @@ void Shader::checkSetScreenParams() return; // 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) view.w, (GLfloat) view.h, 0.0f, 0.0f, }; 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. params[2] = 1.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);