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
Mouse inputs not working with GLFW backend #7481
Comments
The issue is likely in your code so it would be more adequate to post a complete project, and compare it to existing projects. |
Yes i call glfwPollEvents(), if (glfwInit() == GLFW_FALSE)
throw std::runtime_error("Failed to initialize GLFW");
m_deletionQueue.add([=]() {
glfwTerminate();
});
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
m_window = glfwCreateWindow(width, height, title, nullptr, nullptr);
if (m_window == nullptr)
throw std::runtime_error("Failed to create GLFW window");
m_deletionQueue.add([=]() {
glfwDestroyWindow(m_window);
});
glfwSetWindowUserPointer(m_window, this);
glfwSetFramebufferSizeCallback(m_window, framebufferResizeCallback);
For each frame, here is my code: glfwPollEvents();
VkCommandBufferBeginInfo beginInfo{};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
VK_CHECK(vkBeginCommandBuffer(m_commandBuffers[m_currentFrameIndex], &beginInfo));
ImGui_ImplVulkan_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
{ // Begin Rendering
Image::cmdTransitionImageLayout(
m_commandBuffers[m_currentFrameIndex],
m_depthImage->getHandle(),
VK_IMAGE_LAYOUT_UNDEFINED,
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
);
Image::cmdTransitionImageLayout(
m_commandBuffers[m_currentFrameIndex],
m_swapchain->getImage(m_currentImageIndex),
VK_IMAGE_LAYOUT_UNDEFINED,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
);
VkRenderingAttachmentInfo swapchainImageAttachment{};
swapchainImageAttachment.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
swapchainImageAttachment.imageView = m_swapchain->getImageView(m_currentImageIndex);
swapchainImageAttachment.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
swapchainImageAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
swapchainImageAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
swapchainImageAttachment.clearValue = { 0.0f, 0.0f, 0.0f, 1.0f };
VkRenderingAttachmentInfo depthAttachment{};
depthAttachment.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
depthAttachment.imageView = m_depthImage->getImageView();
depthAttachment.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
depthAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
depthAttachment.clearValue = { 1.0f, 0 };
VkRenderingInfo renderingInfo{};
renderingInfo.sType = VK_STRUCTURE_TYPE_RENDERING_INFO;
renderingInfo.renderArea.offset = {0, 0};
renderingInfo.renderArea.extent = m_swapchain->getSwapChainExtent();
renderingInfo.layerCount = 1;
renderingInfo.colorAttachmentCount = 1;
renderingInfo.pColorAttachments = &swapchainImageAttachment;
renderingInfo.pDepthAttachment = &depthAttachment;
renderingInfo.pStencilAttachment = nullptr;
vkCmdBeginRendering(m_commandBuffers[m_currentFrameIndex], &renderingInfo);
}
// Draw scene
ImGui::ShowDemoWindow();
ImGui::Render();
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), m_commandBuffers[m_currentFrameIndex]);
vkCmdEndRendering(m_commandBuffers[m_currentFrameIndex]);
Image::cmdTransitionImageLayout(
m_commandBuffers[m_currentFrameIndex],
m_swapchain->getImage(m_currentImageIndex),
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
);
VK_CHECK(vkEndCommandBuffer(m_commandBuffers[m_currentFrameIndex]));
I cant understand why the hovering works when the callbacks have not been installed in ImGui_ImplGlfw_InitForVulkan, but not with the callbacks installed. |
Because we have a fallback using Callbacks should be installed or you should install them yourself. You can also use our debug log: GImGui->DebugLogFlags |= ImGuiDebugLogFlags_EventIO; // force enable since you cannot click
ImGui::ShowDebugLogWindow(); |
when i have the callbacks automatically installed it says
it does not print the mouse pos and when the callbacks are not installed it spams the mouse pos without detecting when i click
do i have to install the callbacks manualy ? |
Version/Branch of Dear ImGui:
last commit from docking
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
Compiler, OS:
Windows 10
Full config/build information:
No response
Details:
I cant use my mouse to interact with the menus, only my keyboard. When i do a left click, the imgui menu switch to grey and did not respond anymore.
I have another vulkan renderer that uses imgui without this issue but with an older version of the docking branch. I tried to copy this imgui version but the result is the same.
When i switch the "install_callbacks" bool from "ImGui_ImplGlfw_InitForVulkan()" to false, my cursor can hover the buttons but i cant click on them.
Screenshots/Video:
2024-04-10.23-45-57.mp4
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: