|
@@ -13,6 +13,7 @@
|
|
|
|
|
|
// CHANGELOG
|
|
// CHANGELOG
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
|
+// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
|
|
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
|
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
|
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
|
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
|
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
|
|
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
|
|
@@ -141,7 +142,7 @@ using namespace gl;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// OpenGL Data
|
|
// OpenGL Data
|
|
-static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries.
|
|
|
|
|
|
+static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
|
|
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
|
|
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
|
|
static GLuint g_FontTexture = 0;
|
|
static GLuint g_FontTexture = 0;
|
|
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
|
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
|
@@ -152,21 +153,21 @@ static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
|
|
// Functions
|
|
// Functions
|
|
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|
{
|
|
{
|
|
- // Query for GL version
|
|
|
|
|
|
+ // Query for GL version (e.g. 320 for GL 3.2)
|
|
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
|
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
|
GLint major, minor;
|
|
GLint major, minor;
|
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
|
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
|
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
|
- g_GlVersion = major * 1000 + minor;
|
|
|
|
|
|
+ g_GlVersion = major * 100 + minor * 10;
|
|
#else
|
|
#else
|
|
- g_GlVersion = 2000; // GLES 2
|
|
|
|
|
|
+ g_GlVersion = 200; // GLES 2
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// Setup back-end capabilities flags
|
|
// Setup back-end capabilities flags
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
io.BackendRendererName = "imgui_impl_opengl3";
|
|
io.BackendRendererName = "imgui_impl_opengl3";
|
|
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
|
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
|
- if (g_GlVersion >= 3200)
|
|
|
|
|
|
+ if (g_GlVersion >= 320)
|
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -378,7 +379,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|
// Bind texture, Draw
|
|
// Bind texture, Draw
|
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
|
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
|
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
|
- if (g_GlVersion >= 3200)
|
|
|
|
|
|
+ if (g_GlVersion >= 320)
|
|
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
|
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
|
else
|
|
else
|
|
#endif
|
|
#endif
|