diff --git a/DrawList.go b/DrawList.go index cf732456..7ed4758a 100644 --- a/DrawList.go +++ b/DrawList.go @@ -105,6 +105,18 @@ const ( DrawCornerFlagsAll = 0xF ) +// AddLine call AddLineV with a thickness value of 1.0 +func (list DrawList) AddLine(p1 Vec2, p2 Vec2, col PackedColor) { + list.AddLineV(p1, p2, col, 1.0) +} + +// AddLineV adds a line to draw list, extending from point p1 to p2 +func (list DrawList) AddLineV(p1 Vec2, p2 Vec2, col PackedColor, thickness float32) { + p1Arg, _ := p1.wrapped() + p2Arg, _ := p2.wrapped() + C.iggAddLine(list.handle(), p1Arg, p2Arg, C.IggPackedColor(col), C.float(thickness)) +} + // AddRect calls AddRectV with rounding and thickness values of 1.0 and // DrawCornerFlagsAll func (list DrawList) AddRect(min Vec2, max Vec2, col PackedColor) { diff --git a/DrawListWrapper.cpp b/DrawListWrapper.cpp index eff2c75a..878aa459 100644 --- a/DrawListWrapper.cpp +++ b/DrawListWrapper.cpp @@ -41,6 +41,15 @@ void iggGetVertexBufferLayout(size_t *entrySize, size_t *posOffset, size_t *uvOf *colOffset = IM_OFFSETOF(ImDrawVert, col); } +void iggAddLine(IggDrawList handle, IggVec2 const *p1, IggVec2 const *p2, IggPackedColor col, float thickness) +{ + Vec2Wrapper p1Arg(p1); + Vec2Wrapper p2Arg(p2); + + ImDrawList *list = reinterpret_cast(handle); + list->AddLine(*p1Arg, *p2Arg, col, thickness); +} + void iggAddRect(IggDrawList handle, IggVec2 const *min, IggVec2 const *max, IggPackedColor col, float rounding, int flags, float thickness) { Vec2Wrapper minArg(min); diff --git a/DrawListWrapper.h b/DrawListWrapper.h index 74099858..4977cfb0 100644 --- a/DrawListWrapper.h +++ b/DrawListWrapper.h @@ -15,6 +15,7 @@ extern void iggDrawListGetRawVertexBuffer(IggDrawList handle, void **data, int * extern void iggGetIndexBufferLayout(size_t *entrySize); extern void iggGetVertexBufferLayout(size_t *entrySize, size_t *posOffset, size_t *uvOffset, size_t *colOffset); +extern void iggAddLine(IggDrawList handle, IggVec2 const *p1, IggVec2 const *p2, IggPackedColor col, float thickness); extern void iggAddRect(IggDrawList handle, IggVec2 const *min, IggVec2 const *max, IggPackedColor col, float rounding, int flags, float thickness); extern void iggAddRectFilled(IggDrawList handle, IggVec2 const *min, IggVec2 const *max, IggPackedColor col, float rounding, int flags); extern void iggAddCircle(IggDrawList handle, IggVec2 const *center, float radius, IggPackedColor col, int numSegments, float thickness);