2
0

NativeWindow.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef ANKI_CORE_NATIVE_WINDOW_H
  2. #define ANKI_CORE_NATIVE_WINDOW_H
  3. #include "anki/util/StdTypes.h"
  4. #include "anki/util/Array.h"
  5. #include <string>
  6. #include <memory>
  7. namespace anki {
  8. struct NativeWindowImpl;
  9. /// Window initializer
  10. struct NativeWindowInitializer
  11. {
  12. Array<U32, 4> rgbaBits = {{8, 8, 8, 8}};
  13. U32 depthBits = 24;
  14. U32 stencilBits = 8;
  15. U32 samplesCount = 0;
  16. static const Bool doubleBuffer = true;
  17. U32 minorVersion = 0;
  18. U32 majorVersion = 0;
  19. Bool useGles = false; ///< Use OpenGL ES
  20. U32 width = 640;
  21. U32 height = 768;
  22. std::string title = "Untitled";
  23. };
  24. /// Native window with GL context
  25. class NativeWindow
  26. {
  27. public:
  28. NativeWindow()
  29. {}
  30. ~NativeWindow();
  31. /// @name Accessors
  32. /// @{
  33. NativeWindowImpl& getNative()
  34. {
  35. ANKI_ASSERT(isCreated());
  36. return *impl;
  37. }
  38. U32 getWidth() const
  39. {
  40. return width;
  41. }
  42. U32 getHeight() const
  43. {
  44. return height;
  45. }
  46. /// @}
  47. /// @name Public interface
  48. /// Don't implement them in .h files
  49. /// @{
  50. void create(NativeWindowInitializer& initializer);
  51. void destroy();
  52. void swapBuffers();
  53. /// @}
  54. private:
  55. U32 width;
  56. U32 height;
  57. std::shared_ptr<NativeWindowImpl> impl;
  58. Bool isCreated() const
  59. {
  60. return impl.get() != nullptr;
  61. }
  62. };
  63. } // end namespace anki
  64. #endif