NativeWindow.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright (C) 2009-2021, 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/Core/Common.h>
  7. #include <AnKi/Util/StdTypes.h>
  8. #include <AnKi/Util/Array.h>
  9. #include <AnKi/Util/String.h>
  10. #include <AnKi/Util/Allocator.h>
  11. namespace anki {
  12. /// Window initializer
  13. class NativeWindowInitInfo
  14. {
  15. public:
  16. AllocAlignedCallback m_allocCallback = nullptr;
  17. void* m_allocCallbackUserData = nullptr;
  18. U32 m_width = 1920;
  19. U32 m_height = 1080;
  20. Array<U32, 4> m_rgbaBits = {8, 8, 8, 0};
  21. U32 m_depthBits = 0;
  22. U32 m_stencilBits = 0;
  23. U32 m_samplesCount = 0;
  24. static const Bool m_doubleBuffer = true;
  25. /// Create a fullscreen window with the desktop's resolution
  26. Bool m_fullscreenDesktopRez = false;
  27. CString m_title = "AnKi";
  28. };
  29. /// Native window.
  30. class NativeWindow
  31. {
  32. public:
  33. static ANKI_USE_RESULT Error newInstance(const NativeWindowInitInfo& initInfo, NativeWindow*& nativeWindow);
  34. static void deleteInstance(NativeWindow* nativeWindow);
  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. HeapAllocator<U8> m_alloc;
  52. NativeWindow()
  53. {
  54. }
  55. ~NativeWindow()
  56. {
  57. }
  58. };
  59. } // end namespace anki