mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/ui: bug fix: ignore ERROR_BUSY when deleting a GL context
Closes #2518
This commit is contained in:
parent
7018318546
commit
471237b701
@ -6,10 +6,13 @@
|
||||
package glfwwin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk"
|
||||
)
|
||||
|
||||
@ -321,7 +324,10 @@ func getProcAddressWGL(procname string) uintptr {
|
||||
|
||||
func destroyContextWGL(window *Window) error {
|
||||
if window.context.wgl.handle != 0 {
|
||||
if err := wglDeleteContext(window.context.wgl.handle); err != nil {
|
||||
// Ignore ERROR_BUSY. This happens when the thread is different from the context thread (#2518).
|
||||
// This is a known issue of GLFW (glfw/glfw#2239).
|
||||
// TODO: Delete the context on an appropriate thread.
|
||||
if err := wglDeleteContext(window.context.wgl.handle); err != nil && !errors.Is(err, windows.ERROR_BUSY) {
|
||||
return err
|
||||
}
|
||||
window.context.wgl.handle = 0
|
||||
|
@ -1004,8 +1004,7 @@ func (u *userInterfaceImpl) update() (float64, float64, error) {
|
||||
|
||||
func (u *userInterfaceImpl) loopGame() error {
|
||||
defer u.mainThread.Call(func() {
|
||||
// An explicit destorying a window tries to delete a GL context on the main thread on Windows (wglDeleteContext),
|
||||
// but this causes an error unfortunately.
|
||||
u.window.Destroy()
|
||||
glfw.Terminate()
|
||||
})
|
||||
for {
|
||||
|
Loading…
Reference in New Issue
Block a user