Reputation: 31
Is it possible to create an ImGui screen without a background or window? It would just be the ImGui window that can be dragged across the screen. It would looks something like this, but instead of a blue background, you'd just see the application that is under it.
Upvotes: 2
Views: 11593
Reputation: 63
I know the topic is pretty old but it can useful for some people.
You can't really display an ImGui without creating a window, but you can use the docking version of ImGui (link here). This version allow the ImGui interface to "live" outside of the window. So, you can easily have only the ImGui interface displayed.
To do that you can use the sample code from ImGui and modify the window creation like this :
ImGui_ImplWin32_EnableDpiAwareness();
const WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, _T("ImGui Standalone"), nullptr };
::RegisterClassEx(&wc);
const HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("ImGui Standalone"), WS_OVERLAPPEDWINDOW, 100, 100, 50, 50, NULL, NULL, wc.hInstance, NULL);
if (!CreateDeviceD3D(hwnd))
{
CleanupDeviceD3D();
::UnregisterClass(wc.lpszClassName, wc.hInstance);
return;
}
::ShowWindow(hwnd, SW_HIDE);
::UpdateWindow(hwnd);
When you are calling the ShowWindow
function you have to pass the SW_HIDE
parameter to hide the window and only keep the ImGui interface.
You can find a complete project here.
Upvotes: 4
Reputation: 519
In case of GLFW backend, the below window hint with a glclear color can help
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
Render Loop:
{
...
glfwGetFramebufferSize(window, &app_width, &app_height);
glViewport(0, 0, app_width, app_height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//render
...
}
Upvotes: 1