forked from HACKERALERT/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawData.go
42 lines (34 loc) · 1.34 KB
/
DrawData.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
package imgui
// #include "DrawDataWrapper.h"
import "C"
import "unsafe"
// DrawData contains all draw data to render an ImGui frame.
type DrawData uintptr
func (data DrawData) handle() C.IggDrawData {
return C.IggDrawData(data)
}
// Valid indicates whether the structure is usable.
// It is valid only after Render() is called and before the next NewFrame() is called.
func (data DrawData) Valid() bool {
return (data.handle() != nil) && (C.iggDrawDataValid(data.handle()) != 0)
}
// CommandLists is an array of DrawList to render.
// The DrawList are owned by the context and only pointed to from here.
func (data DrawData) CommandLists() []DrawList {
var handles unsafe.Pointer
var count C.int
C.iggDrawDataGetCommandLists(data.handle(), &handles, &count)
list := make([]DrawList, int(count))
for i := 0; i < int(count); i++ {
list[i] = DrawList(*((*uintptr)(handles)))
handles = unsafe.Pointer(uintptr(handles) + unsafe.Sizeof(handles)) // nolint: gas
}
return list
}
// ScaleClipRects is a helper to scale the ClipRect field of each DrawCmd.
// Use if your final output buffer is at a different scale than ImGui expects,
// or if there is a difference between your window resolution and framebuffer resolution.
func (data DrawData) ScaleClipRects(scale Vec2) {
scaleArg, _ := scale.wrapped()
C.iggDrawDataScaleClipRects(data.handle(), scaleArg)
}