diff --git a/adapter.go b/adapter.go index a72bd51..efe3f47 100644 --- a/adapter.go +++ b/adapter.go @@ -70,7 +70,12 @@ func (g GameProxy) Update() error { } io := imgui.CurrentIO() + xoff, yoff := ebiten.Wheel() + io.SetDeltaTime(1.0 / 60.0) + + io.AddMouseWheelDelta(float32(xoff), float32(yoff)) + imgui.NewFrame() err := g.game.Update() @@ -79,8 +84,6 @@ func (g GameProxy) Update() error { io.SetMouseButtonDown(0, ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft)) io.SetMouseButtonDown(1, ebiten.IsMouseButtonPressed(ebiten.MouseButtonRight)) io.SetMouseButtonDown(2, ebiten.IsMouseButtonPressed(ebiten.MouseButtonMiddle)) - xoff, yoff := ebiten.Wheel() - io.AddMouseWheelDelta(float32(xoff), float32(yoff)) switch imgui.CurrentMouseCursor() { case imgui.MouseCursorNone: diff --git a/ebitenbackend.go b/ebitenbackend.go index 1f33a3e..1090173 100644 --- a/ebitenbackend.go +++ b/ebitenbackend.go @@ -186,17 +186,7 @@ func (b *BackendBridge) SetWindowTitle(title string) { ebiten.SetWindowTitle(title) } -//func (b *BackendBridge) DisplaySize() (width, height int32) { -// return int32(b.width), int32(b.height) -//} - func (b *BackendBridge) DisplaySize() (width int32, height int32) { - //widthArg, widthFin := WrapNumberPtr[C.int, int32](&width) - //defer widthFin() - // - //heightArg, heightFin := WrapNumberPtr[C.int, int32](&height) - //defer heightFin() - //C.igGLFWWindow_GetDisplaySize(b.handle(), widthArg, heightArg) return } diff --git a/examples/basic/main.go b/examples/basic/main.go index 1124bad..5eb7714 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -2,13 +2,13 @@ package main import ( imgui "github.com/AllenDang/cimgui-go" - ebitenbackend "github.com/damntourists/cimgui-go-ebiten" + backend "github.com/damntourists/cimgui-go-ebiten" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/vector" "image/color" ) -var adapter = ebitenbackend.NewEbitenAdapter() +var adapter = backend.NewEbitenAdapter() type MyGame struct{} @@ -50,9 +50,14 @@ func (m MyGame) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeig } func main() { - // You MUST use the following buildtags when building: + // + // The build tags listed below are required to compile with AllenDang/cimgui-go. You + // may, however, use the damntourists/cimgui-go-lite to bypass this requirement. + // Please refer to the go.mod file for more info. + // // * exclude_cimgui_sdli // * exclude_cimgui_glfw + // ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled) adapter.CreateWindow("Hello from cimgui-go-ebiten!", 800, 600) diff --git a/examples/custom_font/main.go b/examples/custom_font/main.go index 0f28026..b27c748 100644 --- a/examples/custom_font/main.go +++ b/examples/custom_font/main.go @@ -1,12 +1,3 @@ package main -// -//import ( -// ebitenbackend "cimgui-go-ebiten" -// imgui "github.com/AllenDang/cimgui-go" -//) -// -//func main() { -// backend, _ = imgui.CreateBackend(ebitenbackend.NewBackend()) -// //replace CreateTextureAs imgui.TextureID{Data:uintptr(1)} (default font textureid) -//} +// TODO diff --git a/go.mod b/go.mod index 70c986a..fac22e5 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,14 @@ require ( github.com/hajimehoshi/ebiten/v2 v2.6.6 ) -replace github.com/AllenDang/cimgui-go => github.com/damntourists/cimgui-go-lite v0.0.0-20240308200014-8405231d54c2 +// +// Uncomment if you'd like to use cimgui-go-lite, a glfw and sdl-less version of +// cimgui-go. I will do my best to keep this repository up to date with the latest +// but if I do happen to miss a release, feel free to open an issue or put in a +// pull request. +// +// replace github.com/AllenDang/cimgui-go => github.com/damntourists/cimgui-go-lite latest +// require ( github.com/ebitengine/purego v0.6.0 // indirect