00001 00002 /* 00003 ----------------------------------------------------------------------------- 00004 This source file is part of OGRE 00005 (Object-oriented Graphics Rendering Engine) 00006 For the latest info, see http://www.ogre3d.org/ 00007 00008 Copyright (c) 2000-2013 Torus Knot Software Ltd 00009 00010 Permission is hereby granted, free of charge, to any person obtaining a copy 00011 of this software and associated documentation files (the "Software"), to deal 00012 in the Software without restriction, including without limitation the rights 00013 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00014 copies of the Software, and to permit persons to whom the Software is 00015 furnished to do so, subject to the following conditions: 00016 00017 The above copyright notice and this permission notice shall be included in 00018 all copies or substantial portions of the Software. 00019 00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00021 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00023 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00024 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00025 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00026 THE SOFTWARE. 00027 ----------------------------------------------------------------------------- 00028 */ 00029 #ifndef __D3D11RENDERWINDOW_H__ 00030 #define __D3D11RENDERWINDOW_H__ 00031 00032 #include "OgreD3D11Prerequisites.h" 00033 #include "OgreRenderWindow.h" 00034 00035 #if OGRE_PLATFORM == OGRE_PLATFORM_WINRT 00036 #pragma warning( disable : 4451 ) // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/314b5826-0a66-4307-abfe-87b8052c3c07/ 00037 00038 # include <agile.h> 00039 # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP) 00040 # include <windows.ui.xaml.media.dxinterop.h> 00041 # endif 00042 00043 #endif 00044 00045 namespace Ogre 00046 { 00047 class D3D11RenderWindowBase 00048 : public RenderWindow 00049 { 00050 public: 00051 D3D11RenderWindowBase(D3D11Device& device, IDXGIFactoryN* pDXGIFactory); 00052 ~D3D11RenderWindowBase(); 00053 virtual void create(const String& name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams); 00054 virtual void destroy(void); 00055 00056 void reposition(int left, int top) {} 00057 void resize(unsigned int width, unsigned int height) {} 00058 00059 bool isClosed() const { return mClosed; } 00060 bool isHidden() const { return mHidden; } 00061 00062 void getCustomAttribute( const String& name, void* pData ); 00065 virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer); 00066 bool requiresTextureFlipping() const { return false; } 00067 00068 protected: 00069 void _createSizeDependedD3DResources(); // assumes mpBackBuffer is already initialized 00070 void _destroySizeDependedD3DResources(); 00071 00072 IDXGIDeviceN* _queryDxgiDevice(); // release after use 00073 00074 // just check if the multisampling requested is supported by the device 00075 bool _checkMultiSampleQuality(UINT SampleCount, UINT *outQuality, DXGI_FORMAT format); 00076 00077 void _updateViewportsDimensions(); 00078 00079 protected: 00080 D3D11Device & mDevice; // D3D11 driver 00081 IDXGIFactoryN* mpDXGIFactory; 00082 bool mIsExternal; // window not created by Ogre 00083 bool mSizing; 00084 bool mClosed; 00085 bool mHidden; 00086 00087 // ------------------------------------------------------- 00088 // DirectX-specific 00089 // ------------------------------------------------------- 00090 DXGI_SAMPLE_DESC mFSAAType; 00091 UINT mDisplayFrequency; 00092 bool mVSync; 00093 unsigned int mVSyncInterval; 00094 00095 // Window size depended resources - must be released before swapchain resize and recreated later 00096 ID3D11Texture2D* mpBackBuffer; 00097 ID3D11RenderTargetView* mRenderTargetView; 00098 ID3D11DepthStencilView* mDepthStencilView; 00099 }; 00100 00101 00102 class D3D11RenderWindowSwapChainBased 00103 : public D3D11RenderWindowBase 00104 { 00105 public: 00106 D3D11RenderWindowSwapChainBased(D3D11Device& device, IDXGIFactoryN* pDXGIFactory); 00107 ~D3D11RenderWindowSwapChainBased() { destroy(); } 00108 virtual void destroy(void); 00109 00111 DXGI_SWAP_CHAIN_DESC_N* getPresentationParameters(void) { return &mSwapChainDesc; } 00112 00113 void swapBuffers( ); 00114 00115 protected: 00116 void _createSizeDependedD3DResources(); // obtains mpBackBuffer from mpSwapChain 00117 void _createSwapChain(); 00118 virtual HRESULT _createSwapChainImpl(IDXGIDeviceN* pDXGIDevice) = 0; 00119 void _resizeSwapChainBuffers(unsigned width, unsigned height); 00120 00121 protected: 00122 // Pointer to swap chain 00123 IDXGISwapChainN * mpSwapChain; 00124 DXGI_SWAP_CHAIN_DESC_N mSwapChainDesc; 00125 }; 00126 00127 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 00128 00129 class D3D11RenderWindowHwnd 00130 : public D3D11RenderWindowSwapChainBased 00131 { 00132 public: 00133 D3D11RenderWindowHwnd(D3D11Device& device, IDXGIFactoryN* pDXGIFactory); 00134 ~D3D11RenderWindowHwnd() { destroy(); } 00135 virtual void create(const String& name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams); 00136 virtual void destroy(void); 00137 00138 bool isVisible() const; 00139 void setHidden(bool hidden); 00140 void reposition(int left, int top); 00141 void resize(unsigned int width, unsigned int height); 00142 void setFullscreen(bool fullScreen, unsigned int width, unsigned int height); 00143 00144 // Method for dealing with resize / move & 3d library 00145 void windowMovedOrResized(); 00146 00147 HWND getWindowHandle() const { return mHWnd; } 00148 void getCustomAttribute( const String& name, void* pData ); 00149 00150 protected: 00152 bool _getSwitchingFullscreen() const { return mSwitchingFullscreen; } 00154 void _finishSwitchingFullscreen(); 00155 00156 virtual HRESULT _createSwapChainImpl(IDXGIDeviceN* pDXGIDevice); 00157 void setActive(bool state); 00158 protected: 00159 HWND mHWnd; // Win32 window handle 00160 bool mSwitchingFullscreen; // Are we switching from fullscreen to windowed or vice versa 00161 }; 00162 00163 #endif 00164 00165 #if OGRE_PLATFORM == OGRE_PLATFORM_WINRT 00166 00167 class D3D11RenderWindowCoreWindow 00168 : public D3D11RenderWindowSwapChainBased 00169 { 00170 public: 00171 D3D11RenderWindowCoreWindow(D3D11Device& device, IDXGIFactoryN* pDXGIFactory); 00172 ~D3D11RenderWindowCoreWindow() { destroy(); } 00173 virtual void create(const String& name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams); 00174 virtual void destroy(void); 00175 00176 Windows::UI::Core::CoreWindow^ getCoreWindow() const { return mCoreWindow.Get(); } 00177 00178 bool isVisible() const; 00179 00180 // Method for dealing with resize / move & 3d library 00181 void windowMovedOrResized(); 00182 00183 protected: 00184 virtual HRESULT _createSwapChainImpl(IDXGIDeviceN* pDXGIDevice); 00185 00186 protected: 00187 Platform::Agile<Windows::UI::Core::CoreWindow> mCoreWindow; 00188 }; 00189 00190 #if (OGRE_PLATFORM == OGRE_PLATFORM_WINRT) && (OGRE_WINRT_TARGET_TYPE == DESKTOP_APP) 00191 00192 class D3D11RenderWindowImageSource 00193 : public D3D11RenderWindowBase 00194 { 00195 public: 00196 D3D11RenderWindowImageSource(D3D11Device& device, IDXGIFactoryN* pDXGIFactory); 00197 ~D3D11RenderWindowImageSource() { destroy(); } 00198 virtual void create(const String& name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams); 00199 virtual void destroy(void); 00200 00201 virtual void resize(unsigned int width, unsigned int height); 00202 virtual void update(bool swapBuffers = true); 00203 virtual void swapBuffers(); 00204 00205 virtual bool isVisible() const { return mImageSourceNative != NULL; } 00206 00207 Windows::UI::Xaml::Media::ImageBrush^ getImageBrush() const { return mBrush; } 00208 virtual void getCustomAttribute( const String& name, void* pData ); // "ImageBrush" -> Windows::UI::Xaml::Media::ImageBrush^ 00209 00210 protected: 00211 void _createSizeDependedD3DResources(); // creates mpBackBuffer 00212 00213 protected: 00214 Windows::UI::Xaml::Media::ImageBrush^ mBrush; // size independed 00215 Windows::UI::Xaml::Media::Imaging::SurfaceImageSource^ mImageSource; // size depended, can be NULL 00216 ISurfaceImageSourceNative* mImageSourceNative; // size depended, can be NULL 00217 }; 00218 #endif // (OGRE_PLATFORM == OGRE_PLATFORM_WINRT) && (OGRE_WINRT_TARGET_TYPE == DESKTOP_APP) 00219 00220 #endif 00221 00222 } 00223 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:41