add imgui_wrapper

This commit is contained in:
Alex Yatskov 2019-01-01 15:49:13 -08:00
parent ac0f65fb3e
commit 8c28fc6839
3 changed files with 45 additions and 1 deletions

2
.gitmodules vendored
View File

@ -2,5 +2,5 @@
path = formats/mpq/stormlib path = formats/mpq/stormlib
url = https://github.com/ladislav-zezula/StormLib.git url = https://github.com/ladislav-zezula/StormLib.git
[submodule "platform/imgui/cimgui"] [submodule "platform/imgui/cimgui"]
path = platform/imgui/cimgui path = platform/imgui/imgui_wrapper/cimgui
url = https://github.com/cimgui/cimgui.git url = https://github.com/cimgui/cimgui.git

View File

@ -0,0 +1,44 @@
package imgui
// #define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
// #include "cimgui/cimgui.h"
// #cgo linux LDFLAGS: -L./cimgui -l:cimgui.a -lstdc++ -lm
import "C"
import "unsafe"
type Context = C.ImGuiContext
type DrawData = C.ImDrawData
type FontAtlas = C.ImFontAtlas
type Io = C.ImGuiIO
func CreateContext(fontAtlas *FontAtlas) *Context {
c := C.igCreateContext(fontAtlas)
return c
}
func (c *Context) Destroy() {
C.igDestroyContext(c)
}
func NewFrame() {
C.igNewFrame()
}
func Render() {
C.igRender()
}
func GetDrawData() *DrawData {
return C.igGetDrawData()
}
func GetIo() *Io {
return C.igGetIO()
}
func (fa *FontAtlas) GetTexDataAsRGBA32() (pixels unsafe.Pointer, width, height int32) {
var data *C.uint8_t
var w, h C.int
C.ImFontAtlas_GetTexDataAsRGBA32(fa, &data, &w, &h, nil)
return unsafe.Pointer(data), int32(w), int32(h)
}