graphics.go 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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
  15. import (
  16. "github.com/hajimehoshi/ebiten/v2/internal/builtinshader"
  17. "github.com/hajimehoshi/ebiten/v2/internal/ui"
  18. )
  19. // Filter represents the type of texture filter to be used when an image is magnified or minified.
  20. type Filter int
  21. const (
  22. // FilterNearest represents nearest (crisp-edged) filter
  23. FilterNearest Filter = Filter(builtinshader.FilterNearest)
  24. // FilterLinear represents linear filter
  25. FilterLinear Filter = Filter(builtinshader.FilterLinear)
  26. )
  27. // GraphicsLibrary represents graphics libraries supported by the engine.
  28. type GraphicsLibrary int
  29. const (
  30. // GraphicsLibraryAuto represents the automatic choose of graphics library by Ebitengine.
  31. GraphicsLibraryAuto GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryAuto)
  32. // GraphicsLibraryUnknown represents the state at which graphics library cannot be determined,
  33. // e.g. hasn't loaded yet or failed to initialize.
  34. GraphicsLibraryUnknown GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryUnknown)
  35. // GraphicsLibraryOpenGL represents the graphics library OpenGL.
  36. GraphicsLibraryOpenGL GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryOpenGL)
  37. // GraphicsLibraryDirectX represents the graphics library Microsoft DirectX.
  38. GraphicsLibraryDirectX GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryDirectX)
  39. // GraphicsLibraryMetal represents the graphics library Apple's Metal.
  40. GraphicsLibraryMetal GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryMetal)
  41. // GraphicsLibraryMetal represents the graphics library PlayStation 5.
  42. GraphicsLibraryPlayStation5 GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryPlayStation5)
  43. )
  44. // String returns a string representing the graphics library.
  45. func (g GraphicsLibrary) String() string {
  46. return ui.GraphicsLibrary(g).String()
  47. }
  48. // Ensures GraphicsLibraryAuto is zero (the default value for RunOptions).
  49. var _ [GraphicsLibraryAuto]int = [0]int{}
  50. // DebugInfo is a struct to store debug info about the graphics.
  51. type DebugInfo struct {
  52. // GraphicsLibrary represents the graphics library currently in use.
  53. GraphicsLibrary GraphicsLibrary
  54. }
  55. // ReadDebugInfo writes debug info (e.g. current graphics library) into a provided struct.
  56. func ReadDebugInfo(d *DebugInfo) {
  57. d.GraphicsLibrary = GraphicsLibrary(ui.Get().GraphicsLibrary())
  58. }
  59. // ColorSpace represents the color space of the screen.
  60. type ColorSpace int
  61. const (
  62. // ColorSpaceDefault represents the default color space.
  63. ColorSpaceDefault ColorSpace = iota
  64. // ColorSpaceSRGB represents the sRGB color space (https://en.wikipedia.org/wiki/SRGB).
  65. ColorSpaceSRGB
  66. // ColorSpaceDisplayP3 represents the Display P3 color space (https://en.wikipedia.org/wiki/DCI-P3).
  67. ColorSpaceDisplayP3
  68. )