SimpleGL  1.1.0
A framework for platform independent rendering
texture_object.hpp
Go to the documentation of this file.
1 
8 #ifndef TEXTURE_OBJECT_HPP
9 #define TEXTURE_OBJECT_HPP
10 
11 #include <SimpleGL_gl/SimpleGL_gl_Export.h>
12 
13 #include <GL/glew.h>
14 
15 namespace sgl {
16 
22  enum class TextureFilter : GLint {
23 
25  NEAREST = GL_NEAREST,
26 
28  LINEAR = GL_LINEAR
29  };
30 
36  enum class TextureWrap : GLint {
37 
39  CLAMP_TO_EDGE = GL_CLAMP_TO_EDGE,
40 
42  CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER,
43 
45  REPEAT = GL_REPEAT,
46 
48  MIRRORED_REPEAT = GL_MIRRORED_REPEAT
49  };
50 
56  struct SIMPLEGL_GL_EXPORT TextureData {
57 
59  int width;
60 
62  int height;
63 
66 
68  unsigned char* pixels;
69  };
70 
76  class SIMPLEGL_GL_EXPORT Texture {
77 
78  private:
80  static Texture* current;
81 
83  GLuint handle;
84 
86  int width;
87 
89  int height;
90 
91  public:
93  Texture(void);
94 
96  ~Texture(void);
97 
103  GLuint getHandle();
104 
110  int getWidth();
111 
117  int getHeight();
118 
120  void bind();
121 
123  void generateMipMap();
124 
130  void setMinFilter(TextureFilter filter);
131 
137  void setMagFilter(TextureFilter filter);
138 
144  void setWrapS(TextureWrap wrap);
145 
151  void setWrapT(TextureWrap wrap);
152 
160  void uploadImage(int width, int height, unsigned char* data);
161 
167  void uploadImage(TextureData image);
168  };
169 }
170 
171 #endif /* TEXTURE_OBJECT_HPP */
This structure stores texture image data.
unsigned char * pixels
The pixel data of the image.
int height
The height of the image.
Equivalent to GL_CLAMP_TO_EDGE.
int components
The number of color channels.
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
Equivalent to GL_LINEAR.
This class wraps an OpenGL texture object.
TextureWrap
This enum wraps the texture object&#39;s wrapping functions.
Equivalent to GL_MIRRORED_REPEAT.
Equivalent to GLFW_REPEAT.
TextureFilter
This enum wraps the texture object&#39;s filter.
Equivalent to GL_CLAMP_TO_BORDER.
int width
The width of the image.
Equivalent to GL_NEAREST.