add imgui_wrapper
This commit is contained in:
parent
ac0f65fb3e
commit
8c28fc6839
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -2,5 +2,5 @@
|
||||
path = formats/mpq/stormlib
|
||||
url = https://github.com/ladislav-zezula/StormLib.git
|
||||
[submodule "platform/imgui/cimgui"]
|
||||
path = platform/imgui/cimgui
|
||||
path = platform/imgui/imgui_wrapper/cimgui
|
||||
url = https://github.com/cimgui/cimgui.git
|
||||
|
44
platform/imgui/imgui_wrapper/imgui_wrapper.go
Normal file
44
platform/imgui/imgui_wrapper/imgui_wrapper.go
Normal 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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user