aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/render.h1
-rw-r--r--render/gles2/renderer.c3
-rw-r--r--render/gles2/shaders.c7
-rw-r--r--render/gles2/texture.c1
4 files changed, 10 insertions, 2 deletions
diff --git a/include/wlr/render.h b/include/wlr/render.h
index 747603da..77449556 100644
--- a/include/wlr/render.h
+++ b/include/wlr/render.h
@@ -85,6 +85,7 @@ struct wlr_texture {
bool valid;
uint32_t format;
int width, height;
+ bool inverted_y;
struct wl_signal destroy_signal;
struct wl_resource *resource;
};
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;