doc.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Copyright 2014 Hajime Hoshi
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Package ebiten provides graphics and input API to develop a 2D game.
  15. //
  16. // You can start the game by calling the function RunGame.
  17. //
  18. // // Game implements ebiten.Game interface.
  19. // type Game struct{}
  20. //
  21. // // Update proceeds the game state.
  22. // // Update is called every tick (1/60 [s] by default).
  23. // func (g *Game) Update() error {
  24. // // Write your game's logical update.
  25. // return nil
  26. // }
  27. //
  28. // // Draw draws the game screen.
  29. // // Draw is called every frame (typically 1/60[s] for 60Hz display).
  30. // func (g *Game) Draw(screen *ebiten.Image) {
  31. // // Write your game's rendering.
  32. // }
  33. //
  34. // // Layout takes the outside size (e.g., the window size) and returns the (logical) screen size.
  35. // // If you don't have to adjust the screen size with the outside size, just return a fixed size.
  36. // func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
  37. // return 320, 240
  38. // }
  39. //
  40. // func main() {
  41. // game := &Game{}
  42. // // Specify the window size as you like. Here, a doubled size is specified.
  43. // ebiten.SetWindowSize(640, 480)
  44. // ebiten.SetWindowTitle("Your game's title")
  45. // // Call ebiten.RunGame to start your game loop.
  46. // if err := ebiten.RunGame(game); err != nil {
  47. // log.Fatal(err)
  48. // }
  49. // }
  50. //
  51. // In the API document, 'the main thread' means the goroutine in init(), main() and their callees without 'go'
  52. // statement. It is assured that 'the main thread' runs on the OS main thread. There are some Ebitengine functions (e.g.,
  53. // DeviceScaleFactor) that must be called on the main thread under some conditions (typically, before ebiten.RunGame
  54. // is called).
  55. //
  56. // # Environment variables
  57. //
  58. // `EBITENGINE_SCREENSHOT_KEY` environment variable specifies the key
  59. // to take a screenshot. For example, if you run your game with
  60. // `EBITENGINE_SCREENSHOT_KEY=q`, you can take a game screen's screenshot
  61. // by pressing Q key. This works only on desktops and browsers.
  62. //
  63. // `EBITENGINE_INTERNAL_IMAGES_KEY` environment variable specifies the key
  64. // to dump all the internal images. This is valid only when the build tag
  65. // 'ebitenginedebug' is specified. This works only on desktops and browsers.
  66. //
  67. // `EBITENGINE_GRAPHICS_LIBRARY` environment variable specifies the graphics library.
  68. // If the specified graphics library is not available, RunGame returns an error.
  69. // This environment variable works when RunGame is called or RunGameWithOptions is called with GraphicsLibraryAuto.
  70. // This can take one of the following value:
  71. //
  72. // "auto": Ebitengine chooses the graphics library automatically. This is the default value.
  73. // "opengl": OpenGL, OpenGL ES, or WebGL.
  74. // "directx": DirectX. This works only on Windows.
  75. // "metal": Metal. This works only on macOS or iOS.
  76. // "playstation5": PlayStation 5. This works only on PlayStation 5.
  77. //
  78. // `EBITENGINE_DIRECTX` environment variable specifies various parameters for DirectX.
  79. // You can specify multiple values separated by a comma. The default value is empty (i.e. no parameters).
  80. //
  81. // "debug": Use a debug layer.
  82. // "warp": Use WARP (i.e. software rendering).
  83. // "version=VERSION": Specify a DirectX version (e.g. 11).
  84. // "featurelevel=FEATURE_LEVEL": Specify a feature level (e.g. 11_0). This is for DirectX 12.
  85. //
  86. // The options taking arguments are exclusive, and if multiples are specified, the lastly specified value is adopted.
  87. //
  88. // The possible values for the option "version" are "11" and "12".
  89. // If the version is not specified, the default version 11 is adopted.
  90. // On Xbox, the "version" option is ignored and DirectX 12 is always adopted.
  91. //
  92. // The option "featurelevel" is valid only for DirectX 12.
  93. // The possible values are "11_0", "11_1", "12_0", "12_1", and "12_2". The default value is "11_0".
  94. //
  95. // # Build tags
  96. //
  97. // `ebitenginedebug` outputs a log of graphics commands. This is useful to know what happens in Ebitengine. In general, the
  98. // number of graphics commands affects the performance of your game.
  99. //
  100. // `ebitenginegldebug` enables a debug mode for OpenGL. This is valid only when the graphics library is OpenGL.
  101. // This affects performance very much.
  102. //
  103. // `ebitenginesinglethread` disables Ebitengine's thread safety to unlock maximum performance. If you use this you will have
  104. // to manage threads yourself. Functions like `SetWindowSize` will no longer be concurrent-safe with this build tag.
  105. // They must be called from the main thread or the same goroutine as the given game's callback functions like Update
  106. // `ebitenginesinglethread` works only with desktops and consoles.
  107. // `ebitenginesinglethread` was deprecated as of v2.7. Use RunGameOptions.SingleThread instead.
  108. //
  109. // `microsoftgdk` is for Microsoft GDK (e.g. Xbox).
  110. //
  111. // `nintendosdk` is for NintendoSDK (e.g. Nintendo Switch).
  112. //
  113. // `nintendosdkprofile` enables a profiler for NintendoSDK.
  114. //
  115. // `playstation5` is for PlayStation 5.
  116. package ebiten