NativeWindow.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (C) 2009-2022, 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. Bool m_exclusiveFullscreen = false;
  28. CString m_title = "AnKi";
  29. };
  30. /// Native window.
  31. class NativeWindow
  32. {
  33. public:
  34. static Error newInstance(const NativeWindowInitInfo& initInfo, NativeWindow*& nativeWindow);
  35. static void deleteInstance(NativeWindow* nativeWindow);
  36. U32 getWidth() const
  37. {
  38. return m_width;
  39. }
  40. U32 getHeight() const
  41. {
  42. return m_height;
  43. }
  44. F32 getAspectRatio() const
  45. {
  46. return F32(m_width) / F32(m_height);
  47. }
  48. void setWindowTitle(CString title);
  49. protected:
  50. U32 m_width = 0;
  51. U32 m_height = 0;
  52. HeapAllocator<U8> m_alloc;
  53. NativeWindow()
  54. {
  55. }
  56. ~NativeWindow()
  57. {
  58. }
  59. };
  60. } // end namespace anki