make handleWindowEvent function

This commit is contained in:
filifa 2024-08-24 19:18:59 -05:00
parent 85c55e5a21
commit 01e888ad25
1 changed files with 9 additions and 5 deletions

14
main.go
View File

@ -37,17 +37,21 @@ func render(window *sdl.Window, handle C.projectm_handle) (bool, error) {
return true, nil return true, nil
} }
func handleWindowEvent(event *sdl.WindowEvent, handle C.projectm_handle) {
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))
}
}
func handleEvent(event sdl.Event, handle C.projectm_handle) bool { func handleEvent(event sdl.Event, handle C.projectm_handle) bool {
switch event.(type) { switch event.(type) {
case *sdl.QuitEvent: case *sdl.QuitEvent:
return false return false
case *sdl.WindowEvent: case *sdl.WindowEvent:
event := event.(*sdl.WindowEvent) event := event.(*sdl.WindowEvent)
switch event.Event { handleWindowEvent(event, handle)
case sdl.WINDOWEVENT_RESIZED:
w, h := event.Data1, event.Data2
C.projectm_set_window_size(handle, C.ulong(w), C.ulong(h))
}
} }
return true return true