Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions backend/ebiten-backend/cimgui_backend_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ func (b *EbitenBackend) Run(loop func()) {
ebiten.RunGame(b)
}

// TODO: Not implemented
// Because Ebiten refreshes continuously anyway, Refresh has nothing to do here.
func (b *EbitenBackend) Refresh() {
panic("Refresh is not implemented for Ebiten backend yet.")
// noop
}

func (b *EbitenBackend) SetWindowPos(x, y int) {
Expand Down Expand Up @@ -95,9 +95,9 @@ func (b *EbitenBackend) DisplaySize() (width, height int32) {
return 0, 0
}

// TODO: Not implemented
func (b *EbitenBackend) SetShouldClose(bool) {
panic("SetShouldClose is not implemented for Ebiten backend yet.")
// SetShouldClose asks to close the window and stop the game loop. WIll call CloseCallback if set.
func (b *EbitenBackend) SetShouldClose(sc bool) {
b.shouldClose = sc
}

func (b *EbitenBackend) ContentScale() (xScale, yScale float32) {
Expand Down
8 changes: 8 additions & 0 deletions backend/ebiten-backend/ebiten_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ func (e *EbitenBackend) Update() error {
game.Update()
})

if e.shouldClose {
if e.closeCb != nil {
e.closeCb()
}

return ebiten.Termination
}

return nil
}

Expand Down
3 changes: 2 additions & 1 deletion backend/ebiten-backend/ebiten_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ type EbitenBackend struct {
afterRender,
beforeDestroy,
loop func()
closeCb backend.WindowCloseCallback
closeCb backend.WindowCloseCallback
shouldClose bool

// ebiten stuff
filter ebiten.Filter
Expand Down
1 change: 0 additions & 1 deletion examples/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
_ "github.com/AllenDang/cimgui-go/imguizmo"
_ "github.com/AllenDang/cimgui-go/immarkdown"
_ "github.com/AllenDang/cimgui-go/imnodes"
_ "github.com/AllenDang/cimgui-go/impl/glfw"
_ "github.com/AllenDang/cimgui-go/impl/opengl3"
"github.com/AllenDang/cimgui-go/implot"
"github.com/AllenDang/cimgui-go/utils"
Expand Down
3 changes: 1 addition & 2 deletions examples/glfw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"github.com/AllenDang/cimgui-go/backend/glfwbackend"
"github.com/AllenDang/cimgui-go/examples/common"
"github.com/AllenDang/cimgui-go/imgui"
_ "github.com/AllenDang/cimgui-go/immarkdown"
_ "github.com/AllenDang/cimgui-go/imnodes"
_ "github.com/AllenDang/cimgui-go/impl/glfw"
)

var currentBackend backend.Backend[glfwbackend.GLFWWindowFlags]
Expand Down
Loading