TurtleBrains  0.2.1
High quality, portable, C++ API for native application and 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 TurtleBrains
20 {
21  namespace Graphics
22  {
23 
27  typedef float TexelSpace;
28 
34 
41  typedef unsigned int TextureHandle;
42 
46  extern const TextureHandle kInvalidTexture;
47 
51  extern const TextureHandle& kBlankTexture;
52 
68  {
69  public:
74  TextureManager(void);
75 
80  ~TextureManager(void);
81 
90  TextureHandle CreateTextureFromFile(const tbCore::tbString& filename);
91 
102  TextureHandle CreateTextureFromFileData(const unsigned char* fileDataInMemory, const size_t& fileSizeInBytes);
103 
116  TextureHandle CreateTextureFromPixelData(const unsigned char* pixelData, const PixelSpace& textureWidth, const PixelSpace& textureHeight);
117 
129  TextureHandle CreateTextureEmpty(const PixelSpace& textureWidth, const PixelSpace& textureHeight);
130 
140  TextureHandle CreateTextureReference(const TextureHandle& textureHandle);
141 
149  void DestroyTexture(const TextureHandle& textureHandle);
150 
158  void BindTexture(const TextureHandle& textureHandle);
159 
163  void BindTexture(const TextureHandle& textureHandle, tbCore::uint8 textureUnit);
164 
170  PixelSpace GetTextureWidth(const TextureHandle& textureHandle) const;
171 
177  PixelSpace GetTextureHeight(const TextureHandle& textureHandle) const;
178 
184  size_t ComputeMemoryUsage(void) const;
185 
186  private:
187  TextureHandle mBoundTexture;
188  };
189 
195 
196  }; /* namespace Graphics */
197 }; /* namespace TurtleBrains */
198 
200 
201 #endif /* _TurtleBraines_TextureManager_h_ */
PixelSpace GetTextureWidth(const TextureHandle &textureHandle) const
TextureHandle CreateTextureReference(const TextureHandle &textureHandle)
Definition: tb_texture_manager.h:67
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:25
void BindTexture(const TextureHandle &textureHandle)
unsigned int TextureHandle
Definition: tb_texture_manager.h:41
TextureHandle CreateTextureEmpty(const PixelSpace &textureWidth, const PixelSpace &textureHeight)
Definition: tb_noncopyable.h:22
Contains all functions, classes and helpers related to game/application development written by Tim "B...
Definition: tb_application_dialog.h:21
TextureHandle CreateTextureFromFileData(const unsigned char *fileDataInMemory, const size_t &fileSizeInBytes)
void DestroyTexture(const TextureHandle &textureHandle)
TextureManager theTextureManager
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:33
PixelSpace GetTextureHeight(const TextureHandle &textureHandle) const
const TextureHandle & kBlankTexture
float TexelSpace
Definition: tb_texture_manager.h:27
std::string tbString
Definition: tb_string.h:335
TextureHandle CreateTextureFromPixelData(const unsigned char *pixelData, const PixelSpace &textureWidth, const PixelSpace &textureHeight)