Qt: Fix OpenGL 2.1 support (fixes #1678)

This commit is contained in:
Vicki Pfau 2020-02-28 18:27:13 -08:00
parent cd6209d7f0
commit a637ac256d
2 changed files with 10 additions and 4 deletions

View File

@ -22,6 +22,7 @@ Other fixes:
- GBA: Reject incorrectly sized BIOSes - GBA: Reject incorrectly sized BIOSes
- Debugger: Don't skip undefined instructions when debugger attached - Debugger: Don't skip undefined instructions when debugger attached
- Qt: Force OpenGL paint engine creation thread (fixes mgba.io/i/1642) - Qt: Force OpenGL paint engine creation thread (fixes mgba.io/i/1642)
- Qt: Fix OpenGL 2.1 support (fixes mgba.io/i/1678)
Misc: Misc:
- FFmpeg: Add looping option for GIF/APNG - FFmpeg: Add looping option for GIF/APNG
- Qt: Renderer can be changed while a game is running - Qt: Renderer can be changed while a game is running

View File

@ -21,6 +21,9 @@ static const GLchar* const _gles2Header =
"#version 100\n" "#version 100\n"
"precision mediump float;\n"; "precision mediump float;\n";
static const GLchar* const _gl2Header =
"#version 120\n";
static const GLchar* const _gl32VHeader = static const GLchar* const _gl32VHeader =
"#version 150 core\n" "#version 150 core\n"
"#define attribute in\n" "#define attribute in\n"
@ -462,10 +465,12 @@ void mGLES2ShaderInit(struct mGLES2Shader* shader, const char* vs, const char* f
shader->fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); shader->fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
const GLchar* shaderBuffer[2]; const GLchar* shaderBuffer[2];
const GLubyte* version = glGetString(GL_VERSION); const GLubyte* version = glGetString(GL_VERSION);
if (strncmp((const char*) version, "OpenGL ES ", strlen("OpenGL ES "))) { if (strncmp((const char*) version, "OpenGL ES ", strlen("OpenGL ES ")) == 0) {
shaderBuffer[0] = _gl32VHeader;
} else {
shaderBuffer[0] = _gles2Header; shaderBuffer[0] = _gles2Header;
} else if (version[0] == '2') {
shaderBuffer[0] = _gl2Header;
} else {
shaderBuffer[0] = _gl32VHeader;
} }
if (vs) { if (vs) {
shaderBuffer[1] = vs; shaderBuffer[1] = vs;
@ -474,7 +479,7 @@ void mGLES2ShaderInit(struct mGLES2Shader* shader, const char* vs, const char* f
} }
glShaderSource(shader->vertexShader, 2, shaderBuffer, 0); glShaderSource(shader->vertexShader, 2, shaderBuffer, 0);
if (strncmp((const char*) version, "OpenGL ES ", strlen("OpenGL ES "))) { if (shaderBuffer[0] == _gl32VHeader) {
shaderBuffer[0] = _gl32FHeader; shaderBuffer[0] = _gl32FHeader;
} }
if (fs) { if (fs) {