unroll glsl for loop for compatibility on mac

This commit is contained in:
2019-01-19 23:34:42 +01:00
parent 13f6bd29fa
commit 36cbe52e2e
2 changed files with 12 additions and 9 deletions

View File

@@ -372,9 +372,9 @@ void App::init()
initLayout();
title_update();
GLfloat width_range[2];
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, width_range);
LOG("GL line range: %f - %f", width_range[0], width_range[1]);
//GLfloat width_range[2];
//glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, width_range);
//LOG("GL line range: %f - %f", width_range[0], width_range[1]);
LOG("Screen Size: %f %f", width, height);
GLint fb0;

View File

@@ -161,12 +161,15 @@ void App::initShaders()
"void main() {\n"
" mediump float stroke = 1.0 - texture(tex, uv).r;\n"
" int zero_count = 0;\n"
" for (int x = -1; x <= 1; x++){\n"
" for (int y = -1; y <= 1; y++){\n"
" if (textureOffset(tex, uv, ivec2(x, y)).r == 1.0) \n"
" zero_count++;\n"
" }\n"
" }\n"
" if (textureOffset(tex, uv, ivec2(-1, -1)).r == 1.0) zero_count++;\n"
" if (textureOffset(tex, uv, ivec2(-1, 0)).r == 1.0) zero_count++;\n"
" if (textureOffset(tex, uv, ivec2(-1, +1)).r == 1.0) zero_count++;\n"
" if (textureOffset(tex, uv, ivec2( 0, -1)).r == 1.0) zero_count++;\n"
" if (textureOffset(tex, uv, ivec2( 0, 0)).r == 1.0) zero_count++;\n"
" if (textureOffset(tex, uv, ivec2( 0, +1)).r == 1.0) zero_count++;\n"
" if (textureOffset(tex, uv, ivec2(+1, -1)).r == 1.0) zero_count++;\n"
" if (textureOffset(tex, uv, ivec2(+1, 0)).r == 1.0) zero_count++;\n"
" if (textureOffset(tex, uv, ivec2(+1, +1)).r == 1.0) zero_count++;\n"
" float edge = (zero_count > 1 && zero_count < 9) ? 0.75 : 0.0;\n"
" frag = vec4(col.rgb, edge * (1.0 - zero_count / 9.f));\n"
"}\n";