TurtleBrains  0.3.0
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 
85  void Initialize(void);
86 
95  TextureHandle CreateTextureFromFile(const tbCore::tbString& filename);
96 
107  TextureHandle CreateTextureFromFileData(const unsigned char* fileDataInMemory, const size_t& fileSizeInBytes);
108 
121  TextureHandle CreateTextureFromPixelData(const unsigned char* pixelData, const PixelSpace& textureWidth, const PixelSpace& textureHeight);
122 
134  TextureHandle CreateTextureEmpty(const PixelSpace& textureWidth, const PixelSpace& textureHeight);
135 
145  TextureHandle CreateTextureReference(const TextureHandle& textureHandle);
146 
154  void DestroyTexture(const TextureHandle& textureHandle);
155 
163  void BindTexture(const TextureHandle& textureHandle);
164 
168  void BindTexture(const TextureHandle& textureHandle, tbCore::uint8 textureUnit);
169 
175  PixelSpace GetTextureWidth(const TextureHandle& textureHandle) const;
176 
182  PixelSpace GetTextureHeight(const TextureHandle& textureHandle) const;
183 
190 
191  private:
192  TextureHandle mBoundTexture;
193  };
194 
200 
201  }; /* namespace Graphics */
202 }; /* namespace TurtleBrains */
203 
205 
206 #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:26
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
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)
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)
tbCore::uint64 ComputeMemoryUsage(void) const