From b6dab97d08f5861b862867332bb67e319609f912 Mon Sep 17 00:00:00 2001 From: jackun Date: Thu, 1 Jul 2021 17:56:01 +0300 Subject: [PATCH] [OpenGL] Some code clean-ups --- src/gl/imgui_hud.cpp | 5 ----- src/gl/imgui_impl_opengl3.cpp | 15 ++++----------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/gl/imgui_hud.cpp b/src/gl/imgui_hud.cpp index 2ba940e6..bf95945e 100644 --- a/src/gl/imgui_hud.cpp +++ b/src/gl/imgui_hud.cpp @@ -158,11 +158,6 @@ void imgui_create(void *ctx) ImGui::GetIO().DisplaySize = ImVec2(last_vp[2], last_vp[3]); ImGui_ImplOpenGL3_Init(); - // Make a dummy GL call (we don't actually need the result) - // IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code. - // Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above. - GLint current_texture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); create_fonts(params, sw_stats.font1, sw_stats.font_text); sw_stats.font_params_hash = params.font_params_hash; diff --git a/src/gl/imgui_impl_opengl3.cpp b/src/gl/imgui_impl_opengl3.cpp index c1729ddc..1a1c7347 100644 --- a/src/gl/imgui_impl_opengl3.cpp +++ b/src/gl/imgui_impl_opengl3.cpp @@ -78,13 +78,6 @@ namespace MangoHud { namespace GL { extern overlay_params params; -// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have. -#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2) -#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 0 -#else -#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 1 -#endif - // OpenGL Data static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries. static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings. @@ -400,8 +393,8 @@ void GetOpenGLVersion(int& major, int& minor, bool& isGLES) if (!version) return; - //if (glGetError() == 0x500) { - + //if (glGetError() == 0x500) + { for (int i = 0; prefixes[i]; i++) { const size_t length = strlen(prefixes[i]); if (strncmp(version, prefixes[i], length) == 0) { @@ -412,7 +405,7 @@ void GetOpenGLVersion(int& major, int& minor, bool& isGLES) } sscanf(version, "%d.%d", &major, &minor); - //} + } } bool ImGui_ImplOpenGL3_Init(const char* glsl_version) @@ -454,7 +447,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) ImGuiIO& io = ImGui::GetIO(); io.BackendRendererName = "imgui_impl_opengl3"; //#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET - if ((!g_IsGLES && g_GlVersion >= 320) || (g_IsGLES && g_GlVersion >= 320)) + if (g_GlVersion >= 320) // GL/GLES 3.2+ io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. // Store GLSL version string so we can refer to it later in case we recreate shaders.