runtime error in example if IMGUI_IMPL_OPENGL_LOADER_GLAD is defined #2180

Closed
opened 2018-11-09 21:34:17 +00:00 by doug-moen · 1 comment
doug-moen commented 2018-11-09 21:34:17 +00:00 (Migrated from github.com)

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;
**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 commented 2018-11-09 21:40:10 +00:00 (Migrated from github.com)

This was already fixed in master.
Duplicate of #2157

This was already fixed in master. Duplicate of #2157
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#2180
No description provided.