BsD3D9RenderWindow.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #pragma once
  2. #include "BsD3D9Prerequisites.h"
  3. #include "BsRenderWindow.h"
  4. #include "BsD3D9Device.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Render window implementation for Windows.
  9. */
  10. class BS_D3D9_EXPORT D3D9RenderWindow : public RenderWindow
  11. {
  12. public:
  13. ~D3D9RenderWindow();
  14. /**
  15. * @copydoc RenderWindow::setFullscreen(UINT32, UINT32, float, UINT32)
  16. */
  17. void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
  18. /**
  19. * @copydoc RenderWindow::setFullscreen(const VideoMode&)
  20. */
  21. void setFullscreen(const VideoMode& mode);
  22. /**
  23. * @copydoc RenderWindow::setWindowed
  24. */
  25. void setWindowed(UINT32 width, UINT32 height);
  26. /**
  27. * @copydoc RenderWindow::setHidden
  28. */
  29. void setHidden(bool hidden);
  30. /**
  31. * @copydoc RenderWindow::isActive
  32. */
  33. bool isActive() const;
  34. /**
  35. * @copydoc RenderWindow::isVisible
  36. */
  37. bool isVisible() const;
  38. /**
  39. * @copydoc RenderWindow::isClosed
  40. */
  41. bool isClosed() const { return mClosed; }
  42. /**
  43. * @copydoc RenderWindow::isVSync
  44. */
  45. bool isVSync() const { return mVSync; }
  46. /**
  47. * @copydoc RenderWindow::move
  48. */
  49. void move(INT32 left, INT32 top);
  50. /**
  51. * @copydoc RenderWindow::resize
  52. */
  53. void resize(UINT32 width, UINT32 height);
  54. /**
  55. * @copydoc RenderWindow::getCustomAttribute
  56. */
  57. void getCustomAttribute(const String& name, void* pData) const;
  58. /**
  59. * @copydoc RenderWindow::copyContentsToMemory
  60. */
  61. void copyToMemory(const PixelData &dst, FrameBuffer buffer);
  62. /**
  63. * @copydoc RenderWindow::requiresTextureFlipping
  64. */
  65. bool requiresTextureFlipping() const { return false; }
  66. /**
  67. * @copydoc RenderWindow::swapBuffers
  68. */
  69. void swapBuffers();
  70. /**
  71. * @copydoc RenderWindow::screenToWindowPos
  72. */
  73. Vector2I screenToWindowPos(const Vector2I& screenPos) const;
  74. /**
  75. * @copydoc RenderWindow::windowToScreenPos
  76. */
  77. Vector2I windowToScreenPos(const Vector2I& windowPos) const;
  78. /**
  79. * @copydoc RenderWindow::_windowMovedOrResized
  80. */
  81. void _windowMovedOrResized();
  82. /**
  83. * @brief Gets internal Win32 window handle.
  84. */
  85. HWND _getWindowHandle() const { return mHWnd; }
  86. /**
  87. * @brief Gets the DirectX 9 device object that manages this window.
  88. */
  89. IDirect3DDevice9* _getD3D9Device() const;
  90. /**
  91. * @brief Gets the device that manages this window.
  92. */
  93. D3D9Device* _getDevice() const;
  94. /**
  95. * @brief Sets the device that manages this window.
  96. */
  97. void _setDevice(D3D9Device* device);
  98. /**
  99. * @brief Build the presentation parameters used with this window.
  100. */
  101. void _buildPresentParameters(D3DPRESENT_PARAMETERS* presentParams) const;
  102. /**
  103. * @brief Accessor for render surface.
  104. */
  105. IDirect3DSurface9* _getRenderSurface() const;
  106. /**
  107. * @brief Returns true if this window use depth buffer.
  108. */
  109. bool _isDepthBuffered() const;
  110. /**
  111. * @brief Validate the device for this window.
  112. */
  113. bool _validateDevice();
  114. protected:
  115. friend class D3D9RenderWindowManager;
  116. D3D9RenderWindow(const RENDER_WINDOW_DESC& desc, HINSTANCE instance);
  117. /**
  118. * @brief Updates window coordinates and size from actual values provided by Windows.
  119. */
  120. void updateWindowRect();
  121. /**
  122. * @copydoc RenderWindow::initialize_internal().
  123. */
  124. void initialize_internal();
  125. /**
  126. * @copydoc RenderWindow::destroy_internal().
  127. */
  128. void destroy_internal();
  129. /**
  130. * @brief Calculates window size based on provided client area size and currently set window style.
  131. */
  132. void getAdjustedWindowSize(UINT32 clientWidth, UINT32 clientHeight,
  133. DWORD style, UINT32* winWidth, UINT32* winHeight);
  134. protected:
  135. HINSTANCE mInstance;
  136. D3D9Device* mDevice;
  137. bool mDeviceValid;
  138. HWND mHWnd;
  139. bool mIsExternal;
  140. bool mClosed;
  141. D3DMULTISAMPLE_TYPE mMultisampleType;
  142. DWORD mMultisampleQuality;
  143. UINT mDisplayFrequency;
  144. bool mVSync;
  145. unsigned int mVSyncInterval;
  146. DWORD mStyle;
  147. DWORD mWindowedStyle;
  148. DWORD mWindowedStyleEx;
  149. bool mIsDepthBuffered;
  150. bool mIsChild;
  151. };
  152. }