ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
60.75k stars 10.27k forks source link

Putting a MiniMap in a moveable window ( I seem to lack fundamental knowledge ) #8101

Closed inflex closed 4 hours ago

inflex commented 5 hours ago

Version/Branch of Dear ImGui:

Version 1.91.3

Back-ends:

imgui_impl_SDL2.cpp

Compiler, OS:

Linux + gcc

Full config/build information:

No response

Details:

Simply put, I want to draw a mini-map ( bottom right corner of screen shot ) within the ImGui moveable / resizeable window.

Currently I am drawning the minimap as part of the main draw-> process for the rest of the visible circuit board, and the drawlist is then rendered, all good. I would however like to make it instead that the minimap is drawn within the moveable "Another Window".

I have been searching around at various tutes/guides but haven't been able to quite grok what I'm doing.

I'm not using any OpenGL primatives; this is all SDL2 software rendering, everything is drawn directly to screen coordinate space.

The minimap drawing process is a single function self-contained..

Apologies if these seems like a stupid/trivial question; you'd think after years of writing this codebase I'd have expanded more in to other ImGui features/understandings.

Screenshots/Video:

Screenshot at 2024-10-26 14-06-54

Minimal, Complete and Verifiable Example code:

No response

inflex commented 4 hours ago

Why is it that often when you ask for help you go back and stumble on the solution yourself...

I found doing this, and then using mmdraw->AddLine() (etc) does the job for me ( the various offsets I have to adjust to follow the window but the drawing is rendered on the new window canvas and appropriately clipped ).

    ImGui::SetNextWindowSize(ImVec2(mm_board_width *1.2, mm_board_height *2.2), ImGuiCond_FirstUseEver);
    ImGui::Begin("Another Window");
    ImVec2 canvas = ImGui::GetWindowSize();
    ImDrawList *mmdraw = ImGui::GetWindowDrawList();
 ...
 ...
    ImGui::End();

Screenshot at 2024-10-26 14-29-41