BsWin32Window.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #pragma once
  2. #include "BsWin32Prerequisites.h"
  3. #include "BsRenderWindow.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Render window implementation for Windows.
  8. */
  9. class BS_RSGL_EXPORT Win32Window : public RenderWindow
  10. {
  11. public:
  12. ~Win32Window();
  13. /**
  14. * @copydoc RenderWindow::setFullscreen(UINT32, UINT32, float, UINT32)
  15. */
  16. void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
  17. /**
  18. * @copydoc RenderWindow::setFullscreen(const VideoMode&)
  19. */
  20. void setFullscreen(const VideoMode& mode);
  21. /**
  22. * @copydoc RenderWindow::setWindowed
  23. */
  24. void setWindowed(UINT32 width, UINT32 height);
  25. /**
  26. * @copydoc RenderWindow::setHidden
  27. */
  28. void setHidden(bool hidden);
  29. /**
  30. * @copydoc RenderWindow::isActive
  31. */
  32. bool isActive() const;
  33. /**
  34. * @copydoc RenderWindow::isVisible
  35. */
  36. bool isVisible() const;
  37. /**
  38. * @copydoc RenderWindow::isClosed
  39. */
  40. bool isClosed() const;
  41. /**
  42. * @copydoc RenderWindow::move
  43. */
  44. void move(INT32 left, INT32 top);
  45. /**
  46. * @copydoc RenderWindow::resize
  47. */
  48. void resize(UINT32 width, UINT32 height);
  49. /**
  50. * @copydoc RenderWindow::copyContentsToMemory
  51. */
  52. void copyToMemory(const PixelData &dst, FrameBuffer buffer);
  53. /**
  54. * @copydoc RenderWindow::swapBuffers
  55. */
  56. void swapBuffers();
  57. /**
  58. * @copydoc RenderWindow::requiresTextureFlipping
  59. */
  60. bool requiresTextureFlipping() const { return false; }
  61. /**
  62. * @copydoc RenderWindow::screenToWindowPos
  63. */
  64. Vector2I screenToWindowPos(const Vector2I& screenPos) const;
  65. /**
  66. * @copydoc RenderWindow::windowToScreenPos
  67. */
  68. Vector2I windowToScreenPos(const Vector2I& windowPos) const;
  69. /**
  70. * @copydoc RenderWindow::getCustomAttribute
  71. */
  72. void getCustomAttribute(const String& name, void* pData) const;
  73. /**
  74. * @copydoc RenderWindow::setActive
  75. */
  76. virtual void setActive(bool state);
  77. /**
  78. * @copydoc RenderWindow::_windowMovedOrResized
  79. */
  80. void _windowMovedOrResized();
  81. /**
  82. * @brief Returns handle to device context associated with the window.
  83. */
  84. HDC _getHDC() const { return mHDC; }
  85. protected:
  86. friend class GLRenderWindowManager;
  87. friend class Win32GLSupport;
  88. Win32Window(const RENDER_WINDOW_DESC& desc, Win32GLSupport &glsupport);
  89. /**
  90. * @copydoc RenderWindow::initialize_internal().
  91. */
  92. void initialize_internal();
  93. /**
  94. * @copydoc RenderWindow::destroy_internal().
  95. */
  96. void destroy_internal();
  97. /**
  98. * @brief Calculates window size based on provided client area size and currently set window style.
  99. */
  100. void getAdjustedWindowSize(UINT32 clientWidth, UINT32 clientHeight, UINT32* winWidth, UINT32* winHeight);
  101. protected:
  102. Win32GLSupport &mGLSupport;
  103. HWND mHWnd;
  104. HDC mHDC;
  105. DWORD mWindowedStyle;
  106. DWORD mWindowedStyleEx;
  107. bool mIsExternal;
  108. bool mIsChild;
  109. char* mDeviceName;
  110. bool mIsExternalGLControl;
  111. bool mSizing;
  112. bool mClosed;
  113. int mDisplayFrequency;
  114. Win32Context *mContext;
  115. };
  116. }