From 839b2116df12523446f3a257f471ae6d1eb29c70 Mon Sep 17 00:00:00 2001 From: milek7 Date: Fri, 22 Jan 2021 02:36:49 +0100 Subject: [PATCH] fixes in imgui gl2 interaction with renderers --- application.cpp | 8 ++++++++ imgui/imgui_impl_opengl2.cpp | 2 -- opengl33renderer.cpp | 11 ++++++++++- openglrenderer.cpp | 3 +++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/application.cpp b/application.cpp index d1b87e2b..35b57fc0 100644 --- a/application.cpp +++ b/application.cpp @@ -782,6 +782,10 @@ eu07_application::init_glfw() { glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 ); } else { +#ifdef EU07_USEIMGUIIMPLOPENGL2 + ErrorLog("gles not supported in imgui gl2 build"); + return -1; +#endif #ifdef GLFW_CONTEXT_CREATION_API if (m_glfwversion >= 30200) glfwWindowHint( GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API ); @@ -791,6 +795,10 @@ eu07_application::init_glfw() { glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 0 ); } } else { + if (Global.gfx_usegles) { + ErrorLog("legacy renderer not supported in gles mode"); + return -1; + } Global.gfx_shadergamma = false; glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE ); glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 0 ); diff --git a/imgui/imgui_impl_opengl2.cpp b/imgui/imgui_impl_opengl2.cpp index 90521b1b..8bb303ac 100644 --- a/imgui/imgui_impl_opengl2.cpp +++ b/imgui/imgui_impl_opengl2.cpp @@ -124,8 +124,6 @@ void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data) const ImDrawList* cmd_list = draw_data->CmdLists[n]; const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos))); glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv))); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col))); diff --git a/opengl33renderer.cpp b/opengl33renderer.cpp index fa0bd5fc..91b78b90 100644 --- a/opengl33renderer.cpp +++ b/opengl33renderer.cpp @@ -670,8 +670,13 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode) gl::framebuffer::unbind(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - if (vp.main) + if (vp.main) { + // clear state for ui + gl::vao::unbind(); + gl::buffer::unbind(); + gl::program::unbind(); Application.render_ui(); + } break; } @@ -938,6 +943,10 @@ void opengl33_renderer::Render_pass(viewport_config &vp, rendermode const Mode) Timer::subsystem.gfx_gui.start(); if (vp.main) { + // clear state for ui + gl::vao::unbind(); + gl::buffer::unbind(); + gl::program::unbind(); draw_debug_ui(); Application.render_ui(); } diff --git a/openglrenderer.cpp b/openglrenderer.cpp index 1b8859ad..a6acb243 100644 --- a/openglrenderer.cpp +++ b/openglrenderer.cpp @@ -339,6 +339,9 @@ opengl_renderer::Render() { setup_units( true, false, false ); ::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); ::glClientActiveTexture( GL_TEXTURE0 + m_diffusetextureunit ); + + // clear state for ui + ::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); ::glBindBuffer( GL_ARRAY_BUFFER, 0 ); Application.render_ui(); ::glPopClientAttrib();