Texture.h
Go to the documentation of this file.
1 #ifndef B_TEXTURE_H
2 #define B_TEXTURE_H
3 
4 #include <memory>
5 #include <string>
6 #include "Renderer_GL.h"
7 
8 class TextureData;
9 
13 class Texture
14 {
15 public:
16 
17  /* Functions */
18 
23  Texture() { glGenTextures(1, &_textureID); }
24 
28  Texture(const TextureData &data);
29 
37  Texture(GLuint textureID):_textureID(textureID){}
38 
41  virtual ~Texture() { deleteTexture(); }
42 
45  GLuint getTextureID() { return _textureID; }
46 
50  virtual void bind(GLint texUnit = GL_TEXTURE0);
51 
54  virtual void deleteTexture()
55  {
56  if (_textureID)
57  glDeleteTextures(1, &_textureID);
58  }
59 
60 private:
61 
62  /* Variables */
63 
64  GLuint _textureID = 0;
65 };
66 
67 typedef std::shared_ptr< Texture > TexturePtr;
68 
69 #endif /* defined(B_TEXTURE_H) */
std::shared_ptr< Texture > TexturePtr
Definition: Texture.h:67
virtual void bind(GLint texUnit=GL_TEXTURE0)
Binds the texture.
Definition: Texture.cpp:38
Texture()
Constructor.
Definition: Texture.h:23
Texture(GLuint textureID)
Constructor.
Definition: Texture.h:37
virtual void deleteTexture()
Delete the OpenGL texture.
Definition: Texture.h:54
The underlying data of a texture.
Definition: TextureData.h:13
An image that can be applied to a surface of a drawable object.
Definition: Texture.h:13
GLuint getTextureID()
Returns texture id.
Definition: Texture.h:45
virtual ~Texture()
Virtual destructor.
Definition: Texture.h:41