GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HdlFBO.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 : HdlFBO.hpp */
11 /* Original Date : August 7th 2010 */
12 /* */
13 /* Description : OpenGL FrameBuffer Object Handle */
14 /* */
15 /* ************************************************************************************************************* */
16 
24 #ifndef __HDLFBO_INCLUDE__
25 #define __HDLFBO_INCLUDE__
26 
27  // Includes
28  #include <vector>
29  #include "Core/LibTools.hpp"
30  #include "Core/HdlTexture.hpp"
31  #include "Core/OglInclude.hpp"
32 
33  namespace Glip
34  {
35  namespace CoreGL
36  {
37  // RenderBuffer Handle
44  class GLIP_API HdlRenderBuffer
45  {
46  private :
47  GLuint rboID;
48  GLenum internalFormat;
49  int width,
50  height;
51 
52  // No copy :
54  const HdlRenderBuffer& operator=(const HdlRenderBuffer&);
55 
56  public :
57  HdlRenderBuffer(const GLenum& _internalFormat, int _width, int _height);
58  virtual ~HdlRenderBuffer(void);
59 
60  GLuint getID(void) const;
61  GLenum getInternalFormat(void) const;
62  int getWidth(void) const;
63  int getHeight(void) const;
64  void bind(void);
65 
66  static void unbind(void);
67  };
68 
69  // FBO Handle
76  class GLIP_API HdlFBO : public HdlAbstractTextureFormat
77  {
78  private :
79  // Data
80  std::vector<HdlTexture*> targets;
81  GLuint fboID;
82  bool firstRendering;
83  HdlRenderBuffer* depthBuffer;
84  bool depthBufferAttached;
85 
86  // Tools
87  void bindTextureToFBO(int i);
88  void unbindTextureFromFBO(int i);
89 
90  // No copy :
91  HdlFBO(const HdlFBO&);
92  const HdlFBO& operator=(const HdlFBO&);
93 
94  public :
95  // Tools
96  HdlFBO(const HdlAbstractTextureFormat& f, int numTarget = 1);
97  virtual ~HdlFBO(void);
98 
99  int addTarget(void);
100  int getNumTargets(void) const;
101  int getAttachmentCount(void) const;
102  void addDepthBuffer(void);
103  bool hasDepthBuffer(void);
104  void removeDepthBuffer(void);
105 
106  void beginRendering(int usedTarget=0, bool useExistingDepthBuffer=false);
107  void endRendering(void);
108  void bind(void);
109  HdlTexture* operator[](int i);
110  size_t getSize(bool askDriver = false);
111  GLenum test(void);
112 
113  // Static tools :
114  static int getMaximumColorAttachment(void);
115  static GLenum getAttachment(int i);
116  static int getIndexFromAttachment(GLenum attachment);
117  static void unbind(void);
118  };
119  }
120  }
121 
122 #endif
123 
Specific defines for the API structure.
OpenGL Texture Handle.
Object handle for OpenGL textures.
Definition: HdlTexture.hpp:138
Definition: Component.hpp:32
Object handle for OpenGL Render Buffer Objects.
Definition: HdlFBO.hpp:44
OpenGL includes and tools.
Object handle for OpenGL Frame Buffer Objects.
Definition: HdlFBO.hpp:76
Object handle for OpenGL texture formats (Read Only).
Definition: HdlTexture.hpp:42