make imgui text take format and arguments

This commit is contained in:
Alex Yatskov 2019-01-07 19:25:48 -08:00
parent d9c9bf88f7
commit cfb72ee80c
2 changed files with 5 additions and 3 deletions

View File

@ -4,6 +4,7 @@ package imgui
// #include "native.h"
import "C"
import (
"fmt"
"unsafe"
"github.com/FooSoft/lazarus/graphics"
@ -54,7 +55,8 @@ func SliderInt(label string, value *int, min, max int) bool {
return result
}
func Text(label string) {
func Text(format string, args ...interface{}) {
label := fmt.Sprintf(format, args...)
labelStartC := C.CString(label)
labelEndC := (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(labelStartC)) + uintptr(len(label))))
defer C.free(unsafe.Pointer(labelStartC))

View File

@ -77,11 +77,11 @@ func (s *scene) Advance() error {
imgui.Columns(2)
imgui.Text("Size")
imgui.NextColumn()
imgui.Text(fmt.Sprintf("%+v", frame.Size))
imgui.Text("%+v", frame.Size)
imgui.NextColumn()
imgui.Text("Offset")
imgui.NextColumn()
imgui.Text(fmt.Sprintf("%+v", frame.Offset))
imgui.Text("%+v", frame.Offset)
imgui.Columns(1)
if imgui.Button("Exit") {
platform.WindowSetScene(nil)