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"
|
"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 {
|
switch event.Event {
|
||||||
case sdl.WINDOWEVENT_RESIZED:
|
case sdl.WINDOWEVENT_RESIZED:
|
||||||
w, h := event.Data1, event.Data2
|
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) {
|
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)
|
||||||
handleWindowEvent(event, handle)
|
handleWindowEvent(event, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -49,7 +49,7 @@ func main() {
|
||||||
running := true
|
running := true
|
||||||
for running {
|
for running {
|
||||||
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
|
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
|
||||||
running = handleEvent(event, m.handle)
|
running = handleEvent(event, m)
|
||||||
if !running {
|
if !running {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue