gdk: Add GLES shaders
We cannot use GL shaders with GLES.
This commit is contained in:
@ -468,7 +468,9 @@ glsl_sources = \
|
|||||||
resources/glsl/gl2-texture-2d.fs.glsl \
|
resources/glsl/gl2-texture-2d.fs.glsl \
|
||||||
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/gl2-texture-rect.vs.glsl \
|
||||||
|
resources/glsl/gles2-texture.fs.glsl \
|
||||||
|
resources/glsl/gles2-texture.vs.glsl
|
||||||
|
|
||||||
EXTRA_DIST += $(glsl_sources)
|
EXTRA_DIST += $(glsl_sources)
|
||||||
CLEANFILES += gdk.gresource.xml
|
CLEANFILES += gdk.gresource.xml
|
||||||
|
26
gdk/gdkgl.c
26
gdk/gdkgl.c
@ -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
|
static void
|
||||||
use_texture_2d_program (GdkGLContextPaintData *paint_data)
|
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)
|
if (paint_data->tmp_vertex_buffer == 0)
|
||||||
glGenBuffers(1, &paint_data->tmp_vertex_buffer);
|
glGenBuffers(1, &paint_data->tmp_vertex_buffer);
|
||||||
|
|
||||||
if (texture_target == GL_TEXTURE_RECTANGLE_ARB)
|
if (paint_data->use_es)
|
||||||
use_texture_rect_program (paint_data);
|
use_texture_gles_program (paint_data);
|
||||||
else
|
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;
|
program = paint_data->current_program;
|
||||||
|
|
||||||
|
9
gdk/resources/glsl/gles2-texture.fs.glsl
Normal file
9
gdk/resources/glsl/gles2-texture.fs.glsl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
uniform sampler2D map;
|
||||||
|
|
||||||
|
varying highp vec2 vUv;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_FragColor = texture2D(map, vUv);
|
||||||
|
}
|
10
gdk/resources/glsl/gles2-texture.vs.glsl
Normal file
10
gdk/resources/glsl/gles2-texture.vs.glsl
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
attribute vec2 position;
|
||||||
|
attribute vec2 uv;
|
||||||
|
|
||||||
|
varying highp vec2 vUv;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vUv = uv;
|
||||||
|
|
||||||
|
gl_Position = vec4(position, 0.0, 1.0);
|
||||||
|
}
|
Reference in New Issue
Block a user