OgreD3D11RenderWindow.h
Go to the documentation of this file.
1 
2 /*
3 -----------------------------------------------------------------------------
4 This source file is part of OGRE
5 (Object-oriented Graphics Rendering Engine)
6 For the latest info, see http://www.ogre3d.org/
7 
8 Copyright (c) 2000-2013 Torus Knot Software Ltd
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 -----------------------------------------------------------------------------
28 */
29 #ifndef __D3D11RENDERWINDOW_H__
30 #define __D3D11RENDERWINDOW_H__
31 
32 #include "OgreD3D11Prerequisites.h"
33 #include "OgreRenderWindow.h"
34 
35 #if OGRE_PLATFORM == OGRE_PLATFORM_WINRT
36 #pragma warning( disable : 4451 ) // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/314b5826-0a66-4307-abfe-87b8052c3c07/
37 
38 # include <agile.h>
39 # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP)
40 # include <windows.ui.xaml.media.dxinterop.h>
41 # endif
42 
43 #endif
44 
45 namespace Ogre
46 {
48  : public RenderWindow
49  {
50  public:
51  D3D11RenderWindowBase(D3D11Device& device, IDXGIFactoryN* pDXGIFactory);
53  virtual void create(const String& name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams);
54  virtual void destroy(void);
55 
56  void reposition(int left, int top) {}
57  void resize(unsigned int width, unsigned int height) {}
58 
59  bool isClosed() const { return mClosed; }
60  bool isHidden() const { return mHidden; }
61 
62  void getCustomAttribute( const String& name, void* pData );
65  virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer);
66  bool requiresTextureFlipping() const { return false; }
67 
68  protected:
69  void _createSizeDependedD3DResources(); // assumes mpBackBuffer is already initialized
71 
72  IDXGIDeviceN* _queryDxgiDevice(); // release after use
73 
74  // just check if the multisampling requested is supported by the device
75  bool _checkMultiSampleQuality(UINT SampleCount, UINT *outQuality, DXGI_FORMAT format);
76 
78 
79  protected:
80  D3D11Device & mDevice; // D3D11 driver
82  bool mIsExternal; // window not created by Ogre
83  bool mSizing;
84  bool mClosed;
85  bool mHidden;
86 
87  // -------------------------------------------------------
88  // DirectX-specific
89  // -------------------------------------------------------
90  DXGI_SAMPLE_DESC mFSAAType;
92  bool mVSync;
93  unsigned int mVSyncInterval;
94 
95  // Window size depended resources - must be released before swapchain resize and recreated later
96  ID3D11Texture2D* mpBackBuffer;
97  ID3D11RenderTargetView* mRenderTargetView;
98  ID3D11DepthStencilView* mDepthStencilView;
99  };
100 
101 
103  : public D3D11RenderWindowBase
104  {
105  public:
108  virtual void destroy(void);
109 
112 
113  void swapBuffers( );
114 
115  protected:
116  void _createSizeDependedD3DResources(); // obtains mpBackBuffer from mpSwapChain
117  void _createSwapChain();
118  virtual HRESULT _createSwapChainImpl(IDXGIDeviceN* pDXGIDevice) = 0;
119  void _resizeSwapChainBuffers(unsigned width, unsigned height);
120 
121  protected:
122  // Pointer to swap chain
125  };
126 
127 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
128 
131  {
132  public:
133  D3D11RenderWindowHwnd(D3D11Device& device, IDXGIFactoryN* pDXGIFactory);
135  virtual void create(const String& name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams);
136  virtual void destroy(void);
137 
138  bool isVisible() const;
139  void setHidden(bool hidden);
140  void reposition(int left, int top);
141  void resize(unsigned int width, unsigned int height);
142  void setFullscreen(bool fullScreen, unsigned int width, unsigned int height);
143 
144  // Method for dealing with resize / move & 3d library
145  void windowMovedOrResized();
146 
147  HWND getWindowHandle() const { return mHWnd; }
148  void getCustomAttribute( const String& name, void* pData );
149 
150  protected:
155 
156  virtual HRESULT _createSwapChainImpl(IDXGIDeviceN* pDXGIDevice);
157  void setActive(bool state);
158  protected:
159  HWND mHWnd; // Win32 window handle
160  bool mSwitchingFullscreen; // Are we switching from fullscreen to windowed or vice versa
161  };
162 
163 #endif
164 
165 #if OGRE_PLATFORM == OGRE_PLATFORM_WINRT
166 
169  {
170  public:
171  D3D11RenderWindowCoreWindow(D3D11Device& device, IDXGIFactoryN* pDXGIFactory);
173  virtual void create(const String& name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams);
174  virtual void destroy(void);
175 
176  Windows::UI::Core::CoreWindow^ getCoreWindow() const { return mCoreWindow.Get(); }
177 
178  bool isVisible() const;
179 
180  // Method for dealing with resize / move & 3d library
181  void windowMovedOrResized();
182 
183  protected:
184  virtual HRESULT _createSwapChainImpl(IDXGIDeviceN* pDXGIDevice);
185 
186  protected:
187  Platform::Agile<Windows::UI::Core::CoreWindow> mCoreWindow;
188  };
189 
190 #if (OGRE_PLATFORM == OGRE_PLATFORM_WINRT) && (OGRE_WINRT_TARGET_TYPE == DESKTOP_APP)
191 
193  : public D3D11RenderWindowBase
194  {
195  public:
198  virtual void create(const String& name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams);
199  virtual void destroy(void);
200 
201  virtual void resize(unsigned int width, unsigned int height);
202  virtual void update(bool swapBuffers = true);
203  virtual void swapBuffers();
204 
205  virtual bool isVisible() const { return mImageSourceNative != NULL; }
206 
207  Windows::UI::Xaml::Media::ImageBrush^ getImageBrush() const { return mBrush; }
208  virtual void getCustomAttribute( const String& name, void* pData ); // "ImageBrush" -> Windows::UI::Xaml::Media::ImageBrush^
209 
210  protected:
211  void _createSizeDependedD3DResources(); // creates mpBackBuffer
212 
213  protected:
214  Windows::UI::Xaml::Media::ImageBrush^ mBrush; // size independed
215  Windows::UI::Xaml::Media::Imaging::SurfaceImageSource^ mImageSource; // size depended, can be NULL
216  ISurfaceImageSourceNative* mImageSourceNative; // size depended, can be NULL
217  };
218 #endif // (OGRE_PLATFORM == OGRE_PLATFORM_WINRT) && (OGRE_WINRT_TARGET_TYPE == DESKTOP_APP)
219 
220 #endif
221 
222 }
223 #endif
Ogre::D3D11RenderWindowHwnd::D3D11RenderWindowHwnd
D3D11RenderWindowHwnd(D3D11Device &device, IDXGIFactoryN *pDXGIFactory)
Ogre::D3D11RenderWindowSwapChainBased::mSwapChainDesc
DXGI_SWAP_CHAIN_DESC_N mSwapChainDesc
Definition: OgreD3D11RenderWindow.h:124
Ogre::D3D11RenderWindowBase::copyContentsToMemory
virtual void copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer)
Overridden - see RenderTarget.
Ogre::D3D11RenderWindowSwapChainBased::_resizeSwapChainBuffers
void _resizeSwapChainBuffers(unsigned width, unsigned height)
Ogre::D3D11RenderWindowBase::D3D11RenderWindowBase
D3D11RenderWindowBase(D3D11Device &device, IDXGIFactoryN *pDXGIFactory)
Ogre::D3D11RenderWindowBase::reposition
void reposition(int left, int top)
Reposition the window.
Definition: OgreD3D11RenderWindow.h:56
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::D3D11RenderWindowCoreWindow::~D3D11RenderWindowCoreWindow
~D3D11RenderWindowCoreWindow()
Definition: OgreD3D11RenderWindow.h:172
Ogre::D3D11RenderWindowImageSource::~D3D11RenderWindowImageSource
~D3D11RenderWindowImageSource()
Definition: OgreD3D11RenderWindow.h:197
Ogre::D3D11RenderWindowHwnd::getWindowHandle
HWND getWindowHandle() const
Definition: OgreD3D11RenderWindow.h:147
Ogre::D3D11RenderWindowBase::mClosed
bool mClosed
Definition: OgreD3D11RenderWindow.h:84
Ogre::D3D11RenderWindowBase
Definition: OgreD3D11RenderWindow.h:47
Ogre::D3D11RenderWindowHwnd::getCustomAttribute
void getCustomAttribute(const String &name, void *pData)
Gets a custom (maybe platform-specific) attribute.
Ogre::D3D11RenderWindowSwapChainBased::mpSwapChain
IDXGISwapChainN * mpSwapChain
Definition: OgreD3D11RenderWindow.h:123
Ogre::D3D11RenderWindowImageSource::mImageSourceNative
ISurfaceImageSourceNative * mImageSourceNative
Definition: OgreD3D11RenderWindow.h:216
Ogre::D3D11RenderWindowCoreWindow::_createSwapChainImpl
virtual HRESULT _createSwapChainImpl(IDXGIDeviceN *pDXGIDevice)
Ogre::D3D11RenderWindowImageSource::mImageSource
Windows::UI::Xaml::Media::Imaging::SurfaceImageSource mImageSource
Definition: OgreD3D11RenderWindow.h:215
Ogre::D3D11RenderWindowHwnd::setFullscreen
void setFullscreen(bool fullScreen, unsigned int width, unsigned int height)
Alter fullscreen mode options.
Ogre::D3D11RenderWindowBase::_createSizeDependedD3DResources
void _createSizeDependedD3DResources()
Ogre::D3D11RenderWindowBase::_checkMultiSampleQuality
bool _checkMultiSampleQuality(UINT SampleCount, UINT *outQuality, DXGI_FORMAT format)
Ogre::D3D11RenderWindowCoreWindow::D3D11RenderWindowCoreWindow
D3D11RenderWindowCoreWindow(D3D11Device &device, IDXGIFactoryN *pDXGIFactory)
Ogre::RenderWindow
Manages the target rendering window.
Definition: OgreRenderWindow.h:62
Ogre::D3D11RenderWindowBase::mDevice
D3D11Device & mDevice
Definition: OgreD3D11RenderWindow.h:80
Ogre::D3D11RenderWindowImageSource::update
virtual void update(bool swapBuffers=true)
Tells the target to update it's contents.
Ogre::D3D11RenderWindowHwnd
Definition: OgreD3D11RenderWindow.h:129
Ogre::D3D11RenderWindowSwapChainBased::destroy
virtual void destroy(void)
Destroys the window.
Ogre::D3D11RenderWindowCoreWindow::isVisible
bool isVisible() const
Indicates whether the window is visible (not minimized or obscured)
Ogre::D3D11RenderWindowBase::mRenderTargetView
ID3D11RenderTargetView * mRenderTargetView
Definition: OgreD3D11RenderWindow.h:97
Ogre::D3D11RenderWindowBase::_destroySizeDependedD3DResources
void _destroySizeDependedD3DResources()
Ogre::D3D11RenderWindowHwnd::_createSwapChainImpl
virtual HRESULT _createSwapChainImpl(IDXGIDeviceN *pDXGIDevice)
Ogre::D3D11RenderWindowBase::resize
void resize(unsigned int width, unsigned int height)
Alter the size of the window.
Definition: OgreD3D11RenderWindow.h:57
Ogre::D3D11RenderWindowBase::destroy
virtual void destroy(void)
Destroys the window.
Ogre::D3D11RenderWindowImageSource::swapBuffers
virtual void swapBuffers()
Swaps the frame buffers to display the next frame.
Ogre::DXGI_SWAP_CHAIN_DESC_N
DXGI_SWAP_CHAIN_DESC DXGI_SWAP_CHAIN_DESC_N
Definition: OgreD3D11Prerequisites.h:88
Ogre::D3D11RenderWindowCoreWindow::destroy
virtual void destroy(void)
Destroys the window.
Ogre::D3D11RenderWindowSwapChainBased::_createSwapChain
void _createSwapChain()
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::D3D11RenderWindowSwapChainBased::swapBuffers
void swapBuffers()
Swaps the frame buffers to display the next frame.
Ogre::D3D11RenderWindowBase::mVSync
bool mVSync
Definition: OgreD3D11RenderWindow.h:92
Ogre::D3D11RenderWindowImageSource::getImageBrush
Windows::UI::Xaml::Media::ImageBrush getImageBrush() const
Definition: OgreD3D11RenderWindow.h:207
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::D3D11RenderWindowCoreWindow::create
virtual void create(const String &name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams)
Ogre::D3D11RenderWindowCoreWindow::mCoreWindow
Platform::Agile< Windows::UI::Core::CoreWindow > mCoreWindow
Definition: OgreD3D11RenderWindow.h:187
Ogre::IDXGIFactoryN
IDXGIFactory1 IDXGIFactoryN
Definition: OgreD3D11Prerequisites.h:84
Ogre::D3D11RenderWindowBase::mHidden
bool mHidden
Definition: OgreD3D11RenderWindow.h:85
Ogre::D3D11RenderWindowCoreWindow::windowMovedOrResized
void windowMovedOrResized()
Notify that the window has been resized.
Ogre::D3D11RenderWindowBase::isClosed
bool isClosed() const
Indicates whether the window has been closed by the user.
Definition: OgreD3D11RenderWindow.h:59
Ogre::D3D11RenderWindowImageSource::getCustomAttribute
virtual void getCustomAttribute(const String &name, void *pData)
Gets a custom (maybe platform-specific) attribute.
Ogre::D3D11RenderWindowImageSource::mBrush
Windows::UI::Xaml::Media::ImageBrush mBrush
Definition: OgreD3D11RenderWindow.h:214
Ogre::D3D11Device
Definition: OgreD3D11Device.h:36
Ogre::D3D11RenderWindowBase::getCustomAttribute
void getCustomAttribute(const String &name, void *pData)
Gets a custom (maybe platform-specific) attribute.
OgreD3D11Prerequisites.h
Ogre::D3D11RenderWindowHwnd::mHWnd
HWND mHWnd
Definition: OgreD3D11RenderWindow.h:159
Ogre::D3D11RenderWindowHwnd::_finishSwitchingFullscreen
void _finishSwitchingFullscreen()
Indicate that fullscreen / windowed switching has finished.
Ogre::D3D11RenderWindowHwnd::destroy
virtual void destroy(void)
Destroys the window.
Ogre::D3D11RenderWindowImageSource
Definition: OgreD3D11RenderWindow.h:192
Ogre::D3D11RenderWindowSwapChainBased
Definition: OgreD3D11RenderWindow.h:102
Ogre::D3D11RenderWindowImageSource::isVisible
virtual bool isVisible() const
Indicates whether the window is visible (not minimized or obscured)
Definition: OgreD3D11RenderWindow.h:205
Ogre::RenderTarget::FrameBuffer
FrameBuffer
Definition: OgreRenderTarget.h:91
Ogre::D3D11RenderWindowHwnd::~D3D11RenderWindowHwnd
~D3D11RenderWindowHwnd()
Definition: OgreD3D11RenderWindow.h:134
Ogre::D3D11RenderWindowImageSource::create
virtual void create(const String &name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams)
Ogre::D3D11RenderWindowHwnd::create
virtual void create(const String &name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams)
Ogre::IDXGIDeviceN
IDXGIDevice1 IDXGIDeviceN
Definition: OgreD3D11Prerequisites.h:86
Ogre::D3D11RenderWindowImageSource::resize
virtual void resize(unsigned int width, unsigned int height)
Alter the size of the window.
Ogre::D3D11RenderWindowHwnd::setActive
void setActive(bool state)
Used to set the active state of the render target.
Ogre::D3D11RenderWindowSwapChainBased::_createSizeDependedD3DResources
void _createSizeDependedD3DResources()
Ogre::D3D11RenderWindowHwnd::_getSwitchingFullscreen
bool _getSwitchingFullscreen() const
Are we in the middle of switching between fullscreen and windowed.
Definition: OgreD3D11RenderWindow.h:152
OgreRenderWindow.h
Ogre::D3D11RenderWindowSwapChainBased::D3D11RenderWindowSwapChainBased
D3D11RenderWindowSwapChainBased(D3D11Device &device, IDXGIFactoryN *pDXGIFactory)
Ogre::D3D11RenderWindowHwnd::setHidden
void setHidden(bool hidden)
Hide (or show) the window.
Ogre::D3D11RenderWindowBase::mSizing
bool mSizing
Definition: OgreD3D11RenderWindow.h:83
Ogre::D3D11RenderWindowImageSource::destroy
virtual void destroy(void)
Destroys the window.
Ogre::D3D11RenderWindowHwnd::mSwitchingFullscreen
bool mSwitchingFullscreen
Definition: OgreD3D11RenderWindow.h:160
Ogre::PixelBox
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
Definition: OgrePixelFormat.h:304
Ogre::D3D11RenderWindowBase::requiresTextureFlipping
bool requiresTextureFlipping() const
Definition: OgreD3D11RenderWindow.h:66
Ogre::D3D11RenderWindowBase::mDepthStencilView
ID3D11DepthStencilView * mDepthStencilView
Definition: OgreD3D11RenderWindow.h:98
Ogre::D3D11RenderWindowSwapChainBased::getPresentationParameters
DXGI_SWAP_CHAIN_DESC_N * getPresentationParameters(void)
Get the presentation parameters used with this window.
Definition: OgreD3D11RenderWindow.h:111
Ogre::D3D11RenderWindowBase::~D3D11RenderWindowBase
~D3D11RenderWindowBase()
Ogre::D3D11RenderWindowImageSource::D3D11RenderWindowImageSource
D3D11RenderWindowImageSource(D3D11Device &device, IDXGIFactoryN *pDXGIFactory)
Ogre::D3D11RenderWindowBase::isHidden
bool isHidden() const
Indicates whether the window was set to hidden (not displayed)
Definition: OgreD3D11RenderWindow.h:60
Ogre::D3D11RenderWindowSwapChainBased::_createSwapChainImpl
virtual HRESULT _createSwapChainImpl(IDXGIDeviceN *pDXGIDevice)=0
Ogre::D3D11RenderWindowHwnd::reposition
void reposition(int left, int top)
Reposition the window.
Ogre::D3D11RenderWindowHwnd::windowMovedOrResized
void windowMovedOrResized()
Notify that the window has been resized.
Ogre::D3D11RenderWindowBase::mpBackBuffer
ID3D11Texture2D * mpBackBuffer
Definition: OgreD3D11RenderWindow.h:96
Ogre::D3D11RenderWindowHwnd::resize
void resize(unsigned int width, unsigned int height)
Alter the size of the window.
Ogre::D3D11RenderWindowCoreWindow::getCoreWindow
Windows::UI::Core::CoreWindow getCoreWindow() const
Definition: OgreD3D11RenderWindow.h:176
Ogre::IDXGISwapChainN
IDXGISwapChain IDXGISwapChainN
Definition: OgreD3D11Prerequisites.h:87
Ogre::D3D11RenderWindowBase::_queryDxgiDevice
IDXGIDeviceN * _queryDxgiDevice()
Ogre::D3D11RenderWindowBase::mIsExternal
bool mIsExternal
Definition: OgreD3D11RenderWindow.h:82
Ogre::D3D11RenderWindowBase::create
virtual void create(const String &name, unsigned width, unsigned height, bool fullScreen, const NameValuePairList *miscParams)
Ogre::D3D11RenderWindowCoreWindow
Definition: OgreD3D11RenderWindow.h:167
Ogre::D3D11RenderWindowBase::mpDXGIFactory
IDXGIFactoryN * mpDXGIFactory
Definition: OgreD3D11RenderWindow.h:81
Ogre::D3D11RenderWindowBase::mFSAAType
DXGI_SAMPLE_DESC mFSAAType
Definition: OgreD3D11RenderWindow.h:90
Ogre::D3D11RenderWindowHwnd::isVisible
bool isVisible() const
Indicates whether the window is visible (not minimized or obscured)
Ogre::D3D11RenderWindowSwapChainBased::~D3D11RenderWindowSwapChainBased
~D3D11RenderWindowSwapChainBased()
Definition: OgreD3D11RenderWindow.h:107
Ogre::D3D11RenderWindowBase::_updateViewportsDimensions
void _updateViewportsDimensions()
Ogre::D3D11RenderWindowBase::mDisplayFrequency
UINT mDisplayFrequency
Definition: OgreD3D11RenderWindow.h:91
Ogre::D3D11RenderWindowBase::mVSyncInterval
unsigned int mVSyncInterval
Definition: OgreD3D11RenderWindow.h:93
Ogre::D3D11RenderWindowImageSource::_createSizeDependedD3DResources
void _createSizeDependedD3DResources()

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15