mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
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
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user