From b62b9e853db8b71470355981330e982eb64a032c Mon Sep 17 00:00:00 2001 From: mix Date: Thu, 14 Aug 2025 14:36:46 +0100 Subject: [PATCH] Fix #24151: Change OpenGL shader gl_FragCoord use to not require layout --- data/shaders/drawrect.frag | 6 ++++-- data/shaders/drawrect.vert | 3 +++ distribution/changelog.txt | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/data/shaders/drawrect.frag b/data/shaders/drawrect.frag index d9e5a95be3..c90aa727db 100644 --- a/data/shaders/drawrect.frag +++ b/data/shaders/drawrect.frag @@ -13,7 +13,7 @@ uniform usampler2D uPaletteTex; uniform sampler2D uPeelingTex; uniform bool uPeeling; -layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; +in vec4 gl_FragCoord; flat in int fFlags; flat in uint fColour; @@ -26,6 +26,7 @@ in vec3 fPeelPos; flat in float fZoom; flat in int fTexColourAtlas; flat in int fTexMaskAtlas; +flat in int fScreenHeight; // clang-format on out uint oColour; @@ -41,7 +42,8 @@ void main() } } - vec2 position = (gl_FragCoord.xy - fPosition) * fZoom; + vec2 fragCoord = vec2(floor(gl_FragCoord.x), fScreenHeight - floor(gl_FragCoord.y) - 1); + vec2 position = (fragCoord - fPosition) * fZoom; uint texel; if ((fFlags & FLAG_NO_TEXTURE) == 0) diff --git a/data/shaders/drawrect.vert b/data/shaders/drawrect.vert index 6dc325b9dd..1f346523b4 100644 --- a/data/shaders/drawrect.vert +++ b/data/shaders/drawrect.vert @@ -31,6 +31,7 @@ flat out vec3 fPalettes; flat out float fZoom; flat out int fTexColourAtlas; flat out int fTexMaskAtlas; +flat out int fScreenHeight; // clang-format on void main() @@ -57,6 +58,8 @@ void main() fColour = vColour; fPalettes = vec3(vPalettes); + fScreenHeight = uScreenSize.y; + // Transform texture coordinates to viewport coordinates pos = pos * 2.0 - 1.0; gl_Position = vec4(pos, depth, 1.0); diff --git a/distribution/changelog.txt b/distribution/changelog.txt index d67ca1e908..5a6d5c264a 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -12,6 +12,7 @@ - Fix: [#16988] AppImage version does not show changelog. - Fix: [#18048] Play music from all ride's stations. - Fix: [#24001] Sloped diagonal metal supports that are offset with a crossbeam draw incorrectly. +- Fix: [#24151] Sprites are cut off by 1 row of pixels when using OpenGL on Intel Macs. - Fix: [#24173] Allow all game speeds between 1 and 8 if developer mode is on. - Fix: [#24745] Potential crash when lighting effects are enabled and loading a save or a new scenario. - Fix: [#24835] Dive loop track pieces do not have tunnels.