-
Notifications
You must be signed in to change notification settings - Fork 51
/
main.go
41 lines (29 loc) · 1011 Bytes
/
main.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
package main
import (
"fmt"
"runtime"
"github.com/AllenDang/cimgui-go/backend"
"github.com/AllenDang/cimgui-go/backend/sdlbackend"
"github.com/AllenDang/cimgui-go/examples/common"
"github.com/AllenDang/cimgui-go/imgui"
)
var currentBackend backend.Backend[sdlbackend.SDLWindowFlags]
func init() {
runtime.LockOSThread()
}
func main() {
common.Initialize()
currentBackend, _ = backend.CreateBackend(sdlbackend.NewSDLBackend())
currentBackend.SetAfterCreateContextHook(common.AfterCreateContext)
currentBackend.SetBeforeDestroyContextHook(common.BeforeDestroyContext)
currentBackend.SetBgColor(imgui.NewVec4(0.45, 0.55, 0.6, 1.0))
currentBackend.CreateWindow("Hello from cimgui-go", 1200, 900)
currentBackend.SetDropCallback(func(p []string) {
fmt.Printf("drop triggered: %v", p)
})
currentBackend.SetCloseCallback(func(b backend.Backend[sdlbackend.SDLWindowFlags]) {
fmt.Println("window is closing")
})
currentBackend.SetIcons(common.Image())
currentBackend.Run(common.Loop)
}