Commit 8bb4eb55 authored by Emmanuele Bassi's avatar Emmanuele Bassi

gdk: Add GLES shaders

We cannot use GL shaders with GLES.
parent 3da73371
......@@ -468,7 +468,9 @@ glsl_sources = \
resources/glsl/gl2-texture-2d.fs.glsl \
resources/glsl/gl2-texture-2d.fs.glsl \
resources/glsl/gl2-texture-rect.vs.glsl \
resources/glsl/gl2-texture-rect.vs.glsl
resources/glsl/gl2-texture-rect.vs.glsl \
resources/glsl/gles2-texture.fs.glsl \
resources/glsl/gles2-texture.vs.glsl
EXTRA_DIST += $(glsl_sources)
CLEANFILES += gdk.gresource.xml
......
......@@ -151,6 +151,21 @@ bind_vao (GdkGLContextPaintData *paint_data)
}
}
static void
use_texture_gles_program (GdkGLContextPaintData *paint_data)
{
if (paint_data->texture_2d_quad_program.program == 0)
make_program (&paint_data->texture_2d_quad_program,
"/org/gtk/libgdk/glsl/gles2-texture.vs.glsl",
"/org/gtk/libgdk/glsl/gles2-texture.fs.glsl");
if (paint_data->current_program != &paint_data->texture_2d_quad_program)
{
paint_data->current_program = &paint_data->texture_2d_quad_program;
glUseProgram (paint_data->current_program->program);
}
}
static void
use_texture_2d_program (GdkGLContextPaintData *paint_data)
{
......@@ -213,10 +228,15 @@ gdk_gl_texture_quads (GdkGLContext *paint_context,
if (paint_data->tmp_vertex_buffer == 0)
glGenBuffers(1, &paint_data->tmp_vertex_buffer);
if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
use_texture_rect_program (paint_data);
if (paint_data->use_es)
use_texture_gles_program (paint_data);
else
use_texture_2d_program (paint_data);
{
if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
use_texture_rect_program (paint_data);
else
use_texture_2d_program (paint_data);
}
program = paint_data->current_program;
......
precision mediump float;
uniform sampler2D map;
varying highp vec2 vUv;
void main() {
gl_FragColor = texture2D(map, vUv);
}
attribute vec2 position;
attribute vec2 uv;
varying highp vec2 vUv;
void main() {
vUv = uv;
gl_Position = vec4(position, 0.0, 1.0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment