Equalizer  1.6.1
frameBufferObject.h
1 
2 /* Copyright (c) 2008-2009, Cedric Stalder <cedric.stalder@gmail.com>
3  2009-2012, 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 bool 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 
85  EQ_API void bind();
86 
92  EQ_API void unbind();
93 
104  EQ_API bool resize( const int32_t width, const int32_t height );
105 
107  int32_t getWidth() const
108  { LBASSERT( !_colors.empty( )); return _colors.front()->getWidth();}
109 
111  int32_t getHeight() const
112  { LBASSERT( !_colors.empty()); return _colors.front()->getHeight();}
113 
115  const Textures& getColorTextures() const { return _colors; }
116 
118  const Texture& getDepthTexture() const { return _depth; }
119 
121  const eq::fabric::Error& getError() { return _error; }
122 
124  const GLEWContext* glewGetContext() const { return _glewContext; }
125 
127  bool isValid() const { return _valid; }
128 
129  private:
130  unsigned _fboID;
131 
132  Textures _colors;
133  Texture _depth;
134 
135  const GLEWContext* const _glewContext;
136 
138  eq::fabric::Error _error;
139 
140  bool _valid;
141 
142  struct Private;
143  Private* _private; // placeholder for binary-compatible changes
144 
145  LB_TS_VAR( _thread );
146 
148  bool _checkStatus();
149 
150  void _setError( const int32_t error );
151  };
152 }
153 }
154 
155 #endif // EQUTIL_FRAMEBUFFEROBJECT_H
~FrameBufferObject()
Destruct the Frame Buffer Object.
A C++ class to abstract OpenGL frame buffer objects.
void exit()
De-initialize the Frame Buffer Object.
void bind()
Bind to the Frame Buffer Object.
Error
Defines errors produced by Equalizer classes.
bool addColorTexture()
Add one color texture to the FBO.
const Texture & getDepthTexture() const
void unbind()
Unbind any Frame Buffer Object and use the default drawable for the current context.
bool 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.
const eq::fabric::Error & getError()
const GLEWContext * glewGetContext() const
bool resize(const int32_t width, const int32_t height)
Resize the FBO.
A wrapper around OpenGL textures.
Definition: texture.h:38
std::vector< Texture * > Textures
A vector of pointers to eq::util::Texture.
Definition: eq/util/types.h:35
FrameBufferObject(const GLEWContext *const glewContext, const unsigned textureTarget=0x84F5)
Construct a new Frame Buffer Object.
const Textures & getColorTextures() const