Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove workaround for bug that was fixed in GLFW 3.3.5 #387

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions v3.3/glfw/glfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ const (
// This function may only be called from the main thread.
func Init() error {
C.glfwInit()
// invalidValue can happen when specific joysticks are used. This issue
// will be fixed in GLFW 3.3.5. As a temporary fix, ignore this error.
// See go-gl/glfw#292, go-gl/glfw#324, and glfw/glfw#1763.
err := acceptError(APIUnavailable, invalidValue)
if e, ok := err.(*Error); ok && e.Code == invalidValue {
return nil
}
return err
return acceptError(APIUnavailable)
}

// Terminate destroys all remaining windows, frees any allocated resources and
Expand Down
21 changes: 3 additions & 18 deletions v3.3/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,21 +918,6 @@ func (w *Window) GetClipboardString() string {
return C.GoString(cs)
}

// panicErrorExceptForInvalidValue is the same as panicError but ignores
// invalidValue.
func panicErrorExceptForInvalidValue() {
// invalidValue can happen when specific joysticks are used. This issue
// will be fixed in GLFW 3.3.5. As a temporary fix, ignore this error.
// See go-gl/glfw#292, go-gl/glfw#324, and glfw/glfw#1763.
err := acceptError(invalidValue)
if e, ok := err.(*Error); ok && e.Code == invalidValue {
return
}
if err != nil {
panic(err)
}
}

// PollEvents processes only those events that have already been received and
// then returns immediately. Processing events will cause the window and input
// callbacks associated with those events to be called.
Expand All @@ -944,7 +929,7 @@ func panicErrorExceptForInvalidValue() {
// This function may only be called from the main thread.
func PollEvents() {
C.glfwPollEvents()
panicErrorExceptForInvalidValue()
panicError()
}

// WaitEvents puts the calling thread to sleep until at least one event has been
Expand All @@ -962,7 +947,7 @@ func PollEvents() {
// This function may only be called from the main thread.
func WaitEvents() {
C.glfwWaitEvents()
panicErrorExceptForInvalidValue()
panicError()
}

// WaitEventsTimeout puts the calling thread to sleep until at least one event is available in the
Expand All @@ -989,7 +974,7 @@ func WaitEvents() {
// Event processing is not required for joystick input to work.
func WaitEventsTimeout(timeout float64) {
C.glfwWaitEventsTimeout(C.double(timeout))
panicErrorExceptForInvalidValue()
panicError()
}

// PostEmptyEvent posts an empty event from the current thread to the main
Expand Down