Skip to content

Commit

Permalink
ImDrawList: Separating PrimXXX sections from more internals helper in…
Browse files Browse the repository at this point in the history
… the header file.
  • Loading branch information
ocornut committed Jun 8, 2020
1 parent 117d57d commit e35a813
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2057,19 +2057,22 @@ struct ImDrawList
inline void ChannelsMerge() { _Splitter.Merge(this); }
inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); }

// [Internal helpers]
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
IMGUI_API void ResetForNewFrame();
IMGUI_API void ClearFreeMemory();
IMGUI_API void PopUnusedDrawCmd();
// Advanced: Primitives allocations
// - We render triangles (three vertices)
// - All primitives needs to be reserved via PrimReserve() beforehand.
IMGUI_API void PrimReserve(int idx_count, int vtx_count);
IMGUI_API void PrimUnreserve(int idx_count, int vtx_count);
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles)
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col);
inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index

// [Internal helpers]
IMGUI_API void ResetForNewFrame();
IMGUI_API void ClearFreeMemory();
IMGUI_API void PopUnusedDrawCmd();
IMGUI_API void UpdateClipRect();
IMGUI_API void UpdateTextureID();
};
Expand Down

0 comments on commit e35a813

Please sign in to comment.