2

My learning/test app uses SDL2 + ImGui, so all window management is done by SDL2. So what's the difference between:

    ImGui::SetNextWindowSize({640, 480}, 0);
    ImGui::Begin("MyWindow", &_mywnd, ImGuiWindowFlags_None);
    ImGui::End();

v.s.

    SDL_Window* _window = SDL_CreateWindow("MyWindow", SDL_WINDOWPOS_CENTERED,
            SDL_WINDOWPOS_CENTERED, 640, 480, windowFlags);

SDL_CreateWindow will create a normal window matching the Windows OS theme. But ImGui::Begin creates it's styled window. ImGui doesn't have a window handle or an SDL_Window, correct?

1 Answers1

0

When we look at the ImGui SDL2 example, it creates an SDL window:

SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example",     SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);

You need at least one SDL window, because the renderer needs the window handle.

ImGui::Begin() creates a subwindow that exists only in the drawing area of the main window. This is not an OS window. It is simply a graphical element (ImGuiWindow), like all other ImGui elements. The windows are identified by their name, because they don't have any unique handle.

VLL
  • 9,634
  • 1
  • 29
  • 54