CmD3D9RenderWindow.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #pragma once
  25. #include "CmD3D9Prerequisites.h"
  26. #include "CmRenderWindow.h"
  27. #include "CmD3D9Device.h"
  28. namespace CamelotFramework
  29. {
  30. class CM_D3D9_EXPORT D3D9RenderWindow : public RenderWindow
  31. {
  32. public:
  33. ~D3D9RenderWindow();
  34. /**
  35. * @copydoc RenderWindow::setFullscreen
  36. */
  37. void setFullscreen(bool fullScreen, UINT32 width, UINT32 height);
  38. /**
  39. * @copydoc RenderWindow::setHidden
  40. */
  41. void setHidden(bool hidden);
  42. /**
  43. * @copydoc RenderWindow::isActive
  44. */
  45. bool isActive() const;
  46. /**
  47. * @copydoc RenderWindow::isVisible
  48. */
  49. bool isVisible() const;
  50. /**
  51. * @copydoc RenderWindow::isClosed
  52. */
  53. bool isClosed() const { return mClosed; }
  54. /**
  55. * @copydoc RenderWindow::isVSync
  56. */
  57. bool isVSync() const { return mVSync; }
  58. /**
  59. * @copydoc RenderWindow::reposition
  60. */
  61. void move(INT32 left, INT32 top);
  62. /**
  63. * @copydoc RenderWindow::resize
  64. */
  65. void resize(UINT32 width, UINT32 height);
  66. /**
  67. * @copydoc RenderWindow::getCustomAttribute
  68. */
  69. void getCustomAttribute(const String& name, void* pData) const;
  70. /**
  71. * @copydoc RenderWindow::copyContentsToMemory
  72. */
  73. void copyToMemory(const PixelData &dst, FrameBuffer buffer);
  74. /**
  75. * @copydoc RenderWindow::requiresTextureFlipping
  76. */
  77. bool requiresTextureFlipping() const { return false; }
  78. /**
  79. * @copydoc RenderWindow::swapBuffers
  80. */
  81. void swapBuffers();
  82. /**
  83. * @copydoc RenderWindow::screenToWindowPos
  84. */
  85. Vector2I screenToWindowPos(const Vector2I& screenPos) const;
  86. /**
  87. * @copydoc RenderWindow::windowToScreenPos
  88. */
  89. Vector2I windowToScreenPos(const Vector2I& windowPos) const;
  90. /**
  91. * @copydoc RenderWindow::_windowMovedOrResized
  92. */
  93. void _windowMovedOrResized ();
  94. HWND _getWindowHandle () const { return mHWnd; }
  95. IDirect3DDevice9* _getD3D9Device () const;
  96. D3D9Device* _getDevice () const;
  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 Are we in the middle of switching between fullscreen and windowed.
  108. */
  109. bool _getSwitchingFullscreen() const;
  110. /**
  111. * @brief Indicate that fullscreen / windowed switching has finished.
  112. */
  113. void _finishSwitchingFullscreen();
  114. /**
  115. * @brief Returns true if this window use depth buffer.
  116. */
  117. bool _isDepthBuffered() const;
  118. /**
  119. * @brief Validate the device for this window.
  120. */
  121. bool _validateDevice();
  122. void _adjustWindow(unsigned int clientWidth, unsigned int clientHeight,
  123. DWORD style, unsigned int* winWidth, unsigned int* winHeight);
  124. protected:
  125. friend class D3D9RenderWindowManager;
  126. D3D9RenderWindow (const RENDER_WINDOW_DESC& desc, HINSTANCE instance);
  127. void updateWindowRect();
  128. /**
  129. * @copydoc RenderWindow::initialize_internal().
  130. */
  131. void initialize_internal();
  132. /**
  133. * @copydoc RenderWindow::destroy_internal().
  134. */
  135. void destroy_internal();
  136. protected:
  137. HINSTANCE mInstance; // Process instance
  138. D3D9Device* mDevice; // D3D9 device wrapper class.
  139. bool mDeviceValid; // Device was validation succeeded.
  140. HWND mHWnd; // Win32 Window handle
  141. bool mIsExternal; // window not created by Ogre
  142. bool mClosed; // Is this window destroyed.
  143. bool mSwitchingFullscreen; // Are we switching from fullscreen to windowed or vice versa
  144. D3DMULTISAMPLE_TYPE mFSAAType; // AA type.
  145. DWORD mFSAAQuality; // AA quality.
  146. UINT mDisplayFrequency; // Display frequency.
  147. bool mVSync; // Use vertical sync or not.
  148. unsigned int mVSyncInterval;
  149. DWORD mStyle; // Window style currently used for this window.
  150. bool mIsDepthBuffered;
  151. // Desired width / height after resizing
  152. unsigned int mDesiredWidth;
  153. unsigned int mDesiredHeight;
  154. };
  155. }