ImDrawList: Small refactor to create empty command when beginning the frame, allowing to simplify some functions.

+ Missing clearing two fields in ClearFreeMemory() (was hamrless)
This commit is contained in:
ocornut
2020-06-06 20:25:56 +02:00
parent 003153b3ac
commit 0320e7257b
3 changed files with 17 additions and 12 deletions

View File

@ -1987,7 +1987,8 @@ struct ImDrawList
ImDrawListSplitter _Splitter; // [Internal] for channels api (note: prefer using your own persistent instance of ImDrawListSplitter!)
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; _OwnerName = NULL; Clear(); }
ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; Flags = ImDrawListFlags_None; _VtxCurrentOffset = _VtxCurrentIdx = 0; _VtxWritePtr = NULL; _IdxWritePtr = NULL; _OwnerName = NULL; }
~ImDrawList() { ClearFreeMemory(); }
IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
IMGUI_API void PushClipRectFullScreen();
@ -2056,7 +2057,7 @@ struct ImDrawList
// [Internal helpers]
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
IMGUI_API void Clear();
IMGUI_API void ResetForNewFrame();
IMGUI_API void ClearFreeMemory();
IMGUI_API void PrimReserve(int idx_count, int vtx_count);
IMGUI_API void PrimUnreserve(int idx_count, int vtx_count);