summaryrefslogtreecommitdiff
path: root/tests/testglarea.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2016-04-22 13:53:16 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2016-04-25 14:35:02 +0100
commita92ba06383ad7fe8bb63279603ceeee2ce6217f3 (patch)
tree0c3afe1bf15c9819963d8507159e728deee12b68 /tests/testglarea.c
parentf848450a70931133ab9368fd35b629c6c6e50fcb (diff)
downloadgtk+-a92ba06383ad7fe8bb63279603ceeee2ce6217f3.tar.gz
tests: Add GLES shaders to testglarea
Check if the GdkGLContext is using ES, and load the appropriate shaders in that case.
Diffstat (limited to 'tests/testglarea.c')
-rw-r--r--tests/testglarea.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/tests/testglarea.c b/tests/testglarea.c
index 764e2311b3..ef2bec8d39 100644
--- a/tests/testglarea.c
+++ b/tests/testglarea.c
@@ -80,6 +80,20 @@ create_shader (int type, const char *src)
return shader;
}
+static const char *vertex_shader_code_gles =
+"attribute vec4 position;\n" \
+"uniform mat4 mvp;\n" \
+"void main() {\n" \
+" gl_Position = mvp * position;\n" \
+"}";
+
+static const char *fragment_shader_code_gles =
+"precision mediump float;\n" \
+"void main() {\n" \
+" float lerpVal = gl_FragCoord.y / 400.0;\n" \
+" gl_FragColor = mix(vec4(1.0, 0.85, 0.35, 1.0), vec4(0.2, 0.2, 0.2, 1.0), lerpVal);\n" \
+"}";
+
static const char *vertex_shader_code_330 =
"#version 330\n" \
"\n" \
@@ -243,15 +257,23 @@ realize (GtkWidget *widget)
return;
context = gtk_gl_area_get_context (GTK_GL_AREA (widget));
- if (!gdk_gl_context_is_legacy (context))
+ if (gdk_gl_context_get_use_es (context))
{
- vertex = vertex_shader_code_330;
- fragment = fragment_shader_code_330;
+ vertex = vertex_shader_code_gles;
+ fragment = fragment_shader_code_gles;
}
else
{
- vertex = vertex_shader_code_legacy;
- fragment = fragment_shader_code_legacy;
+ if (!gdk_gl_context_is_legacy (context))
+ {
+ vertex = vertex_shader_code_330;
+ fragment = fragment_shader_code_330;
+ }
+ else
+ {
+ vertex = vertex_shader_code_legacy;
+ fragment = fragment_shader_code_legacy;
+ }
}
init_buffers (&position_buffer, NULL);