Skip to content

Commit

Permalink
Cleanup, fixed scrolling issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
damntourists committed Mar 10, 2024
1 parent 1659c6d commit 8783498
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
7 changes: 5 additions & 2 deletions adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions ebitenbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
11 changes: 8 additions & 3 deletions examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down Expand Up @@ -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)
Expand Down
11 changes: 1 addition & 10 deletions examples/custom_font/main.go
Original file line number Diff line number Diff line change
@@ -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
9 changes: 8 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8783498

Please sign in to comment.