Skip to content

Commit

Permalink
Backends: OpenGL3: Add compatibility of GL_VERSION for GL 2.x
Browse files Browse the repository at this point in the history
GL_MAJOR_VERSION and GL_MINOR_VERSION are available on GL 3.0 and above. So we have to parse GL_VERSION under GL 2.x
  • Loading branch information
xndcn authored Oct 15, 2020
1 parent f2f3260 commit bfa0bf6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion backends/imgui_impl_opengl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,16 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
{
// Query for GL version (e.g. 320 for GL 3.2)
#if !defined(IMGUI_IMPL_OPENGL_ES2)
GLint major, minor;
GLint major = 0, minor = 0;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
if (major == 0 && minor == 0)
{
// Query GL_STRING in desktop GL 2.x, the string will start with "<major>.<minor>"
const GLubyte* version = glGetString(GL_VERSION);
major = version[0] - '0';
minor = version[2] - '0';
}
g_GlVersion = (GLuint)(major * 100 + minor * 10);
#else
g_GlVersion = 200; // GLES 2
Expand Down

0 comments on commit bfa0bf6

Please sign in to comment.