mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/ui: use DirectX as a fallback for old Windows
Initializing OpenGL can fail [1], though this is pretty rare. For such this case, try DirectX as a fallback. [1] https://answers.microsoft.com/en-us/windows/forum/all/my-drivers-dont-support-opengl/a1ee0267-4dc8-4385-a185-6ed322d78329 Updates #2613
This commit is contained in:
parent
370b7599bc
commit
1999f8a024
@ -37,21 +37,36 @@ type graphicsDriverCreatorImpl struct {
|
||||
}
|
||||
|
||||
func (g *graphicsDriverCreatorImpl) newAuto() (graphicsdriver.Graphics, GraphicsLibrary, error) {
|
||||
// Creating a swap chain on an older machines than Windows 10 might fail (#2613).
|
||||
var dxErr error
|
||||
var glErr error
|
||||
if winver.IsWindows10OrGreater() {
|
||||
d, err := g.newDirectX()
|
||||
if err == nil {
|
||||
return d, GraphicsLibraryDirectX, nil
|
||||
}
|
||||
dxErr = err
|
||||
}
|
||||
|
||||
o, err := g.newOpenGL()
|
||||
if err == nil {
|
||||
return o, GraphicsLibraryOpenGL, nil
|
||||
o, err := g.newOpenGL()
|
||||
if err == nil {
|
||||
return o, GraphicsLibraryOpenGL, nil
|
||||
}
|
||||
glErr = err
|
||||
} else {
|
||||
// Creating a swap chain on an older machines than Windows 10 might fail (#2613).
|
||||
// Prefer OpenGL to DirectX.
|
||||
o, err := g.newOpenGL()
|
||||
if err == nil {
|
||||
return o, GraphicsLibraryOpenGL, nil
|
||||
}
|
||||
glErr = err
|
||||
|
||||
// Initializing OpenGL can fail, though this is pretty rare.
|
||||
d, err := g.newDirectX()
|
||||
if err == nil {
|
||||
return d, GraphicsLibraryDirectX, nil
|
||||
}
|
||||
dxErr = err
|
||||
}
|
||||
glErr := err
|
||||
|
||||
return nil, GraphicsLibraryUnknown, fmt.Errorf("ui: failed to choose graphics drivers: DirectX: %v, OpenGL: %v", dxErr, glErr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user