From 7677c95fa7122e38ec8739aa4ea105be260135dd Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 14 Apr 2020 04:05:36 +1000 Subject: [PATCH] dep/imgui: Fix crash when base vertex unsupported (GLES) --- dep/imgui/src/imgui_impl_opengl3.cpp | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/dep/imgui/src/imgui_impl_opengl3.cpp b/dep/imgui/src/imgui_impl_opengl3.cpp index d62280749..165e7ca9c 100644 --- a/dep/imgui/src/imgui_impl_opengl3.cpp +++ b/dep/imgui/src/imgui_impl_opengl3.cpp @@ -79,25 +79,9 @@ #include "TargetConditionals.h" #endif -// Auto-detect GL version -#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) -#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__)) -#define IMGUI_IMPL_OPENGL_ES2 -#elif defined(__EMSCRIPTEN__) -#define IMGUI_IMPL_OPENGL_ES2 -#endif -#endif - // GL includes #include -// Desktop GL has glDrawElementsBaseVertex() which GL ES and WebGL don't have. -#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) -#define IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX 0 -#else -#define IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX 1 -#endif - // OpenGL Data static char g_GlslVersionString[32] = ""; static GLuint g_FontTexture = 0; @@ -318,11 +302,11 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data) // Bind texture, Draw glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId); -#if IMGUI_IMPL_OPENGL_HAS_DRAW_WITH_BASE_VERTEX - 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 - glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx))); -#endif + + if (!g_IsGLES) + 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 + glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx))); } } }