Skip to content
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

glfw is calling imgui's callbacks but imgui is not responsive #4747

Closed
thegeeko opened this issue Nov 20, 2021 · 6 comments
Closed

glfw is calling imgui's callbacks but imgui is not responsive #4747

thegeeko opened this issue Nov 20, 2021 · 6 comments

Comments

@thegeeko
Copy link

Version/Branch of Dear ImGui:

Version: 1.86
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp (or specify if using a custom engine/back-end)
Compiler: gcc
Operating System: arch linux

My Issue/Question:

I'm trying to integrate imgui in my engine and I'm using glfw and opengl the problem is the imgui is not responsive at all .. the glfw is calling imgui's call back .. not sure what can be the problem

Screenshots/Video

https://user-images.githubusercontent.com/36560490/142741741-1c627953-5957-4f94-a3fa-8dfded275ea3.mp4
glfw is calling imgui's function

https://user-images.githubusercontent.com/36560490/142741831-832db75d-a4d4-4710-97a7-766caee9f866.mp4
imgui is not responsive at all

// how I'm initing imgui
void ImGuiLayer::onAttach() {
	ImGui::CreateContext();
	ImGuiIO& io = ImGui::GetIO();
	(void)io;
	io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;		 // Enable Keyboard Controls
	io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;		 // Enable Docking
	io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;		 // Enable Multi-Viewport / Platform Windows

	ImGui::StyleColorsDark();

	// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
	ImGuiStyle& style = ImGui::GetStyle();
	if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
		style.WindowRounding = 0.0f;
		style.Colors[ImGuiCol_WindowBg].w = 1.0f;
	}

	// Setup Platform/Renderer backends
	ImGui_ImplGlfw_InitForOpenGL(App::get().getWindow().getRawWindow(), true);
	ImGui_ImplOpenGL3_Init("#version 430");

	GEG_CORE_INFO("Im gui attached");
}
@ocornut
Copy link
Owner

ocornut commented Nov 20, 2021

Are you calling the backends _NewFrame() functions correctly and before the ImGui::NewFrame() function? Refer to the provided examples and compare your code carefully to them.

@thegeeko
Copy link
Author

yes .. and im calling them in the right order just like the example

void ImGuiLayer::begin() {
	ImGui_ImplOpenGL3_NewFrame();
	ImGui_ImplGlfw_NewFrame();
	ImGui::NewFrame();
}

void ImGuiLayer::end() {
	ImGuiIO& io = ImGui::GetIO();
	App& app = App::get();
	io.DisplaySize = ImVec2((float)app.getWindow().getWidth(), (float)app.getWindow().getHeight());

	// Rendering
	ImGui::Render();
	ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

	if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
		GLFWwindow* backup_current_context = glfwGetCurrentContext();
		ImGui::UpdatePlatformWindows();
		ImGui::RenderPlatformWindowsDefault();
		glfwMakeContextCurrent(backup_current_context);
	}
}

I have begin and end before after every imgui call

and when i start a window twice it's just fine but when i start it just one time or start another window it doesn't work the mouse effects work but it's controllable .. here a gif to show it :

Kooha-11-22-2021-15-29-51.mp4

and when i try to control using the keyboard this assert fails :

triangle: /home/thegeeko/projects/geg/geg/vendor/imgui/imgui.cpp:10328: void ImGui::NavMoveRequestApplyResult(): Assertion `g.NavTabbingResultFirst.ID != 0' failed. 

@ocornut
Copy link
Owner

ocornut commented Nov 22, 2021

and when i try to control using the keyboard this assert fails :

I think this is the recent bug we fixed on Nov 10: a9ea1ae (#4449)

@thegeeko
Copy link
Author

updated to the last commit and the assert doesn't fail anymore still can't control anything tho ..

@thegeeko
Copy link
Author

thegeeko commented Dec 16, 2021

solved the bug .. i was calling ImGui::newFrame before rendering, thanks for the help

@grazianobolla
Copy link

In the examples it is called before rendering...

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

No branches or pull requests

3 participants