From 555c792c7f5d534dab0c0be3a323a6e37d7ccb4d Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 29 Apr 2021 11:37:18 -0400
Subject: [PATCH] Reset the GL viewport and scissor when setting up logical
OpenGL scaling.
Otherwise it ends up at a tiny number from the test GL context SDL2 creates,
if the app otherwise doesn't set it.
---
src/SDL12_compat.c | 2 ++
src/SDL20_syms.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 3f9f7c1..09f9fb2 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -3232,6 +3232,8 @@ InitializeOpenGLScaling(const int w, const int h)
return SDL_FALSE;
}
+ OpenGLFuncs.glViewport(0, 0, w, h);
+ OpenGLFuncs.glScissor(0, 0, w, h);
OpenGLLogicalScalingWidth = w;
OpenGLLogicalScalingHeight = h;
OpenGLFuncs.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
diff --git a/src/SDL20_syms.h b/src/SDL20_syms.h
index 64b61b3..5380446 100644
--- a/src/SDL20_syms.h
+++ b/src/SDL20_syms.h
@@ -300,6 +300,8 @@ OPENGL_SYM(Core,void,glEnable,(GLenum a),(a),)
OPENGL_SYM(Core,void,glDisable,(GLenum a),(a),)
OPENGL_SYM(Core,void,glGetFloatv,(GLenum a, GLfloat *b),(a,b),)
OPENGL_SYM(Core,void,glClearColor,(GLfloat a,GLfloat b,GLfloat c,GLfloat d),(a,b,c,d),)
+OPENGL_SYM(Core,void,glViewport,(GLint a, GLint b, GLsizei c, GLsizei d),(a,b,c,d),)
+OPENGL_SYM(Core,void,glScissor,(GLint a, GLint b, GLsizei c, GLsizei d),(a,b,c,d),)
OPENGL_EXT(GL_ARB_framebuffer_object)
OPENGL_SYM(GL_ARB_framebuffer_object,void,glBindRenderbuffer,(GLenum a, GLuint b),(a,b),)