mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/ui: bug fix: the env variable should be used only when the library is not specified
Updates #2378
This commit is contained in:
parent
8d020ad414
commit
e5b9569142
2
doc.go
2
doc.go
@ -67,7 +67,7 @@
|
|||||||
//
|
//
|
||||||
// `EBITENGINE_GRAPHICS_LIBRARY` environment variable specifies the graphics library.
|
// `EBITENGINE_GRAPHICS_LIBRARY` environment variable specifies the graphics library.
|
||||||
// If the specified graphics library is not available, RunGame returns an error.
|
// If the specified graphics library is not available, RunGame returns an error.
|
||||||
// This environment variable can also be set programmatically through os.Setenv before RunGame is called.
|
// This environment variable works when RunGame is called or RunGameWithOptions is called with GraphicsLibraryAuto.
|
||||||
// This can take one of the following value:
|
// This can take one of the following value:
|
||||||
//
|
//
|
||||||
// "auto": Ebitengine chooses the graphics library automatically. This is the default value.
|
// "auto": Ebitengine chooses the graphics library automatically. This is the default value.
|
||||||
|
@ -29,26 +29,27 @@ type graphicsDriverCreator interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newGraphicsDriver(creator graphicsDriverCreator, graphicsLibrary GraphicsLibrary) (graphicsdriver.Graphics, error) {
|
func newGraphicsDriver(creator graphicsDriverCreator, graphicsLibrary GraphicsLibrary) (graphicsdriver.Graphics, error) {
|
||||||
envName := "EBITENGINE_GRAPHICS_LIBRARY"
|
if graphicsLibrary == GraphicsLibraryAuto {
|
||||||
env := os.Getenv(envName)
|
envName := "EBITENGINE_GRAPHICS_LIBRARY"
|
||||||
if env == "" {
|
env := os.Getenv(envName)
|
||||||
// For backward compatibility, read the EBITEN_ version.
|
if env == "" {
|
||||||
envName = "EBITEN_GRAPHICS_LIBRARY"
|
// For backward compatibility, read the EBITEN_ version.
|
||||||
env = os.Getenv(envName)
|
envName = "EBITEN_GRAPHICS_LIBRARY"
|
||||||
}
|
env = os.Getenv(envName)
|
||||||
|
}
|
||||||
|
|
||||||
switch env {
|
switch env {
|
||||||
case "", "auto":
|
case "", "auto":
|
||||||
// Use the specified graphics library.
|
// Keep the automatic choosing.
|
||||||
// Otherwise, prefer the environment variable.
|
case "opengl":
|
||||||
case "opengl":
|
graphicsLibrary = GraphicsLibraryOpenGL
|
||||||
graphicsLibrary = GraphicsLibraryOpenGL
|
case "directx":
|
||||||
case "directx":
|
graphicsLibrary = GraphicsLibraryDirectX
|
||||||
graphicsLibrary = GraphicsLibraryDirectX
|
case "metal":
|
||||||
case "metal":
|
graphicsLibrary = GraphicsLibraryMetal
|
||||||
graphicsLibrary = GraphicsLibraryMetal
|
default:
|
||||||
default:
|
return nil, fmt.Errorf("ui: an unsupported graphics library is specified by the environment variable: %s", env)
|
||||||
return nil, fmt.Errorf("ui: an unsupported graphics library is specified by the environment variable: %s", env)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch graphicsLibrary {
|
switch graphicsLibrary {
|
||||||
|
Loading…
Reference in New Issue
Block a user