render: Flip textures in case of inverted_y
This commit is contained in:
parent
6c7e1c867c
commit
2d0db16942
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);"
|
||||
" if (invert_y) {"
|
||||
" v_texcoord = vec2(texcoord.s, 1.0 - texcoord.t);"
|
||||
" } else {"
|
||||
" v_texcoord = texcoord;"
|
||||
" }"
|
||||
"}";
|
||||
|
||||
const GLchar fragment_src_rgba[] =
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue