sdlcanvas package now handles resize events automatically if there is no resize handler

This commit is contained in:
Thomas Friedel 2018-05-28 16:14:01 +02:00
parent 1cd53a4e6b
commit 61ad4d0dc2

View file

@ -21,6 +21,7 @@ type Window struct {
Window *sdl.Window
WindowID uint32
GLContext sdl.GLContext
canvas *canvas.Canvas
frameTimes [10]time.Time
frameIndex int
frameCount int
@ -97,6 +98,7 @@ func CreateWindow(w, h int, title string) (*Window, *canvas.Canvas, error) {
Window: window,
WindowID: windowID,
GLContext: glContext,
canvas: cv,
events: make([]sdl.Event, 0, 100),
}
@ -176,6 +178,8 @@ func (wnd *Window) StartFrame() error {
if wnd.SizeChange != nil {
wnd.SizeChange(int(e.Data1), int(e.Data2))
handled = true
} else {
wnd.canvas.SetBounds(0, 0, int(e.Data1), int(e.Data2))
}
}
}