gl_common: make viewport stateless

Also call glViewport before a draw call.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2020-03-17 18:02:53 +00:00
parent d9b407c6b4
commit cf3e95f0a4
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 4 additions and 1 deletions

View File

@ -207,6 +207,8 @@ _gl_average_texture_color(backend_t *base, GLuint source_texture, GLuint destina
const int to_width = from_width > max_width ? from_width / 2 : from_width;
const int to_height = from_height > max_height ? from_height / 2 : from_height;
glViewport(0, 0, width, height);
// Prepare coordinates
GLint coord[] = {
// top left
@ -395,6 +397,7 @@ static void _gl_compose(backend_t *base, struct gl_image *img, GLuint target,
// x, y, width, height, dx, dy, ptex->width, ptex->height, z);
// Bind texture
glViewport(0, 0, gd->width, gd->height);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, brightness);
glActiveTexture(GL_TEXTURE0);
@ -778,7 +781,6 @@ static int gl_win_shader_from_string(const char *vshader_str, const char *fshade
* Callback to run on root window size change.
*/
void gl_resize(struct gl_data *gd, int width, int height) {
glViewport(0, 0, width, height);
gd->height = height;
gd->width = width;
@ -1395,6 +1397,7 @@ void gl_present(backend_t *base, const region_t *region) {
sizeof(GLuint) * 6);
}
glViewport(0, 0, gd->width, gd->height);
glUseProgram(gd->present_prog);
glBindTexture(GL_TEXTURE_2D, gd->back_texture);