Crazy Eddie's GUI System  0.8.4
Texture.h
00001 /***********************************************************************
00002     created:    Sat Mar 7 2009
00003     author:     Paul D Turner (parts based on code by Rajko Stojadinovic)
00004 *************************************************************************/
00005 /***************************************************************************
00006  *   Copyright (C) 2004 - 2011 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 _CEGUIDirect3D10Texture_h_
00028 #define _CEGUIDirect3D10Texture_h_
00029 
00030 #include "../../Texture.h"
00031 #include "CEGUI/RendererModules/Direct3D10/Renderer.h"
00032 #include "../../Size.h"
00033 #include "../../Vector.h"
00034 
00035 #if defined(_MSC_VER)
00036 #   pragma warning(push)
00037 #   pragma warning(disable : 4251)
00038 #endif
00039 
00040 // d3d forward refs
00041 struct ID3D10Device;
00042 struct ID3D10Texture2D;
00043 struct ID3D10ShaderResourceView;
00044 
00045 // Start of CEGUI namespace section
00046 namespace CEGUI
00047 {
00049 class D3D10_GUIRENDERER_API Direct3D10Texture : public Texture
00050 {
00051 public:
00057     void setDirect3DTexture(ID3D10Texture2D* tex);
00058 
00066     ID3D10Texture2D* getDirect3DTexture() const;
00067 
00075     ID3D10ShaderResourceView* 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& Direct3D10Renderer::createTexture(const String&);
00101     friend Texture& Direct3D10Renderer::createTexture(const String&,
00102                                                       const String&,
00103                                                       const String&);
00104     friend Texture& Direct3D10Renderer::createTexture(const String&,
00105                                                       const Sizef&);
00106     //friend Texture& Direct3D10Renderer::createTexture(ID3D10Texture2D* tex);
00107     friend void Direct3D10Renderer::destroyTexture(Texture&);
00108     friend void Direct3D10Renderer::destroyTexture(const String&);
00109 
00111     Direct3D10Texture(ID3D10Device& device, const String&);
00113     Direct3D10Texture(ID3D10Device& device, const String&,
00114                       const String& filename, const String& resourceGroup);
00116     Direct3D10Texture(ID3D10Device& device, const String&, const Sizef& sz);
00118     Direct3D10Texture(ID3D10Device& device, const String&, ID3D10Texture2D* tex);
00120     virtual ~Direct3D10Texture();
00121 
00123     void cleanupDirect3D10Texture();
00125     void updateCachedScaleValues();
00127     void updateTextureSize();
00129     void initialiseShaderResourceView();
00130 
00132     ID3D10Device& d_device;
00134     ID3D10Texture2D* d_texture;
00136     ID3D10ShaderResourceView* 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 _CEGUIDirect3D10Texture_h_
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends