make handleWindowEvent function
This commit is contained in:
parent
85c55e5a21
commit
01e888ad25
14
main.go
14
main.go
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue