Crazy Eddies GUI System: CEGUIDirect3D11Texture.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CEGUIDirect3D11Texture.h

    00001 /***********************************************************************
    00002     filename:   CEGUIDirect3D11Texture.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 _CEGUIDirect3D11Texture_h_
    00028 #define _CEGUIDirect3D11Texture_h_
    00029
    00030 #include "../../CEGUITexture.h"
    00031 #include "CEGUIDirect3D11Renderer.h"
    00032 #include "../../CEGUISize.h"
    00033 #include "../../CEGUIVector.h"
    00034
    00035 // d3d forward refs
    00036 struct ID3D11Device;
    00037 struct ID3D11DeviceContext;
    00038 struct ID3D11Texture2D;
    00039 struct ID3D11ShaderResourceView;
    00040
    00041
    00042
    00043 // Start of CEGUI namespace section
    00044 namespace CEGUI
    00045 {
    00047 class D3D11_GUIRENDERER_API Direct3D11Texture : public Texture
    00048 {
    00049 public:
    00055     void setDirect3DTexture(ID3D11Texture2D* tex);
    00056
    00064     ID3D11Texture2D* getDirect3DTexture() const;
    00065
    00073     ID3D11ShaderResourceView* getDirect3DShaderResourceView() const;
    00074
    00082     void setOriginalDataSize(const Size& sz);
    00083
    00084     // implement abstract members from base class.
    00085     const Size& getSize() const;
    00086     const Size& getOriginalDataSize() const;
    00087     const Vector2& getTexelScaling() const;
    00088     void loadFromFile(const String& filename, const String& resourceGroup);
    00089     void loadFromMemory(const void* buffer, const Size& buffer_size,
    00090                         PixelFormat pixel_format);
    00091     void saveToMemory(void* buffer);
    00092
    00093 protected:
    00094     // Friends to allow Renderer to peform construction and destruction
    00095     friend Texture& Direct3D11Renderer::createTexture();
    00096     friend Texture& Direct3D11Renderer::createTexture(const String&, const String&);
    00097     friend Texture& Direct3D11Renderer::createTexture(const Size&);
    00098     //friend Texture& Direct3D11Renderer::createTexture(ID3D10Texture2D* tex);
    00099     friend void Direct3D11Renderer::destroyTexture(Texture&);
    00100
    00102     Direct3D11Texture(IDevice11& device);
    00104     Direct3D11Texture(IDevice11& device, const String& filename,
    00105                       const String& resourceGroup);
    00107     Direct3D11Texture(IDevice11& device, const Size& sz);
    00109     Direct3D11Texture(IDevice11& device, ID3D11Texture2D* tex);
    00111     virtual ~Direct3D11Texture();
    00112
    00114     void cleanupDirect3D11Texture();
    00116     void updateCachedScaleValues();
    00118     void updateTextureSize();
    00120     void initialiseShaderResourceView();
    00121
    00123     IDevice11& d_device;
    00125     ID3D11Texture2D* d_texture;
    00127     ID3D11ShaderResourceView* d_resourceView;
    00129     Size d_size;
    00131     Size d_dataSize;
    00133     Vector2 d_texelScaling;
    00134 };
    00135
    00136
    00137 } // End of  CEGUI namespace section
    00138
    00139 #endif  // end of guard _CEGUIDirect3D11Texture_h_