diff --git a/include/render.h b/include/render.h index f61b764..4175cb4 100644 --- a/include/render.h +++ b/include/render.h @@ -40,6 +40,7 @@ struct renderer { struct { GLuint program; GLint u_tex; + GLint u_proj; } shader; }; diff --git a/shaders/dmabuf-vertex.glsl b/shaders/dmabuf-vertex.glsl index 9b83f34..56cef09 100644 --- a/shaders/dmabuf-vertex.glsl +++ b/shaders/dmabuf-vertex.glsl @@ -1,3 +1,5 @@ +uniform mat2 u_proj; + attribute vec2 pos; attribute vec2 texture; @@ -6,5 +8,5 @@ varying vec2 v_texture; void main() { v_texture = vec2(texture.s, 1.0 - texture.t); - gl_Position = vec4(pos, 0, 1); + gl_Position = vec4(u_proj * pos, 0, 1); } diff --git a/shaders/texture-vertex.glsl b/shaders/texture-vertex.glsl index c43764f..020f11a 100644 --- a/shaders/texture-vertex.glsl +++ b/shaders/texture-vertex.glsl @@ -1,3 +1,5 @@ +uniform mat2 u_proj; + attribute vec2 pos; attribute vec2 texture; @@ -6,5 +8,5 @@ varying vec2 v_texture; void main() { v_texture = texture; - gl_Position = vec4(pos, 0, 1); + gl_Position = vec4(u_proj * pos, 0, 1); } diff --git a/src/render.c b/src/render.c index ba37d36..55cc699 100644 --- a/src/render.c +++ b/src/render.c @@ -412,6 +412,7 @@ int renderer_init(struct renderer* self, uint32_t width, uint32_t height, } self->shader.u_tex = glGetUniformLocation(self->shader.program, "u_tex"); + self->shader.u_proj = glGetUniformLocation(self->shader.program, "u_proj"); self->width = width; self->height = height; @@ -487,7 +488,15 @@ int render_dmabuf_frame(struct renderer* self, struct dmabuf_frame* frame) glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, image); glUseProgram(self->shader.program); + glUniform1i(self->shader.u_tex, 0); + + const float proj[] = { + 1.0f, 0.0f, + 0.0f, 1.0f, + }; + glUniformMatrix2fv(self->shader.u_proj, 1, GL_FALSE, proj); + gl_render(); glBindTexture(GL_TEXTURE_2D, 0); @@ -516,7 +525,15 @@ int render_framebuffer(struct renderer* self, const void* addr, uint32_t format, glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0); glUseProgram(self->shader.program); + glUniform1i(self->shader.u_tex, 0); + + const float proj[] = { + 1.0f, 0.0f, + 0.0f, 1.0f, + }; + glUniformMatrix2fv(self->shader.u_proj, 1, GL_FALSE, proj); + gl_render(); glBindTexture(GL_TEXTURE_2D, 0);