The ImGui Window doesn't respond at all
Version/Branch of Dear ImGui:
Lastest
Back-ends:
imgui_impl_glfw3.cpp + imgui_impl_opengl2.cpp
Compiler, OS:
Arch GCC CodeBlocks
Full config/build information:
No response
Details:
The ImGui Window doesn't respond at all
I'm trying to fix this like for 2 hours I even used chatgpt to fix the issue but nothing work
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
#include <iostream>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GLFW/glfw3.h>
#include "imgui/imgui.h"
#include "imgui/imgui_impl_glfw.h"
#include "imgui/imgui_impl_opengl2.h"
using namespace std;
int main()
{
// Initialize GLFW
if (!glfwInit()) {
cout << "Failed to initialize GLFW!" << endl;
return -1;
}
// Set OpenGL version to 2.x
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
// Create GLFW window
GLFWwindow* window = glfwCreateWindow(800, 600, "LightMX", nullptr, nullptr);
if (!window) {
cout << "Failed to create GLFW window!" << endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Initialize GLEW (must be done after creating the context)
glewInit();
// Initialize ImGui
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL2_Init();
// Input callback setup
glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
glfwSetCursorPosCallback(window, ImGui_ImplGlfw_CursorPosCallback);
glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
while (!glfwWindowShouldClose(window)) {
// Poll events
glfwPollEvents();
// Start new ImGui frame
ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
// Render ImGui UI
ImGui::Begin("Hello, ImGui!");
ImGui::Text("This is ImGui rendered with OpenGL 2.x");
if (ImGui::Button("Exit")) {
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
ImGui::End();
// Clear OpenGL screen
glClearColor(0.45f, 0.55f, 0.60f, 1.00f);
glClear(GL_COLOR_BUFFER_BIT);
// Render ImGui
ImGui::Render();
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
// Swap buffers
glfwSwapBuffers(window);
}
// Cleanup
ImGui_ImplOpenGL2_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwTerminate();
return0;
}
heres the full code
Please describe your problem. You are not describing the problem.
How long you tried to fix it doesn't tell us anything about what you tried, statements like "nothing worked" are also quite unspecific.
Without testing your code, two things that seem suspicious:
- You are instructing
ImGui_ImplGlfw_InitForOpenGLto install callbacks, then you are setting some callbacks yourself, even the default callbacks. This is redundant at best and not part of the example code. Why did you add those? - Your full code ends with a
return0, that shouldn't even compile. That is a strong indicator that your posted code is not the one you actually are working with.
Start with the example code from here: examples/example_glfw_opengl2/main.cpp
Does that work on your system? If not, something might be wrong with your setup. Otherwise, change it step by step to your needs while testing every step.
I couldn't see the problem when looking at the code (except for the fact you are using extremely old OpenGL context version) so I copied your code and it worked here. So please be more specific.
I meant that ImGui wasn't responding to anything and it respond only if I changed the window size(not in code)
Hi, If you could upload a GIF, demonstrating your problem.
If your issue is about problems you are facing in your Open Engine project, you are using some of the functions wrong as I can see but your window is responding at least when I build it. Try using a debugger and see for yourself for example what happenes when you click the github button.