First imgui trys

This commit is contained in:
Dmitry Sergeev
2026-08-25 13:02:54 +03:00
parent 3398cdf3f1
commit 3b51bea58a
5 changed files with 347 additions and 2 deletions
+21
View File
@@ -15,6 +15,7 @@ import (
"time"
"unsafe"
cimgui "github.com/AllenDang/cimgui-go/imgui"
vk "github.com/christerso/vulkan-go/vk"
"github.com/qvest-digital/go-mxl/mxl"
pflag "github.com/spf13/pflag"
@@ -325,6 +326,15 @@ func main() {
panic(err)
}
defer r.Destroy()
guiBackend, err := imgui.NewVulkanBackend(
vkPhysDevice, vkDevice, vkQueue, r.CmdPool(), r.RenderPass())
if err != nil {
panic(err)
}
defer guiBackend.Destroy()
r.ImGuiDraw = func(cmd vk.CommandBuffer) {
guiBackend.RecordDraw(cmd, gui.LastDrawData())
}
defer vkDevice.WaitIdle()
}
@@ -528,7 +538,9 @@ func main() {
dropped uint64
frameCount uint64
lastReport time.Time
lastFrame time.Time
)
lastFrame = time.Now()
for running {
frameStart := time.Now()
var event [128]byte
@@ -589,6 +601,15 @@ func main() {
}
if r != nil {
gui.BeginFrame(time.Since(lastFrame), int32(r.Extent().Width), int32(r.Extent().Height))
// test widget
cimgui.Begin("Test")
imguiLabel := fmt.Sprintf("%dx%d", 1920, 1080)
cimgui.SeparatorText(imguiLabel)
cimgui.End()
gui.EndFrame()
lastFrame = time.Now()
// end of test widget
var w, h, stride uint32
if syncSrc != nil {
w, h, stride = syncSrc.Width(), syncSrc.Height(), syncSrc.Stride()