Expose pixelgl.Window.SwapBuffers

Allow buffers to be swapped without polling input, offering decoupling symmetrical with that provided by UpdateInput.
This commit is contained in:
Luke Meyers 2020-02-09 20:59:59 -08:00
parent e51d4a6676
commit effd43bc56
1 changed files with 7 additions and 2 deletions

View File

@ -173,6 +173,13 @@ func (w *Window) Destroy() {
// Update swaps buffers and polls events. Call this method at the end of each frame. // Update swaps buffers and polls events. Call this method at the end of each frame.
func (w *Window) Update() { func (w *Window) Update() {
w.SwapBuffers()
w.UpdateInput()
}
// SwapBuffers swaps buffers. Call this to swap buffers without polling window events.
// Note that Update invokes SwapBuffers.
func (w *Window) SwapBuffers() {
mainthread.Call(func() { mainthread.Call(func() {
_, _, oldW, oldH := intBounds(w.bounds) _, _, oldW, oldH := intBounds(w.bounds)
newW, newH := w.window.GetSize() newW, newH := w.window.GetSize()
@ -207,8 +214,6 @@ func (w *Window) Update() {
w.window.SwapBuffers() w.window.SwapBuffers()
w.end() w.end()
}) })
w.UpdateInput()
} }
// SetClosed sets the closed flag of the Window. // SetClosed sets the closed flag of the Window.