mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
add new environment variables with the EBITENGINE_ suffix
Updates #2111 Updates #2190
This commit is contained in:
parent
926dd5677e
commit
204fb5935b
10
doc.go
10
doc.go
@ -56,16 +56,16 @@
|
|||||||
//
|
//
|
||||||
// Environment variables
|
// Environment variables
|
||||||
//
|
//
|
||||||
// `EBITEN_SCREENSHOT_KEY` environment variable specifies the key
|
// `EBITENGINE_SCREENSHOT_KEY` environment variable specifies the key
|
||||||
// to take a screenshot. For example, if you run your game with
|
// to take a screenshot. For example, if you run your game with
|
||||||
// `EBITEN_SCREENSHOT_KEY=q`, you can take a game screen's screenshot
|
// `EBITENGINE_SCREENSHOT_KEY=q`, you can take a game screen's screenshot
|
||||||
// by pressing Q key. This works only on desktops.
|
// by pressing Q key. This works only on desktops.
|
||||||
//
|
//
|
||||||
// `EBITEN_INTERNAL_IMAGES_KEY` environment variable specifies the key
|
// `EBITENGINE_INTERNAL_IMAGES_KEY` environment variable specifies the key
|
||||||
// to dump all the internal images. This is valid only when the build tag
|
// to dump all the internal images. This is valid only when the build tag
|
||||||
// 'ebitendebug' is specified. This works only on desktops.
|
// 'ebitendebug' is specified. This works only on desktops.
|
||||||
//
|
//
|
||||||
// `EBITEN_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 can take one of the following value:
|
// This can take one of the following value:
|
||||||
//
|
//
|
||||||
@ -74,7 +74,7 @@
|
|||||||
// "directx": DirectX. This works only on Windows.
|
// "directx": DirectX. This works only on Windows.
|
||||||
// "metal": Metal. This works only on macOS or iOS.
|
// "metal": Metal. This works only on macOS or iOS.
|
||||||
//
|
//
|
||||||
// `EBITEN_DIRECTX` environment variable specifies various parameters for DirectX.
|
// `EBITENGINE_DIRECTX` environment variable specifies various parameters for DirectX.
|
||||||
// You can specify multiple values separated by a comma. The default value is empty (i.e. no parameters).
|
// You can specify multiple values separated by a comma. The default value is empty (i.e. no parameters).
|
||||||
//
|
//
|
||||||
// "warp": Use WARP (i.e. software rendering).
|
// "warp": Use WARP (i.e. software rendering).
|
||||||
|
@ -98,16 +98,27 @@ type imageDumper struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func envScreenshotKey() string {
|
||||||
|
if env := os.Getenv("EBITENGINE_SCREENSHOT_KEY"); env != "" {
|
||||||
|
return env
|
||||||
|
}
|
||||||
|
// For backward compatibility, read the EBITEN_ version.
|
||||||
|
return os.Getenv("EBITEN_SCREENSHOT_KEY")
|
||||||
|
}
|
||||||
|
|
||||||
|
func envInternalImagesKey() string {
|
||||||
|
if env := os.Getenv("EBITENGINE_INTERNAL_IMAGES_KEY"); env != "" {
|
||||||
|
return env
|
||||||
|
}
|
||||||
|
// For backward compatibility, read the EBITEN_ version.
|
||||||
|
return os.Getenv("EBITEN_INTERNAL_IMAGES_KEY")
|
||||||
|
}
|
||||||
|
|
||||||
func (i *imageDumper) update() error {
|
func (i *imageDumper) update() error {
|
||||||
if i.err != nil {
|
if i.err != nil {
|
||||||
return i.err
|
return i.err
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
envScreenshotKey = "EBITEN_SCREENSHOT_KEY"
|
|
||||||
envInternalImagesKey = "EBITEN_INTERNAL_IMAGES_KEY"
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := i.g.Update(); err != nil {
|
if err := i.g.Update(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -116,14 +127,14 @@ func (i *imageDumper) update() error {
|
|||||||
if i.keyState == nil {
|
if i.keyState == nil {
|
||||||
i.keyState = map[Key]int{}
|
i.keyState = map[Key]int{}
|
||||||
|
|
||||||
if keyname := os.Getenv(envScreenshotKey); keyname != "" {
|
if keyname := envScreenshotKey(); keyname != "" {
|
||||||
if key, ok := keyNameToKeyCode(keyname); ok {
|
if key, ok := keyNameToKeyCode(keyname); ok {
|
||||||
i.hasScreenshotKey = true
|
i.hasScreenshotKey = true
|
||||||
i.screenshotKey = key
|
i.screenshotKey = key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if keyname := os.Getenv(envInternalImagesKey); keyname != "" {
|
if keyname := envInternalImagesKey(); keyname != "" {
|
||||||
if isDebug {
|
if isDebug {
|
||||||
if key, ok := keyNameToKeyCode(keyname); ok {
|
if key, ok := keyNameToKeyCode(keyname); ok {
|
||||||
i.hasDumpInternalImagesKey = true
|
i.hasDumpInternalImagesKey = true
|
||||||
|
@ -152,7 +152,12 @@ func (g *Graphics) initialize() (ferr error) {
|
|||||||
useWARP bool
|
useWARP bool
|
||||||
useDebugLayer bool
|
useDebugLayer bool
|
||||||
)
|
)
|
||||||
for _, t := range strings.Split(os.Getenv("EBITEN_DIRECTX"), ",") {
|
env := os.Getenv("EBITENGINE_DIRECTX")
|
||||||
|
if env == "" {
|
||||||
|
// For backward compatibility, read the EBITEN_ version.
|
||||||
|
env = os.Getenv("EBITEN_DIRECTX")
|
||||||
|
}
|
||||||
|
for _, t := range strings.Split(env, ",") {
|
||||||
switch strings.TrimSpace(t) {
|
switch strings.TrimSpace(t) {
|
||||||
case "warp":
|
case "warp":
|
||||||
// TODO: Is WARP available on Xbox?
|
// TODO: Is WARP available on Xbox?
|
||||||
|
@ -29,9 +29,15 @@ type graphicsDriverCreator interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newGraphicsDriver(creator graphicsDriverCreator) (graphicsdriver.Graphics, error) {
|
func newGraphicsDriver(creator graphicsDriverCreator) (graphicsdriver.Graphics, error) {
|
||||||
const envName = "EBITEN_GRAPHICS_LIBRARY"
|
envName := "EBITENGINE_GRAPHICS_LIBRARY"
|
||||||
|
env := os.Getenv(envName)
|
||||||
|
if env == "" {
|
||||||
|
// For backward compatibility, read the EBITEN_ version.
|
||||||
|
envName = "EBITEN_GRAPHICS_LIBRARY"
|
||||||
|
env = os.Getenv(envName)
|
||||||
|
}
|
||||||
|
|
||||||
switch env := os.Getenv(envName); env {
|
switch env {
|
||||||
case "", "auto":
|
case "", "auto":
|
||||||
g, err := creator.newAuto()
|
g, err := creator.newAuto()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user