CmD3D11RenderWindow.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #pragma once
  2. #include "CmD3D11Prerequisites.h"
  3. #include "CmRenderWindow.h"
  4. namespace CamelotFramework
  5. {
  6. class CM_D3D11_EXPORT D3D11RenderWindow : public RenderWindow
  7. {
  8. public:
  9. ~D3D11RenderWindow();
  10. /**
  11. * @copydoc RenderWindow::reposition
  12. */
  13. void reposition(INT32 left, INT32 top);
  14. /**
  15. * @copydoc RenderWindow::resize
  16. */
  17. void resize(UINT32 width, UINT32 height);
  18. /**
  19. * @copydoc RenderWindow::setHidden
  20. */
  21. void setHidden(bool hidden);
  22. /**
  23. * @copydoc RenderWindow::setActive
  24. */
  25. void setActive(bool state);
  26. /**
  27. * @copydoc RenderWindow::setFullscreen
  28. */
  29. void setFullscreen(bool fullScreen, UINT32 width, UINT32 height);
  30. /**
  31. * @copydoc RenderWindow::copyContentsToMemory
  32. */
  33. void copyContentsToMemory(const PixelData &dst, FrameBuffer buffer);
  34. /**
  35. * @copydoc RenderWindow::swapBuffers
  36. */
  37. void swapBuffers();
  38. /**
  39. * @copydoc RenderWindow::isClosed
  40. */
  41. bool isClosed() const { return mClosed; }
  42. /**
  43. * @copydoc RenderWindow::isHidden
  44. */
  45. bool isHidden() const { return mHidden; }
  46. /**
  47. * @copydoc RenderWindow::screenToWindowPos
  48. */
  49. Int2 screenToWindowPos(const Int2& screenPos) const;
  50. /**
  51. * @copydoc RenderWindow::windowToScreenPos
  52. */
  53. Int2 windowToScreenPos(const Int2& windowPos) const;
  54. /**
  55. * @copydoc RenderWindow::getCustomAttribute
  56. */
  57. void getCustomAttribute(const String& name, void* pData) const;
  58. /**
  59. * @copydoc RenderWindow::requiresTextureFlipping
  60. */
  61. bool requiresTextureFlipping() const { return false; }
  62. void startResize(WindowResizeDirection direction);
  63. void endResize();
  64. void startMove();
  65. void endMove();
  66. /**
  67. * @copydoc RenderWindow::reposition
  68. */
  69. void _windowMovedOrResized();
  70. DXGI_SWAP_CHAIN_DESC* _getPresentationParameters(void) { return &mSwapChainDesc; }
  71. HWND _getWindowHandle() const { return mHWnd; }
  72. protected:
  73. friend class D3D11RenderWindowManager;
  74. D3D11RenderWindow(const RENDER_WINDOW_DESC& desc, D3D11Device& device, IDXGIFactory* DXGIFactory);
  75. void createSizeDependedD3DResources();
  76. void destroySizeDependedD3DResources();
  77. IDXGIDevice* queryDxgiDevice();
  78. bool checkMultiSampleQuality(UINT32 SampleCount, UINT32 *outQuality, DXGI_FORMAT format);
  79. void createSwapChain();
  80. void resizeSwapChainBuffers(unsigned width, unsigned height);
  81. bool getSwitchingFullscreen() const { return mSwitchingFullscreen; }
  82. void finishSwitchingFullscreen();
  83. /**
  84. * @copydoc RenderWindow::initialize_internal().
  85. */
  86. void initialize_internal();
  87. /**
  88. * @copydoc RenderWindow::destroy_internal().
  89. */
  90. void destroy_internal();
  91. protected:
  92. D3D11Device& mDevice; // D3D11 driver
  93. IDXGIFactory* mDXGIFactory;
  94. bool mIsExternal;
  95. bool mSizing;
  96. bool mClosed;
  97. bool mHidden;
  98. // -------------------------------------------------------
  99. // DirectX-specific
  100. // -------------------------------------------------------
  101. DXGI_SAMPLE_DESC mFSAAType;
  102. UINT mDisplayFrequency;
  103. bool mVSync;
  104. unsigned int mVSyncInterval;
  105. // Window size depended resources - must be released before swapchain resize and recreated later
  106. ID3D11Texture2D* mBackBuffer;
  107. ID3D11RenderTargetView* mRenderTargetView;
  108. TextureViewPtr mDepthStencilView;
  109. TexturePtr mDepthStencilBuffer;
  110. IDXGISwapChain* mSwapChain;
  111. DXGI_SWAP_CHAIN_DESC mSwapChainDesc;
  112. HWND mHWnd; // Win32 window handle
  113. bool mSwitchingFullscreen; // Are we switching from fullscreen to windowed or vice versa
  114. };
  115. }