CmD3D11RenderWindow.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 move(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 copyToMemory(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. Vector2I screenToWindowPos(const Vector2I& screenPos) const;
  50. /**
  51. * @copydoc RenderWindow::windowToScreenPos
  52. */
  53. Vector2I windowToScreenPos(const Vector2I& 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 _windowMovedOrResized();
  63. DXGI_SWAP_CHAIN_DESC* _getPresentationParameters(void) { return &mSwapChainDesc; }
  64. HWND _getWindowHandle() const { return mHWnd; }
  65. protected:
  66. friend class D3D11RenderWindowManager;
  67. D3D11RenderWindow(const RENDER_WINDOW_DESC& desc, D3D11Device& device, IDXGIFactory* DXGIFactory);
  68. void createSizeDependedD3DResources();
  69. void destroySizeDependedD3DResources();
  70. IDXGIDevice* queryDxgiDevice();
  71. bool checkMultiSampleQuality(UINT32 SampleCount, UINT32 *outQuality, DXGI_FORMAT format);
  72. void createSwapChain();
  73. void resizeSwapChainBuffers(unsigned width, unsigned height);
  74. bool getSwitchingFullscreen() const { return mSwitchingFullscreen; }
  75. void finishSwitchingFullscreen();
  76. /**
  77. * @copydoc RenderWindow::initialize_internal().
  78. */
  79. void initialize_internal();
  80. /**
  81. * @copydoc RenderWindow::destroy_internal().
  82. */
  83. void destroy_internal();
  84. protected:
  85. D3D11Device& mDevice; // D3D11 driver
  86. IDXGIFactory* mDXGIFactory;
  87. bool mIsExternal;
  88. bool mSizing;
  89. bool mClosed;
  90. // -------------------------------------------------------
  91. // DirectX-specific
  92. // -------------------------------------------------------
  93. DXGI_SAMPLE_DESC mFSAAType;
  94. UINT mDisplayFrequency;
  95. bool mVSync;
  96. unsigned int mVSyncInterval;
  97. // Window size depended resources - must be released before swapchain resize and recreated later
  98. ID3D11Texture2D* mBackBuffer;
  99. ID3D11RenderTargetView* mRenderTargetView;
  100. TextureViewPtr mDepthStencilView;
  101. TexturePtr mDepthStencilBuffer;
  102. IDXGISwapChain* mSwapChain;
  103. DXGI_SWAP_CHAIN_DESC mSwapChainDesc;
  104. HWND mHWnd; // Win32 window handle
  105. bool mSwitchingFullscreen; // Are we switching from fullscreen to windowed or vice versa
  106. };
  107. }