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

Regressed since 459de65
See ocornut#3530
  • Loading branch information
grauw committed Feb 9, 2023
1 parent 85395b7 commit baa49c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backends/imgui_impl_opengl3_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,13 @@ static int parse_version(void)
return GL3W_ERROR_INIT;
glGetIntegerv(GL_MAJOR_VERSION, &version.major);
glGetIntegerv(GL_MINOR_VERSION, &version.minor);
if (version.major < 3)
if (version.major == 0 && version.minor == 0)
{
// Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
const char* gl_version = (const char*)glGetString(GL_VERSION);
sscanf(gl_version, "%d.%d", &version.major, &version.minor);
}
if (version.major < 2)
return GL3W_ERROR_OPENGL_VERSION;
return GL3W_OK;
}
Expand Down

0 comments on commit baa49c9

Please sign in to comment.