GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HdlTexture.hpp
Go to the documentation of this file.
1 /* ************************************************************************************************************* */
2 /* */
3 /* GLIP-LIB */
4 /* OpenGL Image Processing LIBrary */
5 /* */
6 /* Author : R. Kerviche */
7 /* LICENSE : MIT License */
8 /* Website : glip-lib.net */
9 /* */
10 /* File : HdlTexture.hpp */
11 /* Original Date : August 7th 2010 */
12 /* */
13 /* Description : OpenGL Texture Handle */
14 /* */
15 /* ************************************************************************************************************* */
16 
24 #ifndef __HDLTEXTURE_INCLUDE__
25 #define __HDLTEXTURE_INCLUDE__
26 
27  // Include
28  #include "Core/LibTools.hpp"
29  #include "Core/OglInclude.hpp"
30  #include "Core/HdlTextureTools.hpp"
31 
32  namespace Glip
33  {
34  namespace CoreGL
35  {
36 
37  // Texture Format Handle
42  class GLIP_API HdlAbstractTextureFormat
43  {
44  private :
45  int alignment; // Alignment in memory (on 1, 4 or 8 bytes).
46 
47  protected :
48  // Data
49  int width, height; // Image parameters.
50  GLenum mode, depth, minFilter, magFilter, wraps, wrapt; // Image format, texture filtering and wrapping modes.
51  int baseLevel, maxLevel; // MipMap information.
52 
53  // Protected constructors :
54  HdlAbstractTextureFormat(int _width, int _height, GLenum _mode, GLenum _depth, GLenum _minFilter = GL_NEAREST, GLenum _magFilter = GL_NEAREST, GLenum _wraps = GL_CLAMP, GLenum _wrapt = GL_CLAMP, int _baseLevel = 0, int _maxLevel = 0);
56 
57  // Protected function :
58  void setAlignment(int _alignment);
59 
60  public :
61  virtual ~HdlAbstractTextureFormat(void);
62 
63  int getWidth (void) const;
64  int getHeight (void) const;
65  int getNumPixels (void) const;
66  int getNumChannels (void) const;
67  int getNumElements (void) const;
68  int getAlignment (void) const;
69  int getPixelSize (void) const;
70  virtual size_t getRowSize (void) const;
71  virtual size_t getSize (void) const;
72  int getChannelDepth (void) const;
73  GLenum getGLMode (void) const;
74  GLenum getGLDepth (void) const;
75  GLenum getMinFilter (void) const;
76  GLenum getMagFilter (void) const;
77  int getBaseLevel (void) const;
78  int getMaxLevel (void) const;
79  GLenum getSWrapping (void) const;
80  GLenum getTWrapping (void) const;
81  bool isCompressed (void) const;
82  bool isFloatingPoint (void) const;
83 
84  const HdlTextureFormatDescriptor& getFormatDescriptor(void) const;
85 
86  bool operator==(const HdlAbstractTextureFormat&) const;
87  bool operator!=(const HdlAbstractTextureFormat&) const;
88 
89  bool isCompatibleWith(const HdlAbstractTextureFormat&) const;
90 
91  HdlAbstractTextureFormat getCompressedFormat(void) const;
92  HdlAbstractTextureFormat getUncompressedFormat(void) const;
93  bool isCorrespondingCompressedFormat(const HdlAbstractTextureFormat&) const;
94 
95  virtual unsigned int getSetting(GLenum param) const;
96 
97  // Static Tools :
98  static int getMaxSize(void);
99  };
100 
101  // Texture Format Handle
107  {
108  public :
109  // reproduce constructor :
110  HdlTextureFormat(int _width, int _height, GLenum _mode, GLenum _depth, GLenum _minFilter = GL_NEAREST, GLenum _magFilter = GL_NEAREST, GLenum _wraps = GL_CLAMP, GLenum _wrapt = GL_CLAMP, int _baseLevel = 0, int _maxLevel = 0);
112 
113  // Writing Functions
114  void setWidth (int w);
115  void setHeight (int h);
116  void setSize (int w, int h);
117  void setGLMode (GLenum md);
118  void setGLDepth (GLenum dp);
119  void setMinFilter(GLenum mf);
120  void setMagFilter(GLenum mf);
121  void setBaseLevel(int l);
122  void setMaxLevel (int l);
123  void setSWrapping(GLenum m);
124  void setTWrapping(GLenum m);
125 
126  const HdlAbstractTextureFormat& operator=(const HdlAbstractTextureFormat&);
127 
128  void setSetting(GLenum param, unsigned int value);
129 
130  static HdlTextureFormat getTextureFormat(GLuint texID);
131  };
132 
133  // Texture Handle
138  class GLIP_API HdlTexture : public HdlAbstractTextureFormat
139  {
140  private :
141  // Data
142  GLuint texID;
143  bool proxy;
144 
145  // Functions
146  HdlTexture(const HdlTexture&); // No-copy
147 
148  public :
149  // Functions
151  HdlTexture(GLuint proxyTexID);
152  virtual ~HdlTexture(void);
153 
154  GLuint getID(void) const;
155  bool isProxy(void) const;
156  int getSizeOnGPU(int m=0);
157  void bind(GLenum unit=GL_TEXTURE0_ARB);
158  void bind(int unit);
159  void write(GLvoid *texData, GLenum pixelFormat = GL_ZERO, GLenum pixelDepth = GL_ZERO, int alignment=-1);
160  void writeCompressed(GLvoid *texData, int size, GLenum pixelFormat = GL_ZERO, GLenum pixelDepth = GL_ZERO, int alignment=-1);
161  void fill(char dataByte);
162  void read(GLvoid *data, GLenum pixelFormat = GL_ZERO, GLenum pixelDepth = GL_ZERO, int alignment=-1);
163  GLenum getInternalMode(void);
164  bool checkForConsistency(bool verbose = false);
165  void setMinFilter(GLenum mf);
166  void setMagFilter(GLenum mf);
167  void setSWrapping(GLenum m);
168  void setTWrapping(GLenum m);
169  void setSetting(GLenum param, unsigned int value);
170 
171  const HdlAbstractTextureFormat& format(void) const;
172 
173  // Static Textures tools
174  static void unbind(GLenum unit=GL_TEXTURE0_ARB);
175  static void unbind(int unit);
176  static int getMaxImageUnits(void);
177  };
178  }
179  }
180 
181 #endif
182 
Specific defines for the API structure.
Object handle describing an OpenGL Texture mode.
Definition: HdlTextureTools.hpp:39
OpenGL Texture Handle Tools.
Object handle for OpenGL textures.
Definition: HdlTexture.hpp:138
Definition: Component.hpp:32
Object handle for OpenGL texture formats.
Definition: HdlTexture.hpp:106
OpenGL includes and tools.
Object handle for OpenGL texture formats (Read Only).
Definition: HdlTexture.hpp:42