TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
tb_texture_manager.h
1 
10 #ifndef _TurtleBraines_TextureManager_h_
11 #define _TurtleBraines_TextureManager_h_
12 
13 #include "../core/tb_noncopyable.h"
14 #include "../core/tb_string.h"
15 #include "../core/tb_types.h"
16 
17 #include <cstddef>
18 
19 namespace tbImplementation { class TextureManagerCreator; }
20 
21 namespace TurtleBrains
22 {
23  namespace Graphics
24  {
25 
29  typedef float TexelSpace;
30 
36 
44 
48  extern const TextureHandle kInvalidTexture;
49 
53  extern const TextureHandle& kBlankTexture;
54 
70  {
71  public:
75  void Initialize(void);
76 
85  TextureHandle CreateTextureFromFile(const tbCore::tbString& filename);
86 
97  TextureHandle CreateTextureFromFileData(const unsigned char* fileDataInMemory, const size_t& fileSizeInBytes);
98 
111  TextureHandle CreateTextureFromPixelData(const unsigned char* pixelData, const PixelSpace& textureWidth, const PixelSpace& textureHeight);
112 
123  TextureHandle CreateTextureEmpty(const PixelSpace& textureWidth, const PixelSpace& textureHeight);
124 
134  TextureHandle CreateTextureReference(const TextureHandle& textureHandle);
135 
143  void DestroyTexture(const TextureHandle& textureHandle);
144 
152  void BindTexture(const TextureHandle& textureHandle);
153 
157  void BindTexture(const TextureHandle& textureHandle, tbCore::uint8 textureUnit);
158 
164  PixelSpace GetTextureWidth(const TextureHandle& textureHandle) const;
165 
171  PixelSpace GetTextureHeight(const TextureHandle& textureHandle) const;
172 
179 
180  private:
185  TextureManager(void);
186 
191  ~TextureManager(void);
192 
193  friend class tbImplementation::TextureManagerCreator;
194  TextureHandle mBoundTexture;
195  };
196 
202 
203  }; /* namespace Graphics */
204 }; /* namespace TurtleBrains */
205 
207 
208 #endif /* _TurtleBraines_TextureManager_h_ */
PixelSpace GetTextureWidth(const TextureHandle &textureHandle) const
TextureHandle CreateTextureReference(const TextureHandle &textureHandle)
Definition: tb_texture_manager.h:69
Give the GameScene and Entities something to display, Text, Sprites and AnimatedSprites help bring th...
TextureHandle CreateTextureFromFile(const tbCore::tbString &filename)
uint16_t uint16
Unsigned integer with a size of 16 bits. Supports values from 0 to 65535.
Definition: tb_types.h:26
void BindTexture(const TextureHandle &textureHandle)
TextureHandle CreateTextureEmpty(const PixelSpace &textureWidth, const PixelSpace &textureHeight)
Definition: tb_noncopyable.h:22
Here is some information about the primary namespace.
Definition: tb_application_dialog.h:21
TextureManager & theTextureManager
uint64_t uint64
Unsigned integer with a size of 64 bits, Supports values from 0 to (2^64 - 1).
Definition: tb_types.h:30
TextureHandle CreateTextureFromFileData(const unsigned char *fileDataInMemory, const size_t &fileSizeInBytes)
void DestroyTexture(const TextureHandle &textureHandle)
tbCore::uint32 TextureHandle
Definition: tb_texture_manager.h:43
const TextureHandle kInvalidTexture
uint8_t uint8
Unsigned integer with a size of 8 bits. Supports values from 0 to 255.
Definition: tb_types.h:23
tbCore::uint16 PixelSpace
Definition: tb_texture_manager.h:35
PixelSpace GetTextureHeight(const TextureHandle &textureHandle) const
uint32_t uint32
Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1)...
Definition: tb_types.h:28
const TextureHandle & kBlankTexture
float TexelSpace
Definition: tb_texture_manager.h:29
std::string tbString
Definition: tb_string.h:335
TextureHandle CreateTextureFromPixelData(const unsigned char *pixelData, const PixelSpace &textureWidth, const PixelSpace &textureHeight)
Definition: tb_application_dialog.h:19
tbCore::uint64 ComputeMemoryUsage(void) const