Problem displaying both Imgui and Scene at the same time


I’m using Freeglut with OpenGL3.

When i setup imgui my previous scene is not rendered anymore but imgui demo widget is shown.
I’ve pretty much followed the opengl2 with freeglut example but adapted it to opengl3 meaning:

these after glut setup

these after glutmainloop

and my display function is:
clear screen
static float f = 0.0f;
static int counter = 0;
ImGui::Begin(“Hello, world!”);
ImGui::Text(“This is some useful text.”);
ImGui::Text(“Application average %.3f ms/frame (%.1f FPS)”, 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
use shader program (vertex+fragment)
send necessary uniforms
draw hierarchy scene using vaos

What am i missing?
I want to use imgui as an overlay over the scene.
The imgui setup also overwrites my input listeners that are done in glut setup:



You are not providing enough information. The problem is related to your actual scene drawing code.

If ImGui_ImplOpenGL3_RenderDrawData() is conflicting with state that you expect to carry over multiple frames, try to comment out parts of ImGui_ImplOpenGL3_RenderDrawData until you find which state is affected. It may be possible to improve it to save/restore more state.


I should have said more clearly that after the setup itself my scene is no longer rendered.
Imgui’s render draw data is not the culprit.

EDIT: ImGui_ImplFreeGLUT_InstallFuncs this was the culprit it overwrites my callbacks that i have in glut setup.


Unfortunately Glut doesn’t allow to read the old callback so we can’t automatically forward the calls to your already registered callbacks.

Don’t call ImGui_ImplFreeGLUT_InstallFuncs() and call the individual callbacks yourself.

Or, to put it bluntly, you really should not use GLUT in 2019. This is library designed in 1994 and by any criteria it is a little absurd to use Glut today when you can use GLFW or SDL.


Lesson learned about glut.
It was’t my choice however. It was given to us as starting code to build upon.
I made workaround so that when i press tilde it would draw imgui and switch input calls to imgui’s functions. Then when i press tilde again it reverts to my own functions.

Anyway i’m not sure how this discussion site works, but i guess you can close this topic now that there is no longer an issue?


It was given to us as starting code to build upon.

Whoever did that is ill informed and should probably be suggested to reevaluate their tool.
I mostly added a freeglut back-end as part of a my mildly obsessive stance to suggest that dear imgui can work everywhere.

No need to close anything this is regular forum afaik.

Good luck!