This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
/
DrawCommand.go
64 lines (54 loc) · 2.05 KB
/
DrawCommand.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package imgui
// #include "wrapper/DrawCommand.h"
import "C"
// DrawCommand describes one GPU call (or a callback).
type DrawCommand uintptr
func (cmd DrawCommand) handle() C.IggDrawCmd {
return C.IggDrawCmd(cmd)
}
// ElementCount is the number of indices (multiple of 3) to be rendered as triangles.
// Vertices are stored in the callee DrawList's VertexBuffer, indices in IndexBuffer.
func (cmd DrawCommand) ElementCount() int {
var count C.uint
C.iggDrawCommandGetElementCount(cmd.handle(), &count)
return int(count)
}
// IndexOffset is the start offset in index buffer.
// Always equal to sum of ElemCount drawn so far.
func (cmd DrawCommand) IndexOffset() int {
var count C.uint
C.iggDrawCommandGetIndexOffset(cmd.handle(), &count)
return int(count)
}
// VertexOffset is the start offset in vertex buffer.
// ImGuiBackendFlags_RendererHasVtxOffset: false always 0,
// otherwise may be >0 to support meshes larger than 64K vertices with 16-bit indices.
func (cmd DrawCommand) VertexOffset() int {
var count C.uint
C.iggDrawCommandGetVertexOffset(cmd.handle(), &count)
return int(count)
}
// ClipRect defines the clipping rectangle (x1, y1, x2, y2).
func (cmd DrawCommand) ClipRect() (rect Vec4) {
rectArg, rectFin := rect.wrapped()
defer rectFin()
C.iggDrawCommandGetClipRect(cmd.handle(), rectArg)
return
}
// TextureID is the user-provided texture ID.
// Set by user in FontAtlas.SetTextureID() for fonts or passed to Image*() functions.
// Ignore if never using images or multiple fonts atlas.
func (cmd DrawCommand) TextureID() TextureID {
var id C.IggTextureID
C.iggDrawCommandGetTextureID(cmd.handle(), &id)
return TextureID(id)
}
// HasUserCallback returns true if this handle command should be deferred.
func (cmd DrawCommand) HasUserCallback() bool {
return C.iggDrawCommandHasUserCallback(cmd.handle()) != 0
}
// CallUserCallback calls the user callback instead of rendering the vertices.
// ClipRect and TextureID will be set normally.
func (cmd DrawCommand) CallUserCallback(list DrawList) {
C.iggDrawCommandCallUserCallback(cmd.handle(), list.handle())
}