NativeWindow.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. {
  13. class NativeWindowImpl;
  14. using Context = void*;
  15. /// Window initializer
  16. class NativeWindowInitInfo
  17. {
  18. public:
  19. U32 m_width = 1920;
  20. U32 m_height = 1080;
  21. Array<U32, 4> m_rgbaBits = {8, 8, 8, 0};
  22. U32 m_depthBits = 0;
  23. U32 m_stencilBits = 0;
  24. U32 m_samplesCount = 0;
  25. static const Bool m_doubleBuffer = true;
  26. /// Create a fullscreen window with the desktop's resolution
  27. Bool m_fullscreenDesktopRez = false;
  28. CString m_title = "AnKi";
  29. };
  30. /// Native window.
  31. class NativeWindow
  32. {
  33. public:
  34. NativeWindow()
  35. {
  36. }
  37. ~NativeWindow()
  38. {
  39. destroy();
  40. }
  41. ANKI_USE_RESULT Error init(NativeWindowInitInfo& initializer, HeapAllocator<U8>& alloc);
  42. U32 getWidth() const
  43. {
  44. return m_width;
  45. }
  46. U32 getHeight() const
  47. {
  48. return m_height;
  49. }
  50. void setWindowTitle(CString title);
  51. ANKI_INTERNAL HeapAllocator<U8> getAllocator() const
  52. {
  53. return m_alloc;
  54. }
  55. ANKI_INTERNAL NativeWindowImpl& getNative()
  56. {
  57. ANKI_ASSERT(isCreated());
  58. return *m_impl;
  59. }
  60. private:
  61. U32 m_width = 0;
  62. U32 m_height = 0;
  63. NativeWindowImpl* m_impl = nullptr;
  64. HeapAllocator<U8> m_alloc;
  65. Bool isCreated() const
  66. {
  67. return m_impl != nullptr;
  68. }
  69. void destroy();
  70. };
  71. } // end namespace anki