CmD3D9RenderWindow.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #ifndef __D3D9RENDERWINDOW_H__
  25. #define __D3D9RENDERWINDOW_H__
  26. #include "CmD3D9Prerequisites.h"
  27. #include "CmRenderWindow.h"
  28. #include "CmD3D9Device.h"
  29. namespace CamelotEngine
  30. {
  31. class _OgreD3D9Export D3D9RenderWindow : public RenderWindow
  32. {
  33. public:
  34. /** Constructor.
  35. @param instance The application instance
  36. @param driver The root driver
  37. @param deviceIfSwapChain The existing D3D device to create an additional swap chain from, if this is not
  38. the first window.
  39. */
  40. D3D9RenderWindow (HINSTANCE instance);
  41. ~D3D9RenderWindow ();
  42. void create (const String& name, unsigned int width, unsigned int height,
  43. bool fullScreen, const NameValuePairList *miscParams);
  44. void setFullscreen (bool fullScreen, unsigned int width, unsigned int height);
  45. void destroy (void);
  46. bool isActive () const;
  47. bool isVisible () const;
  48. bool isClosed () const { return mClosed; }
  49. bool isVSync () const { return mVSync; }
  50. void reposition (int left, int top);
  51. void resize (unsigned int width, unsigned int height);
  52. void swapBuffers ( bool waitForVSync = true );
  53. HWND getWindowHandle () const { return mHWnd; }
  54. IDirect3DDevice9* getD3D9Device ();
  55. D3D9Device* getDevice ();
  56. void setDevice (D3D9Device* device);
  57. void getCustomAttribute (const String& name, void* pData);
  58. /** Overridden - see RenderTarget.
  59. */
  60. void copyContentsToMemory (const PixelData &dst, FrameBuffer buffer);
  61. bool requiresTextureFlipping () const { return false; }
  62. // Method for dealing with resize / move & 3d library
  63. void windowMovedOrResized ();
  64. /// Build the presentation parameters used with this window
  65. void buildPresentParameters (D3DPRESENT_PARAMETERS* presentParams);
  66. /// @copydoc RenderTarget::_beginUpdate
  67. void _beginUpdate();
  68. /// @copydoc RenderTarget::_updateViewport
  69. void _updateViewport(Viewport* viewport, bool updateStatistics = true);
  70. /// @copydoc RenderTarget::_endUpdate
  71. void _endUpdate();
  72. /// Accessor for render surface
  73. IDirect3DSurface9* getRenderSurface();
  74. /// Are we in the middle of switching between fullscreen and windowed
  75. bool _getSwitchingFullscreen() const;
  76. /// Indicate that fullscreen / windowed switching has finished
  77. void _finishSwitchingFullscreen();
  78. /// Returns true if this window use depth buffer.
  79. bool isDepthBuffered() const;
  80. /// Returns true if this window should use NV perf hud adapter.
  81. bool isNvPerfHUDEnable() const;
  82. /** Validate the device for this window. */
  83. bool _validateDevice();
  84. void adjustWindow(unsigned int clientWidth, unsigned int clientHeight,
  85. DWORD style, unsigned int* winWidth, unsigned int* winHeight);
  86. protected:
  87. HINSTANCE mInstance; // Process instance
  88. D3D9Device* mDevice; // D3D9 device wrapper class.
  89. bool mDeviceValid; // Device was validation succeeded.
  90. HWND mHWnd; // Win32 Window handle
  91. bool mIsExternal; // window not created by Ogre
  92. bool mClosed; // Is this window destroyed.
  93. bool mSwitchingFullscreen; // Are we switching from fullscreen to windowed or vice versa
  94. D3DMULTISAMPLE_TYPE mFSAAType; // AA type.
  95. DWORD mFSAAQuality; // AA quality.
  96. UINT mDisplayFrequency; // Display frequency.
  97. bool mVSync; // Use vertical sync or not.
  98. unsigned int mVSyncInterval;
  99. bool mUseNVPerfHUD; // Use NV Perf HUD.
  100. DWORD mStyle; // Window style currently used for this window.
  101. // Desired width / height after resizing
  102. unsigned int mDesiredWidth;
  103. unsigned int mDesiredHeight;
  104. void updateWindowRect();
  105. };
  106. }
  107. #endif