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 _CEGUIDirect3D11Texture_h_ 00027 #define _CEGUIDirect3D11Texture_h_ 00028 00029 #include "../../Texture.h" 00030 #include "CEGUI/RendererModules/Direct3D11/Renderer.h" 00031 #include "../../Size.h" 00032 #include "../../Vector.h" 00033 00034 // d3d forward refs 00035 struct ID3D11Device; 00036 struct ID3D11DeviceContext; 00037 struct ID3D11Texture2D; 00038 struct ID3D11ShaderResourceView; 00039 00040 #if defined(_MSC_VER) 00041 # pragma warning(push) 00042 # pragma warning(disable : 4251) 00043 #endif 00044 00045 // Start of CEGUI namespace section 00046 namespace CEGUI 00047 { 00049 class D3D11_GUIRENDERER_API Direct3D11Texture : public Texture 00050 { 00051 public: 00057 void setDirect3DTexture(ID3D11Texture2D* tex); 00058 00066 ID3D11Texture2D* getDirect3DTexture() const; 00067 00075 ID3D11ShaderResourceView* getDirect3DShaderResourceView() const; 00076 00084 void setOriginalDataSize(const Sizef& sz); 00085 00086 // implement abstract members from base class. 00087 const String& getName() const; 00088 const Sizef& getSize() const; 00089 const Sizef& getOriginalDataSize() const; 00090 const Vector2f& getTexelScaling() const; 00091 void loadFromFile(const String& filename, const String& resourceGroup); 00092 void loadFromMemory(const void* buffer, const Sizef& buffer_size, 00093 PixelFormat pixel_format); 00094 void blitFromMemory(const void* sourceData, const Rectf& area); 00095 void blitToMemory(void* targetData); 00096 bool isPixelFormatSupported(const PixelFormat fmt) const; 00097 00098 protected: 00099 // Friends to allow Renderer to peform construction and destruction 00100 friend Texture& Direct3D11Renderer::createTexture(const String&); 00101 friend Texture& Direct3D11Renderer::createTexture(const String&, 00102 const String&, 00103 const String&); 00104 friend Texture& Direct3D11Renderer::createTexture(const String&, 00105 const Sizef&); 00106 //friend Texture& Direct3D11Renderer::createTexture(ID3D10Texture2D* tex); 00107 friend void Direct3D11Renderer::destroyTexture(Texture&); 00108 friend void Direct3D11Renderer::destroyTexture(const String&); 00109 00111 Direct3D11Texture(IDevice11& device, const String& name); 00113 Direct3D11Texture(IDevice11& device, const String& name, const String& filename, 00114 const String& resourceGroup); 00116 Direct3D11Texture(IDevice11& device, const String& name, const Sizef& sz); 00118 Direct3D11Texture(IDevice11& device, const String& name, ID3D11Texture2D* tex); 00120 virtual ~Direct3D11Texture(); 00121 00123 void cleanupDirect3D11Texture(); 00125 void updateCachedScaleValues(); 00127 void updateTextureSize(); 00129 void initialiseShaderResourceView(); 00130 00132 IDevice11& d_device; 00134 ID3D11Texture2D* d_texture; 00136 ID3D11ShaderResourceView* d_resourceView; 00138 Sizef d_size; 00140 Sizef d_dataSize; 00142 Vector2f d_texelScaling; 00144 const String d_name; 00145 }; 00146 00147 00148 } // End of CEGUI namespace section 00149 00150 #if defined(_MSC_VER) 00151 # pragma warning(pop) 00152 #endif 00153 00154 #endif // end of guard _CEGUIDirect3D11Texture_h_