NativeWindow.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Window/Common.h>
  7. #include <AnKi/Util/Array.h>
  8. #include <AnKi/Util/String.h>
  9. namespace anki {
  10. /// Window initializer
  11. class NativeWindowInitInfo
  12. {
  13. public:
  14. U32 m_width = 1920;
  15. U32 m_height = 1080;
  16. Array<U32, 4> m_rgbaBits = {8, 8, 8, 0};
  17. U32 m_depthBits = 0;
  18. U32 m_stencilBits = 0;
  19. U32 m_samplesCount = 0;
  20. U32 m_targetFps = 0;
  21. static constexpr Bool m_doubleBuffer = true;
  22. /// Create a fullscreen window with the desktop's resolution
  23. Bool m_fullscreenDesktopRez = false;
  24. Bool m_exclusiveFullscreen = false;
  25. Bool m_borderless = false;
  26. CString m_title = "AnKi";
  27. };
  28. /// Native window.
  29. class NativeWindow : public MakeSingletonPtr<NativeWindow>
  30. {
  31. template<typename>
  32. friend class MakeSingletonPtr;
  33. public:
  34. Error init(const NativeWindowInitInfo& inf);
  35. U32 getWidth() const
  36. {
  37. return m_width;
  38. }
  39. U32 getHeight() const
  40. {
  41. return m_height;
  42. }
  43. F32 getAspectRatio() const
  44. {
  45. return F32(m_width) / F32(m_height);
  46. }
  47. void setWindowTitle(CString title);
  48. protected:
  49. U32 m_width = 0;
  50. U32 m_height = 0;
  51. NativeWindow()
  52. {
  53. }
  54. ~NativeWindow()
  55. {
  56. }
  57. };
  58. template<>
  59. template<>
  60. NativeWindow& MakeSingletonPtr<NativeWindow>::allocateSingleton<>();
  61. template<>
  62. void MakeSingletonPtr<NativeWindow>::freeSingleton();
  63. } // end namespace anki