ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
60.67k stars 10.25k forks source link

"Failed to initialize OpenGL Loader!" After properly initializing opengl functions #7747

Closed pinkoboio closed 3 months ago

pinkoboio commented 3 months ago

Version/Branch of Dear ImGui:

Version 1.90, Branch: master

Back-ends:

imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp

Compiler, OS:

g++, NixOS 23.11

Full config/build information:

No response

Details:

Why does this code result in a "Failed to initialize OpenGL Loader!" error?

I have a very basic opengl program, it uses opengl version 3.0 and before adding imgui everything worked perfectly fine. I added the following code to my program to initialize imgui:

IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
ImGui_ImplGlfw_InitForOpenGL(Graphics::window, true);
ImGui_ImplOpenGL3_Init();

and I also added the following code to the end of my application loop:

ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGui::ShowDemoWindow();

When I run the program I get the following output:

Failed to initialize OpenGL loader!
zsh: segmentation fault (core dumped)

I've looked online to see if others have encountered this issue, and I've found two issues that most closely resemble mine. The first poster forgot to initialize glad before they called ImGui_ImplOpenGL3_Init() and the second poster's hardware just had dodgy opengl3 support. Thing is I know my hardware is opengl3 compatible, I've been working on this opengl program for a while and never experienced any difficulty with opengl compatibility.

My initial thought of what could be causing the issue would be the fact that I'm running NixOS, and the fact that NixOS doesn't adhere to the filesystem standard.(?) That seems like a stretch though, I don't truly know what could be causing my problem at this point. I was hoping to be able to depend on ImGUI to move forward with the development of my project, so any amount of guidance would be appreciated.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

ocornut commented 3 months ago

We made a fix in 1.90.6 which may be the fix for you: #7562 Commit 0d483a1c89f6cafe61db858e490c472ee8063542

pinkoboio commented 3 months ago

That commit did fix my issue, ImGui works as expected now. I'll close this issue now, thanks :]