From 65b5b58e9855a702ba0a322d37a8303596b70de5 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 3 Sep 2012 12:41:05 +0000 Subject: [PATCH] neercs: do not crash if the shader system does not support integer attributes, but do not display anything yet (the code is not ready). --- neercs/video/text.lolfx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/neercs/video/text.lolfx b/neercs/video/text.lolfx index dc3ed5b..ccae185 100644 --- a/neercs/video/text.lolfx +++ b/neercs/video/text.lolfx @@ -2,8 +2,14 @@ #version 130 +#define HAVE_UINT 0 + attribute vec2 in_Position; +#if HAVE_UINT attribute uint in_Char, in_Attr; +#else +attribute vec4 in_Char, in_Attr; +#endif varying vec4 pass_Foreground; varying vec4 pass_Background; @@ -13,10 +19,16 @@ uniform mat4 in_Transform; void main() { +#if HAVE_UINT float u = float(in_Char & 0xfu) / 32.0 + 0.0; float v = float((in_Char >> 4u) & 0xfu) / 32.0 + 0.5; +#else + float u = 3.0 / 32.0; + float v = 3.0 / 32.0 + 0.5; +#endif pass_UV = vec2(u, v); +#if HAVE_UINT float A = float(in_Attr >> 29u) / 7.0; float B = float((in_Attr >> 25u) & 0xfu) / 15.0; float C = float((in_Attr >> 21u) & 0xfu) / 15.0; @@ -26,6 +38,17 @@ void main() float F = float((in_Attr >> 11u) & 0xfu) / 15.0; float G = float((in_Attr >> 7u) & 0xfu) / 15.0; float H = float((in_Attr >> 4u) & 0x7u) / 7.0; +#else + float A = 0.0; + float B = 0.0; + float C = 0.0; + float D = 0.0; + + float E = 0.0; + float F = 1.0; + float G = 1.0; + float H = 1.0; +#endif pass_Background = vec4(B, C, D, 1.0 - A); pass_Foreground = vec4(F, G, H, 1.0 - E); @@ -53,4 +76,4 @@ void main(void) vec2 c = gl_PointCoord * (1.0 / 32.0) + pass_UV; float t = texture2D(in_Texture, c).x; gl_FragColor = mix(pass_Background, pass_Foreground, t); -} \ No newline at end of file +}