pass window struct to event functions

This commit is contained in:
filifa 2024-08-24 20:14:00 -05:00
parent 4aaf8e6638
commit edaf47d893
1 changed files with 5 additions and 5 deletions

10
main.go
View File

@ -11,21 +11,21 @@ import (
"github.com/veandco/go-sdl2/sdl"
)
func handleWindowEvent(event *sdl.WindowEvent, handle C.projectm_handle) {
func handleWindowEvent(event *sdl.WindowEvent, m *milkDropWindow) {
switch event.Event {
case sdl.WINDOWEVENT_RESIZED:
w, h := event.Data1, event.Data2
C.projectm_set_window_size(handle, C.ulong(w), C.ulong(h))
C.projectm_set_window_size(m.handle, C.ulong(w), C.ulong(h))
}
}
func handleEvent(event sdl.Event, handle C.projectm_handle) bool {
func handleEvent(event sdl.Event, m *milkDropWindow) bool {
switch event.(type) {
case *sdl.QuitEvent:
return false
case *sdl.WindowEvent:
event := event.(*sdl.WindowEvent)
handleWindowEvent(event, handle)
handleWindowEvent(event, m)
}
return true
@ -49,7 +49,7 @@ func main() {
running := true
for running {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
running = handleEvent(event, m.handle)
running = handleEvent(event, m)
if !running {
break
}