I wasn’t sure if I should post here or in “Getting Started” and chose here because other than this issue, I have dear imgui setup and working.
First, I am using Win32 API on Windows 10 with OpenGL using imgui_impl_win32 and imgui_impl_opengl3. I am using GLEW, so I have #define IMGUI_IMPL_OPENGL_LOADER_GLEW. I am using 1.72b, but until about ten minutes ago, I was using 1.6 and had the same issue.
My issue is that when I drag an imgui window outside the main application window, it turns black. If I boil my code down (which I need to do because it is running inside my engine that is composed of multiple layers), here is what it would look like in a simple application:
//Setup
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
Application& app = Application::GetApplication();
io.DisplaySize = ImVec2((float)app.GetWindowWidth(), (float)app.GetWindowHeight());
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
ImGui::StyleColorsDark();
ImGuiStyle& style = ImGui::GetStyle();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
style.WindowRounding = 0.0f;
style.Colors[ImGuiCol_WindowBg].w = 1.0f;
}
void* window = Application::GetApplication().window->GetHandle();
ImGui_ImplWin32_Init(window);
ImGui_ImplOpenGL3_Init("#version 410");
//Begin a frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
//Render stuff
ImGui::ShowDemoWindow(&show);
//End a frame
ImGuiIO& io = ImGui::GetIO();
Application& app = Application::GetApplication();
io.DisplaySize = ImVec2((float)app.GetWindowWidth(), (float)app.GetWindowHeight());
ImGui::Render();
HGLRC backup_current_context = wglGetCurrentContext();
ImGui::UpdatePlatformWindows();
//ImGui::RenderPlatformWindowsDefault();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
wglMakeCurrent(Mercury::Graphics::API::hDC ,backup_current_context);
//I also have the standard shutdown code, but it would not be relevant to this issue.
I have commented out the stuff about grabbing the context and making it current, but it still does not work. I have also uncommented the line with ImGui::RenderPlatformWindowsDefault(), but all that does is to cause the window being dragged outside to be drawn as a black rectangle outside and normally inside, but only the outside one can be interacted with.
Any ideas?
Thanks!