1

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.

Sleepi
  • 13
  • 1
  • 3
  • I don't know if you use SDL, but in SDL you can disable the frame with `SDL_NOFRAME` which is a good start (surely there are ways to do that in opengl and direct3d too). Moving it around would probably be implementation specific. For example on windows you can drag a window around using its client area like [this](https://stackoverflow.com/questions/7773771/how-do-i-implement-dragging-a-window-using-its-client-area) – Offtkp Dec 18 '21 at 15:59
  • You can just make the window the size of the viewport (which will be controlled by the normal OS window), and set some styles (`ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse`) and pass `NULL` as the second argument to `ImGUI::Begin` so it will always fill the whole viewport. – tromgy Dec 18 '21 at 16:35

2 Answers2

1

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
    ...
}
Naveen
  • 459
  • 4
  • 10
  • 1
    I added `glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);` for something similar too. Makes the borders (and I think the top with like the X and minimize buttons) disappear. – Joel Aug 25 '23 at 18:34
1

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.

Demo Screenshot