From 1ae812ff0396bbd8aaee19bc515a52422f7abb16 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 1 Oct 2022 16:41:51 +0900 Subject: [PATCH] Fix shader compilation errors in OpenGL ES --- shaders/dilate.f.glsl | 6 +++--- shaders/fill_angle.f.glsl | 2 +- src/video.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/shaders/dilate.f.glsl b/shaders/dilate.f.glsl index d3cf0b1..4497bdc 100644 --- a/shaders/dilate.f.glsl +++ b/shaders/dilate.f.glsl @@ -27,9 +27,9 @@ void main() { int size = int(floor(threshold)); int cutoff = size + 1; float edge_weight = fract(threshold); - vec2 tex_size = textureSize(tex, 0).xy; + vec2 tex_size = vec2(textureSize(tex, 0).xy); - float a_out = 0; + float a_out = 0.0; for (int x = -cutoff; x <= cutoff; x++) { for (int y = -cutoff; y <= cutoff; y++) { @@ -37,7 +37,7 @@ void main() { if (d > threshold) continue; float a = texture(tex, tex_coord + vec2(x, y) / tex_size).r; - if (d > size) + if (d > float(size)) a *= edge_weight; a_out += a; } diff --git a/shaders/fill_angle.f.glsl b/shaders/fill_angle.f.glsl index e76e8b2..b2f3906 100644 --- a/shaders/fill_angle.f.glsl +++ b/shaders/fill_angle.f.glsl @@ -27,7 +27,7 @@ out vec4 frag_color; void main() { vec2 p = tex_coord - center; float a = atan(p.y, p.x); - a = mod(a - start_angle, 2 * PI); + a = mod(a - start_angle, 2.0 * PI); if (a > angle) discard; frag_color = color; diff --git a/src/video.c b/src/video.c index 1d2def7..697fedf 100644 --- a/src/video.c +++ b/src/video.c @@ -36,7 +36,8 @@ struct sdl_private sdl; static const GLchar glsl_preamble[] = #ifdef USE_GLES "#version 300 es\n" - "precision highp float;\n"; + "precision highp float;\n" + "precision highp int;\n"; #else "#version 140\n"; #endif