mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
gsk: Port GskGLRenderer to GLES
Use the appropriate API and shaders if the GdkGLContext was created for OpenGL ES instead of OpenGL.
This commit is contained in:
parent
5909ce6897
commit
9d3ca22b4c
@ -160,7 +160,11 @@ gsk_gl_renderer_allocate_buffers (GskGLRenderer *self,
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
if (gdk_gl_context_get_use_es (self->context))
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
else
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
}
|
||||
|
||||
if (self->render_buffer != 0)
|
||||
@ -302,8 +306,16 @@ gsk_gl_renderer_create_program (GskGLRenderer *self)
|
||||
GBytes *source;
|
||||
int status;
|
||||
|
||||
vs_path = "/org/gtk/libgsk/glsl/gl3-base.vs.glsl";
|
||||
fs_path = "/org/gtk/libgsk/glsl/gl3-base.fs.glsl";
|
||||
if (gdk_gl_context_get_use_es (self->context))
|
||||
{
|
||||
vs_path = "/org/gtk/libgsk/glsl/gles-base.vs.glsl";
|
||||
fs_path = "/org/gtk/libgsk/glsl/gles-base.fs.glsl";
|
||||
}
|
||||
else
|
||||
{
|
||||
vs_path = "/org/gtk/libgsk/glsl/gl3-base.vs.glsl";
|
||||
fs_path = "/org/gtk/libgsk/glsl/gl3-base.fs.glsl";
|
||||
}
|
||||
|
||||
GSK_NOTE (OPENGL, g_print ("Compiling vertex shader\n"));
|
||||
source = g_resources_lookup_data (vs_path, 0, NULL);
|
||||
|
11
gsk/resources/glsl/gles-base.fs.glsl
Normal file
11
gsk/resources/glsl/gles-base.fs.glsl
Normal file
@ -0,0 +1,11 @@
|
||||
precision mediump float;
|
||||
|
||||
uniform mat4 mvp;
|
||||
uniform sampler2D map;
|
||||
uniform float alpha;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(map, vUv) * vec4(alpha);
|
||||
}
|
12
gsk/resources/glsl/gles-base.vs.glsl
Normal file
12
gsk/resources/glsl/gles-base.vs.glsl
Normal file
@ -0,0 +1,12 @@
|
||||
uniform mat4 mvp;
|
||||
|
||||
attribute vec2 position;
|
||||
attribute vec2 uv;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
gl_Position = mvp * vec4(position, 0.0, 1.0);
|
||||
|
||||
vUv = vec2(uv.x, 1.0 - uv.y);
|
||||
}
|
Loading…
Reference in New Issue
Block a user