aboutsummaryrefslogtreecommitdiff
path: root/render/gles2
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2018-03-07 15:41:12 +0100
committerGuido Günther <agx@sigxcpu.org>2018-03-11 19:02:05 +0100
commit2d0db169422b74e5ef7c07965c376273c7bb2961 (patch)
tree7d54fbec55991134320b8dd552c84d8c8e54cbe9 /render/gles2
parent6c7e1c867caf5c9a7c1046273f22b01cda30f034 (diff)
render: Flip textures in case of inverted_y
Diffstat (limited to 'render/gles2')
-rw-r--r--render/gles2/renderer.c3
-rw-r--r--render/gles2/shaders.c7
-rw-r--r--render/gles2/texture.c1
3 files changed, 9 insertions, 2 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index ad739cf8..ba03f599 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -179,7 +179,8 @@ static bool wlr_gles2_render_texture(struct wlr_renderer *wlr_renderer,
wlr_texture_bind(texture);
GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
- GL_CALL(glUniform1f(2, alpha));
+ GL_CALL(glUniform1i(1, texture->inverted_y));
+ GL_CALL(glUniform1f(3, alpha));
draw_quad();
return true;
}
diff --git a/render/gles2/shaders.c b/render/gles2/shaders.c
index 46a10248..38c61f9c 100644
--- a/render/gles2/shaders.c
+++ b/render/gles2/shaders.c
@@ -50,6 +50,7 @@ const GLchar ellipse_fragment_src[] =
// Textured quads
const GLchar vertex_src[] =
"uniform mat4 proj;"
+"uniform bool invert_y;"
"attribute vec2 pos;"
"attribute vec2 texcoord;"
"varying vec2 v_texcoord;"
@@ -69,7 +70,11 @@ const GLchar vertex_src[] =
"}"
"void main() {"
" gl_Position = transpose(proj) * vec4(pos, 0.0, 1.0);"
-" v_texcoord = texcoord;"
+" if (invert_y) {"
+" v_texcoord = vec2(texcoord.s, 1.0 - texcoord.t);"
+" } else {"
+" v_texcoord = texcoord;"
+" }"
"}";
const GLchar fragment_src_rgba[] =
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 241b94a8..d25d1809 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -164,6 +164,7 @@ static bool gles2_texture_upload_drm(struct wlr_texture *_tex,
EGLint inverted_y;
wlr_egl_query_buffer(tex->egl, buf, EGL_WAYLAND_Y_INVERTED_WL, &inverted_y);
+ tex->wlr_texture.inverted_y = !!inverted_y;
GLenum target;
const struct pixel_format *pf;