Equalizer  1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
frameBufferObject.h
1 
2 /* Copyright (c) 2008-2009, Cedric Stalder <cedric.stalder@gmail.com>
3  * 2009-2013, Stefan Eilemann <eile@equalizergraphics.com>
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQUTIL_FRAMEBUFFEROBJECT_H
20 #define EQUTIL_FRAMEBUFFEROBJECT_H
21 
22 #include <eq/util/texture.h> // member
23 #include <eq/util/types.h>
24 
25 #include <vector>
26 
27 namespace eq
28 {
29 namespace util
30 {
33 {
34 public:
36  EQ_API FrameBufferObject( const GLEWContext* const glewContext,
37  const unsigned textureTarget = 0x84F5
38  /*GL_TEXTURE_RECTANGLE_ARB*/ );
39 
41  EQ_API ~FrameBufferObject();
42 
54  EQ_API bool addColorTexture();
55 
70  EQ_API Error init( const int32_t width, const int32_t height,
71  const unsigned colorFormat, const int32_t depthSize,
72  const int32_t stencilSize );
73 
75  EQ_API void exit();
76 
83  EQ_API void bind();
84 
90  EQ_API void unbind();
91 
102  EQ_API Error resize( const int32_t width, const int32_t height );
103 
105  int32_t getWidth() const
106  { LBASSERT( !_colors.empty( )); return _colors.front()->getWidth();}
107 
109  int32_t getHeight() const
110  { LBASSERT( !_colors.empty()); return _colors.front()->getHeight();}
111 
113  const Textures& getColorTextures() const { return _colors; }
114 
116  const Texture& getDepthTexture() const { return _depth; }
117 
119  const GLEWContext* glewGetContext() const { return _glewContext; }
120 
122  bool isValid() const { return _valid; }
123 
124 private:
125  unsigned _fboID;
126 
127  Textures _colors;
128  Texture _depth;
129 
130  const GLEWContext* const _glewContext;
131 
132  bool _valid;
133 
134  LB_TS_VAR( _thread );
135 
137  Error _checkStatus();
138 };
139 }
140 }
141 
142 #endif // EQUTIL_FRAMEBUFFEROBJECT_H
const Textures & getColorTextures() const
A C++ class to abstract OpenGL frame buffer objects.
EQ_API ~FrameBufferObject()
Destruct the Frame Buffer Object.
const GLEWContext * glewGetContext() const
A wrapper around OpenGL textures.
Definition: texture.h:38
EQ_API void exit()
De-initialize the Frame Buffer Object.
EQ_API void unbind()
Unbind any Frame Buffer Object and use the default drawable for the current context.
const Texture & getDepthTexture() const
EQ_API Error resize(const int32_t width, const int32_t height)
Resize the FBO.
EQ_API bool addColorTexture()
Add one color texture to the FBO.
EQ_API FrameBufferObject(const GLEWContext *const glewContext, const unsigned textureTarget=0x84F5)
Construct a new Frame Buffer Object.
EQ_API void bind()
Bind to the Frame Buffer Object.
EQ_API Error init(const int32_t width, const int32_t height, const unsigned colorFormat, const int32_t depthSize, const int32_t stencilSize)
Initialize the Frame Buffer Object.
std::vector< Texture * > Textures
A vector of pointers to eq::util::Texture.
Definition: util/types.h:36