Skip to content

The ImGui Window doesn't respond at all #8507

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

Open
tohar777 opened this issue Mar 21, 2025 · 6 comments
Open

The ImGui Window doesn't respond at all #8507

tohar777 opened this issue Mar 21, 2025 · 6 comments
Labels

Comments

@tohar777
Copy link

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

@ocornut
Copy link
Owner

ocornut commented Mar 21, 2025

Please describe your problem. You are not describing the problem.

@GamingMinds-DanielC
Copy link
Contributor

GamingMinds-DanielC commented Mar 21, 2025

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_InitForOpenGL to 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.

@ocornut
Copy link
Owner

ocornut commented Mar 21, 2025

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.

@tohar777
Copy link
Author

I meant that ImGui wasn't responding to anything and it respond only if I changed the window size(not in code)

@kingofknights
Copy link

Hi,
If you could upload a GIF, demonstrating your problem.

@JanPschwietzer
Copy link

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.

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

No branches or pull requests

5 participants