Spinning Topp Logo BlackTopp Studios
inc
texture.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _graphicstexture_h
42 #define _graphicstexture_h
43 
44 #include "datatypes.h"
45 #include "Graphics/graphicsenumerations.h"
46 
47 namespace Ogre
48 {
49  class Texture;
50  template<typename T> class SharedPtr;
51  typedef SharedPtr<Texture> TexturePtr;
52 }//Ogre
53 
54 namespace Mezzanine
55 {
56  namespace Graphics
57  {
58  class InternalTextureData;
59  ///////////////////////////////////////////////////////////////////////////////
60  /// @brief This class represents a texture loaded into video memory.
61  /// @details
62  ///////////////////////////////////////
64  {
65  protected:
66  /// @internal
67  /// @brief A pointer to the internal implementation of the Texture.
69  public:
70  /// @brief Class Constructor.
71  Texture(Ogre::TexturePtr InternalTexture);
72  /// @brief Class Destructor.
73  ~Texture();
74 
75  ///////////////////////////////////////////////////////////////////////////////
76  // Utility Methods
77 
78  /// @brief Gets the width of the source Texture in pixels.
79  /// @remarks The actual size of the Texture in hardware is subject to change based on a number of configurations in the rendersystem.
80  /// This method ignores those settings and reports only the original unaltered size.
81  /// @return Returns a UInt32 representing the size of this Texture on the X axis.
82  UInt32 GetOriginalWidth() const;
83  /// @brief Gets the height of the source Texture in pixels.
84  /// @remarks The actual size of the Texture in hardware is subject to change based on a number of configurations in the rendersystem.
85  /// This method ignores those settings and reports only the original unaltered size.
86  /// @return Returns a UInt32 representing the size of this Texture on the Y axis.
87  UInt32 GetOriginalHeight() const;
88  /// @brief Gets the depth of the source Texture in pixels.
89  /// @remarks The actual size of the Texture in hardware is subject to change based on a number of configurations in the rendersystem.
90  /// This method ignores those settings and reports only the original unaltered size.
91  /// @return Returns a UInt32 representing the size of this Texture on the Z axis.
92  UInt32 GetOriginalDepth() const;
93  /// @brief Gets the pixel format of this Texture.
94  /// @return Returns a PixelFormat enum value representing how the bits of this Texture are layed out.
95  Graphics::PixelFormat GetFormat() const;
96  /// @brief Gets the number of MipMaps that exist for this Texture.
97  /// @return Returns the number of MipMaps this Texture has.
98  Whole GetNumMipMaps() const;
99 
100  /// @brief Gets the size of this Texture.
101  /// @return Returns a Whole representing the total size of this Texture in bytes.
102  Whole GetSize() const;
103 
104  ///////////////////////////////////////////////////////////////////////////////
105  // Asset Methods
106 
107  /// @brief Gets the Name of this Texture.
108  /// @note If this Texture originated from a file, usually the name of the Texture will be the file name.
109  /// @return Returns a const string reference containing the name of this Texture.
110  const String& GetName() const;
111  /// @brief Gets the resource group this Texture belongs to.
112  /// @return Returns a const string reference containing the group this Texture belongs to.
113  const String& GetGroup() const;
114 
115  ///////////////////////////////////////////////////////////////////////////////
116  // Internal Buffer Manipulation Methods
117 
118  /// @brief Reads from the internal buffer and populates the provided buffer with the texture data.
119  /// @exception If the size of the provided buffer is smaller than this texture, a PARAMETERS_EXCEPTION will be thrown.
120  /// @param DestBuffer The buffer to be written to.
121  /// @param BufferSize The size of the buffer provided.
122  /// @return Returns the number of bytes read from the texture. Usually this will be the size of the texture itself.
123  Whole _ReadFromBuffer(UInt8* DestBuffer, const Whole BufferSize);
124  /// @brief Writes to the textures internal buffer.
125  /// @exception If the size of this texture is smaller than the buffer being written, a PARAMETERS_EXCEPTION will be thrown.
126  /// @param SrcBuffer The buffer containing the pixel data to be written.
127  /// @param BufferSize The size of the buffer being written.
128  /// @param SrcFormat The pixel format of the texture in the source buffer. Pixel format will automatically be converted to the set format of this texture.
129  void _WriteToBuffer(UInt8* SrcBuffer, const Whole BufferSize, const Graphics::PixelFormat SrcFormat);
130 
131  ///////////////////////////////////////////////////////////////////////////////
132  // Internal Methods
133 
134  /// @internal
135  /// @brief Gets the internal Texture pointer.
136  /// @return Returns a shared pointer pointing to the internal Texture.
137  Ogre::TexturePtr _GetInternalTexture() const;
138  };//Texture
139  }//Graphics
140 }//Mezzanine
141 
142 #endif
InternalTextureData * ITD
A pointer to the internal implementation of the Texture.
Definition: texture.h:68
All the definitions for datatypes as well as some basic conversion functions are defined here...
uint8_t UInt8
An 8-bit unsigned integer.
Definition: datatypes.h:118
This class is used to store the internal structures needed by the Texture class.
Definition: texture.cpp:62
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
This class represents a texture loaded into video memory.
Definition: texture.h:63
PixelFormat
This is used to describe how bits are arraged for each pixel in an image.
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159