From 6c1bc5548cf61da25f1fc70fe961fbbadff2b714 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 21 May 2019 15:17:42 -0700 Subject: [PATCH] GBA Video: Fix scale/rot sprite mosaic in GL --- src/gba/renderers/gl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gba/renderers/gl.c b/src/gba/renderers/gl.c index ab57298c3..6546dc57d 100644 --- a/src/gba/renderers/gl.c +++ b/src/gba/renderers/gl.c @@ -404,13 +404,15 @@ static const char* const _renderObj = "void main() {\n" " vec2 incoord = texCoord;\n" " if (mosaic.x > 1) {\n" - " incoord.x = clamp(incoord.x - int(mod(mosaic.z + incoord.x, mosaic.x)), 0, dims.z - 1);\n" + " int x = int(incoord.x);\n" + " incoord.x = clamp(x - int(mod(mosaic.z + x, mosaic.x)), 0, dims.z - 1);\n" " } else if (mosaic.x < -1) {\n" - " incoord.x = dims.z - incoord.x - 1;" - " incoord.x = clamp(dims.z - incoord.x + int(mod(mosaic.z + incoord.x, -mosaic.x)) - 1, 0, dims.z - 1);\n" + " int x = dims.z - int(incoord.x) - 1;\n" + " incoord.x = clamp(dims.z - x + int(mod(mosaic.z + x, -mosaic.x)) - 1, 0, dims.z - 1);\n" " }\n" " if (mosaic.y > 1) {\n" - " incoord.y = clamp(incoord.y - int(mod(mosaic.w + incoord.y, mosaic.y)), 0, dims.w - 1);\n" + " int y = int(incoord.y);\n" + " incoord.y = clamp(y - int(mod(mosaic.w + y, mosaic.y)), 0, dims.w - 1);\n" " }\n" " ivec2 coord = ivec2(transform * (incoord - dims.zw / 2) + dims.xy / 2);\n" " if ((coord & ~(dims.xy - 1)) != ivec2(0, 0)) {\n"