pass window struct to event functions
This commit is contained in:
parent
4aaf8e6638
commit
edaf47d893
10
main.go
10
main.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue