You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to call the part of pixelgl.Window.Update that swaps buffers without calling the part that polls input. Since UpdateInput has already been broken out and exported (cf. #78), this symmetric case seems like a reasonable extension of the same principle.
My use case is an architecture that polls input via UpdateInput and JustPressed in a separate goroutine from the graphics refresh loop. Because the graphics goroutine polls input as a side-effect of its call to Update, the input handling goroutine's call to JustPressed doesn't trigger reliably -- because, I surmise, the two are racing and sometimes the graphics update "swallows" the first-time input. Regular Pressed works, but then I'd have to roll my own edge detection.
I've tested this change locally (since it's trivial to make) and it seems to work fine:
diff --git a/pixelgl/window.go b/pixelgl/window.go
index 10c16ce..14ce2d9 100644
--- a/pixelgl/window.go
+++ b/pixelgl/window.go
@@ -173,6 +173,11 @@ func (w *Window) Destroy() {
// Update swaps buffers and polls events. Call this method at the end of each frame.
func (w *Window) Update() {
+ w.SwapBuffers()
+ w.UpdateInput()
+}
+
+func (w *Window) SwapBuffers() {
mainthread.Call(func() {
_, _, oldW, oldH := intBounds(w.bounds)
newW, newH := w.window.GetSize()
@@ -207,8 +212,6 @@ func (w *Window) Update() {
w.window.SwapBuffers()
w.end()
})
-
- w.UpdateInput()
}
// SetClosed sets the closed flag of the Window.
I'll submit a PR with this.
Thanks for this library, been playing with it about a week now and it's been great.
The text was updated successfully, but these errors were encountered:
I'd like to be able to call the part of
pixelgl.Window.Update
that swaps buffers without calling the part that polls input. SinceUpdateInput
has already been broken out and exported (cf. #78), this symmetric case seems like a reasonable extension of the same principle.My use case is an architecture that polls input via
UpdateInput
andJustPressed
in a separate goroutine from the graphics refresh loop. Because the graphics goroutine polls input as a side-effect of its call toUpdate
, the input handling goroutine's call toJustPressed
doesn't trigger reliably -- because, I surmise, the two are racing and sometimes the graphics update "swallows" the first-time input. RegularPressed
works, but then I'd have to roll my own edge detection.I've tested this change locally (since it's trivial to make) and it seems to work fine:
I'll submit a PR with this.
Thanks for this library, been playing with it about a week now and it's been great.
The text was updated successfully, but these errors were encountered: