Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: Wed May 5 2010 00003 *************************************************************************/ 00004 /*************************************************************************** 00005 * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining 00008 * a copy of this software and associated documentation files (the 00009 * "Software"), to deal in the Software without restriction, including 00010 * without limitation the rights to use, copy, modify, merge, publish, 00011 * distribute, sublicense, and/or sell copies of the Software, and to 00012 * permit persons to whom the Software is furnished to do so, subject to 00013 * the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be 00016 * included in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00019 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00021 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00022 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00023 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00024 * OTHER DEALINGS IN THE SOFTWARE. 00025 ***************************************************************************/ 00026 #ifndef _CEGUIDirect3D11Renderer_h_ 00027 #define _CEGUIDirect3D11Renderer_h_ 00028 00029 #include "../../Renderer.h" 00030 #include "../../Size.h" 00031 #include "../../Vector.h" 00032 #include <vector> 00033 #include <map> 00034 00035 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC) 00036 # ifdef CEGUIDIRECT3D11RENDERER_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: 00109 static Direct3D11Renderer& bootstrapSystem(ID3D11Device* device, 00110 ID3D11DeviceContext* context, 00111 const int abi = CEGUI_VERSION_ABI); 00112 00128 static void destroySystem(); 00129 00134 static Direct3D11Renderer& create(ID3D11Device* device,ID3D11DeviceContext* context, 00135 const int abi = CEGUI_VERSION_ABI); 00136 00144 static void destroy(Direct3D11Renderer& renderer); 00145 00146 // //! return the ID3D10Device used by this renderer object. 00147 // ID3D11Device& getDirect3DDevice() const; 00148 // 00149 // //! return the ID3D11Device context used by this renderer object. 00150 // ID3D11DeviceContext& getDirect3DDeviceContext() const; 00151 00152 //returns d3d11 container for further rendering and creating 00153 IDevice11& getDirect3DDevice(); 00154 00156 void bindTechniquePass(const BlendMode mode, const bool clipped); 00158 void setCurrentTextureShaderResource(ID3D11ShaderResourceView* srv); 00160 void setProjectionMatrix(D3DXMATRIX& matrix); 00162 void setWorldMatrix(D3DXMATRIX& matrix); 00163 00164 // Implement interface from Renderer 00165 RenderTarget& getDefaultRenderTarget(); 00166 GeometryBuffer& createGeometryBuffer(); 00167 void destroyGeometryBuffer(const GeometryBuffer& buffer); 00168 void destroyAllGeometryBuffers(); 00169 TextureTarget* createTextureTarget(); 00170 void destroyTextureTarget(TextureTarget* target); 00171 void destroyAllTextureTargets(); 00172 Texture& createTexture(const String& name); 00173 Texture& createTexture(const String& name, 00174 const String& filename, 00175 const String& resourceGroup); 00176 Texture& createTexture(const String& name, const Sizef& size); 00177 void destroyTexture(Texture& texture); 00178 void destroyTexture(const String& name); 00179 void destroyAllTextures(); 00180 Texture& getTexture(const String& name) const; 00181 bool isTextureDefined(const String& name) const; 00182 void beginRendering(); 00183 void endRendering(); 00184 void setDisplaySize(const Sizef& sz); 00185 const Sizef& getDisplaySize() const; 00186 const Vector2f& getDisplayDPI() const; 00187 uint getMaxTextureSize() const; 00188 const String& getIdentifierString() const; 00189 00190 protected: 00192 Direct3D11Renderer(ID3D11Device* device,ID3D11DeviceContext* context); 00193 00195 ~Direct3D11Renderer(); 00196 00198 Sizef getViewportSize(); 00199 00201 void throwIfNameExists(const String& name) const; 00203 static void logTextureCreation(const String& name); 00205 static void logTextureDestruction(const String& name); 00206 00208 static String d_rendererID; 00210 00211 IDevice11 d_device; 00212 00214 Sizef d_displaySize; 00216 Vector2f d_displayDPI; 00218 RenderTarget* d_defaultTarget; 00220 typedef std::vector<TextureTarget*> TextureTargetList; 00222 TextureTargetList d_textureTargets; 00224 typedef std::vector<Direct3D11GeometryBuffer*> GeometryBufferList; 00226 GeometryBufferList d_geometryBuffers; 00228 typedef std::map<String, Direct3D11Texture*, StringFastLessCompare 00229 CEGUI_MAP_ALLOC(String, Direct3D11Texture*)> TextureMap; 00231 TextureMap d_textures; 00233 ID3DX11Effect* d_effect; 00235 ID3DX11EffectTechnique* d_normalClippedTechnique; 00237 ID3DX11EffectTechnique* d_normalUnclippedTechnique; 00239 ID3DX11EffectTechnique* d_premultipliedClippedTechnique; 00241 ID3DX11EffectTechnique* d_premultipliedUnclippedTechnique; 00243 ID3D11InputLayout* d_inputLayout; 00245 ID3DX11EffectShaderResourceVariable* d_boundTextureVariable; 00247 ID3DX11EffectMatrixVariable* d_worldMatrixVariable; 00249 ID3DX11EffectMatrixVariable* d_projectionMatrixVariable; 00250 }; 00251 00252 00253 } // End of CEGUI namespace section 00254 00255 #if defined(_MSC_VER) 00256 # pragma warning(pop) 00257 #endif 00258 00259 #endif // end of guard _CEGUIDirect3D11Renderer_h_