Crazy Eddies GUI System
0.7.6
|
00001 /*********************************************************************** 00002 filename: CEGUIDirect3D11Renderer.h 00003 created: Wed May 5 2010 00004 *************************************************************************/ 00005 /*************************************************************************** 00006 * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, sublicense, and/or sell copies of the Software, and to 00013 * permit persons to whom the Software is furnished to do so, subject to 00014 * the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00021 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00022 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00023 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00024 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00025 * OTHER DEALINGS IN THE SOFTWARE. 00026 ***************************************************************************/ 00027 #ifndef _CEGUIDirect3D11Renderer_h_ 00028 #define _CEGUIDirect3D11Renderer_h_ 00029 00030 #include "../../CEGUIRenderer.h" 00031 #include "../../CEGUISize.h" 00032 #include "../../CEGUIVector.h" 00033 #include <vector> 00034 00035 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC) 00036 # ifdef DIRECT3D11_GUIRENDERER_EXPORTS 00037 # define D3D11_GUIRENDERER_API __declspec(dllexport) 00038 # else 00039 # define D3D11_GUIRENDERER_API __declspec(dllimport) 00040 # endif 00041 #else 00042 # define D3D11_GUIRENDERER_API 00043 #endif 00044 00045 #if defined(_MSC_VER) 00046 # pragma warning(push) 00047 # pragma warning(disable : 4251) 00048 #endif 00049 00050 // D3D forward refs 00051 struct ID3D11Device; 00052 struct ID3D11DeviceContext; 00053 struct ID3DX11Effect;//D3DXEffect11 in dependences 00054 struct ID3DX11EffectTechnique;//D3DXEffect11 in dependences 00055 struct ID3D11InputLayout; 00056 struct ID3DX11EffectShaderResourceVariable;//D3DXEffect11 in dependences 00057 struct ID3DX11EffectMatrixVariable;//D3DXEffect11 in dependences 00058 struct ID3D11ShaderResourceView;//D3DXEffect11 in dependences 00059 struct D3DXMATRIX; 00060 00061 #include <d3d11.h> 00062 #include <d3dx11.h> 00063 #include <d3dx10.h> 00064 00065 00066 struct IDevice11//little structure that keeps both device, in order to reduce copy & paste around module 00067 { 00069 ID3D11Device* d_device; 00071 ID3D11DeviceContext* d_context; 00072 }; 00073 00074 // Start of CEGUI namespace section 00075 namespace CEGUI 00076 { 00077 class Direct3D11GeometryBuffer; 00078 class Direct3D11Texture; 00079 00080 00082 class D3D11_GUIRENDERER_API Direct3D11Renderer : public Renderer 00083 { 00084 public: 00106 static Direct3D11Renderer& bootstrapSystem(ID3D11Device* device, 00107 ID3D11DeviceContext* context); 00108 00124 static void destroySystem(); 00125 00130 static Direct3D11Renderer& create(ID3D11Device* device,ID3D11DeviceContext* context); 00131 00139 static void destroy(Direct3D11Renderer& renderer); 00140 00141 // //! return the ID3D10Device used by this renderer object. 00142 // ID3D11Device& getDirect3DDevice() const; 00143 // 00144 // //! return the ID3D11Device context used by this renderer object. 00145 // ID3D11DeviceContext& getDirect3DDeviceContext() const; 00146 00147 //returns d3d11 container for further rendering and creating 00148 IDevice11& getDirect3DDevice(); 00149 00151 void bindTechniquePass(const BlendMode mode); 00153 void setCurrentTextureShaderResource(ID3D11ShaderResourceView* srv); 00155 void setProjectionMatrix(D3DXMATRIX& matrix); 00157 void setWorldMatrix(D3DXMATRIX& matrix); 00158 00159 // Implement interface from Renderer 00160 RenderingRoot& getDefaultRenderingRoot(); 00161 GeometryBuffer& createGeometryBuffer(); 00162 void destroyGeometryBuffer(const GeometryBuffer& buffer); 00163 void destroyAllGeometryBuffers(); 00164 TextureTarget* createTextureTarget(); 00165 void destroyTextureTarget(TextureTarget* target); 00166 void destroyAllTextureTargets(); 00167 Texture& createTexture(); 00168 Texture& createTexture(const String& filename, const String& resourceGroup); 00169 Texture& createTexture(const Size& size); 00170 void destroyTexture(Texture& texture); 00171 void destroyAllTextures(); 00172 void beginRendering(); 00173 void endRendering(); 00174 void setDisplaySize(const Size& sz); 00175 const Size& getDisplaySize() const; 00176 const Vector2& getDisplayDPI() const; 00177 uint getMaxTextureSize() const; 00178 const String& getIdentifierString() const; 00179 00180 protected: 00182 Direct3D11Renderer(ID3D11Device* device,ID3D11DeviceContext* context); 00183 00185 ~Direct3D11Renderer(); 00186 00188 Size getViewportSize(); 00189 00191 static String d_rendererID; 00193 00194 IDevice11 d_device; 00195 00197 Size d_displaySize; 00199 Vector2 d_displayDPI; 00201 RenderTarget* d_defaultTarget; 00203 RenderingRoot* d_defaultRoot; 00205 typedef std::vector<TextureTarget*> TextureTargetList; 00207 TextureTargetList d_textureTargets; 00209 typedef std::vector<Direct3D11GeometryBuffer*> GeometryBufferList; 00211 GeometryBufferList d_geometryBuffers; 00213 typedef std::vector<Direct3D11Texture*> TextureList; 00215 TextureList d_textures; 00217 ID3DX11Effect* d_effect; 00219 ID3DX11EffectTechnique* d_normalTechnique; 00221 ID3DX11EffectTechnique* d_premultipliedTechnique; 00223 ID3D11InputLayout* d_inputLayout; 00225 ID3DX11EffectShaderResourceVariable* d_boundTextureVariable; 00227 ID3DX11EffectMatrixVariable* d_worldMatrixVariable; 00229 ID3DX11EffectMatrixVariable* d_projectionMatrixVariable; 00230 }; 00231 00232 00233 } // End of CEGUI namespace section 00234 00235 #if defined(_MSC_VER) 00236 # pragma warning(pop) 00237 #endif 00238 00239 #endif // end of guard _CEGUIDirect3D11Renderer_h_