NativeWindow.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. NativeWindowImpl& getNative()
  32. {
  33. ANKI_ASSERT(isCreated());
  34. return *impl;
  35. }
  36. /// @name Public interface
  37. /// Don't implement them in .h files
  38. /// @{
  39. void create(NativeWindowInitializer& initializer);
  40. void destroy();
  41. void swapBuffers();
  42. /// @}
  43. private:
  44. U32 width;
  45. U32 height;
  46. std::shared_ptr<NativeWindowImpl> impl;
  47. Bool isCreated() const
  48. {
  49. return impl.get() != nullptr;
  50. }
  51. };
  52. } // end namespace anki
  53. #endif