Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error in example if IMGUI_IMPL_OPENGL_LOADER_GLAD is defined #2180

Closed
doug-moen opened this issue Nov 9, 2018 · 1 comment
Closed

Comments

@doug-moen
Copy link

Version/Branch of Dear ImGui:

Version 1.65 :

Back-end file/Renderer/OS: (or specify if you are using a custom engine back-end)

Back-ends: imgui_impl_opengl3.cpp, imgui_impl_glfw.cpp
OS: Ubuntu 16.04
Compiler: gcc 5.4.0

My Issue/Question: (please provide context)

examples/example_glfw_opengl3/main.cpp fails to run
if IMGUI_IMPL_OPENGL_LOADER_GLAD is defined.
The problem is here:

#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
    bool err = gladLoadGL() != 0;
#endif
    if (err)
    {
        fprintf(stderr, "Failed to initialize OpenGL loader!\n");
        return 1;
    }

gladLoadGL() returns 0 on error, and non-zero on success.
So the error condition is inverted.
The fix is:

    bool err = gladLoadGL() == 0;
@ocornut
Copy link
Owner

ocornut commented Nov 9, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants