pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
678 stars 103 forks source link

GL version #36

Closed nick-0 closed 1 year ago

nick-0 commented 1 year ago

Running the imgui_example_glfw_opengl3.py demo, when I print: print(GL.glGetString(GL.GL_VERSION)) I get 4.6.0 NVIDIA... But, when I run any immapp or hello_imgui demo, I get: 3.3.0 NVIDIA...

I would like to use immap, but how would I use the latest OpenGL on my machine?

Thanks, Nick

pthom commented 1 year ago

Hum. I cannot reproduce your issue on any of the machines I tried (I tried on Mac M1, Linux and Windows VMs).

However, I have a possible solution, and I would like to know if it helps on your side.

You will need to install from source: see instructions here

Then, edit:

imgui_bundle/external/hello_imgui/hello_imgui/src/hello_imgui/internal/backend_impls/opengl_setup_helper/opengl_setup_glfw.cpp

And modify this function:


    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
        {

//                EDIT THE LINES BELOW

            // 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
    }

After this run pip install -v .

I'd be interested in knowing if this changes anything for you.


By the way, which OS are you using?

nick-0 commented 1 year ago

I am on Windows 10. My current installation of imgui-bundle is from pypi. I will make the changes and let you know, thanks!

nick-0 commented 1 year ago

I commented out all glfw hints and I am now getting 4.6.0, thank you.

        {
            // 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

Windows 10 Python 3.10