Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #88 from JetSetIlly/addLine
Browse files Browse the repository at this point in the history
Add line
  • Loading branch information
dertseha authored Mar 7, 2020
2 parents 4826f00 + 50703d0 commit 12f5050
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions DrawList.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions DrawListWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImDrawList *>(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);
Expand Down
1 change: 1 addition & 0 deletions DrawListWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 12f5050

Please sign in to comment.