NativeWindow.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include <AnKi/Util/CVarSet.h>
  10. namespace anki {
  11. ANKI_CVAR(NumericCVar<U32>, Window, Width, 1920, 16, 16 * 1024, "Width")
  12. ANKI_CVAR(NumericCVar<U32>, Window, Height, 1080, 16, 16 * 1024, "Height")
  13. ANKI_CVAR(NumericCVar<U32>, Window, Fullscreen, 1, 0, 2, "0: windowed, 1: borderless fullscreen, 2: exclusive fullscreen")
  14. ANKI_CVAR(BoolCVar, Window, Maximized, false, "Maximize")
  15. ANKI_CVAR(BoolCVar, Window, Borderless, false, "Borderless")
  16. /// Native window.
  17. class NativeWindow : public MakeSingletonPtr<NativeWindow>
  18. {
  19. template<typename>
  20. friend class MakeSingletonPtr;
  21. public:
  22. Error init(U32 targetFps, CString title);
  23. U32 getWidth() const
  24. {
  25. return m_width;
  26. }
  27. U32 getHeight() const
  28. {
  29. return m_height;
  30. }
  31. F32 getAspectRatio() const
  32. {
  33. return F32(m_width) / F32(m_height);
  34. }
  35. void setWindowTitle(CString title);
  36. protected:
  37. U32 m_width = 0;
  38. U32 m_height = 0;
  39. NativeWindow()
  40. {
  41. }
  42. ~NativeWindow()
  43. {
  44. }
  45. };
  46. template<>
  47. template<>
  48. NativeWindow& MakeSingletonPtr<NativeWindow>::allocateSingleton<>();
  49. template<>
  50. void MakeSingletonPtr<NativeWindow>::freeSingleton();
  51. } // end namespace anki