all repos — mgba @ a637ac256da54e31fc6a934c0d0394dea356640c

mGBA Game Boy Advance Emulator

Qt: Fix OpenGL 2.1 support (fixes #1678)
Vicki Pfau vi@endrift.com
Fri, 28 Feb 2020 18:27:13 -0800
commit

a637ac256da54e31fc6a934c0d0394dea356640c

parent

cd6209d7f07cbbc881e647c536cac50291222552

2 files changed, 10 insertions(+), 4 deletions(-)

jump to
M CHANGESCHANGES

@@ -22,6 +22,7 @@ - Core: Fix crash modifying hash table entry (fixes mgba.io/i/1673)

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

@@ -21,6 +21,9 @@ static const GLchar* const _gles2Header =

"#version 100\n" "precision mediump float;\n"; +static const GLchar* const _gl2Header = + "#version 120\n"; + static const GLchar* const _gl32VHeader = "#version 150 core\n" "#define attribute in\n"

@@ -462,10 +465,12 @@ shader->vertexShader = glCreateShader(GL_VERTEX_SHADER);

shader->fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); const GLchar* shaderBuffer[2]; const GLubyte* version = glGetString(GL_VERSION); - if (strncmp((const char*) version, "OpenGL ES ", strlen("OpenGL ES "))) { - shaderBuffer[0] = _gl32VHeader; - } else { + if (strncmp((const char*) version, "OpenGL ES ", strlen("OpenGL ES ")) == 0) { shaderBuffer[0] = _gles2Header; + } else if (version[0] == '2') { + shaderBuffer[0] = _gl2Header; + } else { + shaderBuffer[0] = _gl32VHeader; } if (vs) { shaderBuffer[1] = vs;

@@ -474,7 +479,7 @@ shaderBuffer[1] = _nullVertexShader;

} glShaderSource(shader->vertexShader, 2, shaderBuffer, 0); - if (strncmp((const char*) version, "OpenGL ES ", strlen("OpenGL ES "))) { + if (shaderBuffer[0] == _gl32VHeader) { shaderBuffer[0] = _gl32FHeader; } if (fs) {