mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/graphicsdriver/directx: use OpenGL as the default on old Windows
On old machines, CreateSwapChain might fail without a specific reasons. Probably this is due to an issue in drivers, and if so, there is nothing we can do. When choosing a graphics library, prefer OpenGL on such old machines. Updates #2613
This commit is contained in:
parent
182ac21866
commit
370b7599bc
@ -29,6 +29,7 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/directx"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/directx"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk"
|
"github.com/hajimehoshi/ebiten/v2/internal/microsoftgdk"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/internal/winver"
|
||||||
)
|
)
|
||||||
|
|
||||||
type graphicsDriverCreatorImpl struct {
|
type graphicsDriverCreatorImpl struct {
|
||||||
@ -36,15 +37,23 @@ type graphicsDriverCreatorImpl struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphicsDriverCreatorImpl) newAuto() (graphicsdriver.Graphics, GraphicsLibrary, error) {
|
func (g *graphicsDriverCreatorImpl) newAuto() (graphicsdriver.Graphics, GraphicsLibrary, error) {
|
||||||
d, err1 := g.newDirectX()
|
// Creating a swap chain on an older machines than Windows 10 might fail (#2613).
|
||||||
if err1 == nil {
|
var dxErr error
|
||||||
return d, GraphicsLibraryDirectX, nil
|
if winver.IsWindows10OrGreater() {
|
||||||
|
d, err := g.newDirectX()
|
||||||
|
if err == nil {
|
||||||
|
return d, GraphicsLibraryDirectX, nil
|
||||||
|
}
|
||||||
|
dxErr = err
|
||||||
}
|
}
|
||||||
o, err2 := g.newOpenGL()
|
|
||||||
if err2 == nil {
|
o, err := g.newOpenGL()
|
||||||
|
if err == nil {
|
||||||
return o, GraphicsLibraryOpenGL, nil
|
return o, GraphicsLibraryOpenGL, nil
|
||||||
}
|
}
|
||||||
return nil, GraphicsLibraryUnknown, fmt.Errorf("ui: failed to choose graphics drivers: DirectX: %v, OpenGL: %v", err1, err2)
|
glErr := err
|
||||||
|
|
||||||
|
return nil, GraphicsLibraryUnknown, fmt.Errorf("ui: failed to choose graphics drivers: DirectX: %v, OpenGL: %v", dxErr, glErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) {
|
func (*graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user