From 553783869aaa598173558f94cdf078be4904c3c1 Mon Sep 17 00:00:00 2001 From: Bernd Busse Date: Fri, 24 Apr 2020 14:16:42 +0200 Subject: [PATCH] gl_common: Wrong viewport in `gl_average_texture_color()` Set viewport in `gl_average_texture_color()` to global `vp_width` and `vp_height` as the projection matrix has been initialized to these dimensions as well. Related: a7bd48f5abe5769cfe1966b4466c7251978c95b8 --- src/backend/gl/gl_common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index 13c5d1e..3e8f799 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -200,6 +200,8 @@ static void gl_free_prog_main(gl_win_shader_t *pprogram) { static GLuint _gl_average_texture_color(backend_t *base, GLuint source_texture, GLuint destination_texture, GLuint auxiliary_texture, GLuint fbo, int width, int height) { + auto gd = (struct gl_data *)base; + const int max_width = 1; const int max_height = 1; const int from_width = next_power_of_two(width); @@ -236,7 +238,7 @@ _gl_average_texture_color(backend_t *base, GLuint source_texture, GLuint destina glBindTexture(GL_TEXTURE_2D, source_texture); // Render into framebuffer - glViewport(0, 0, width, height); + glViewport(0, 0, gd->vp_width, gd->vp_height); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, NULL); // Have we downscaled enough?