pthom / imgui_bundle

Dear ImGui Bundle: an extensive set of Ready-to-use widgets and libraries, based on ImGui. Start your first app in 5 lines of code, or less. Whether you prefer Python or C++, this pack has your back!
https://pthom.github.io/imgui_bundle/
MIT License
590 stars 62 forks source link

glBindSampler(0, 0) is needed for OpenGL backend #195

Open gegogi opened 3 months ago

gegogi commented 3 months ago

For an app code that uses a separate Sampler scheme instead of texture-sampler bound scheme, the following code is needed as in ImGui source. Please refer to glBindSampler doc too.

image

https://docs.gl/gl3/glBindSampler

pthom commented 3 months ago

Hello.

I am quite busy these days so that I will not have time to work this in the next days. In the meantime you can compile the library by yourself and just define what is needed to get this feature.

from imgui_impl_opengl3:

// Desktop GL 3.3+ has glBindSampler()
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_3)
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
#endif

=> You need to define GL_VERSION_3_3 at compilation time.

This will not work on a mac, because of the way openGL is setup on this plaform at the present time. See src/hello_imgui/internal/backend_impls/opengl_setup_helper/opengl_setup_glfw.cpp

    void OpenGlSetupGlfw::SelectOpenGlVersion()
    {
        #if defined(IMGUI_IMPL_OPENGL_ES3)
        {
            BACKEND_THROW("OpenGlSetupGlfw::SelectOpenGlVersion needs implementation for GLES !");
            //            SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 3);
            //            SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
            //                                SDL_GL_CONTEXT_PROFILE_ES);
            //            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
            //            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
        }
        #elif defined(__APPLE__)
        {
            glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
            glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
            glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);  // 3.2+ only
            glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);            // Required on Mac
        }
        #else
        {
            // GL 3.2+
            glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
            glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
            glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);  // 3.2+ only
            glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);            // 3.0+ only
        }
        #endif
    }