Equalizer  1.10.1
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
frameBufferObject.h
1 
2 /* Copyright (c) 2008-2015, Cedric Stalder <cedric.stalder@gmail.com>
3  * Stefan Eilemann <eile@equalizergraphics.com>
4  * Daniel Nachbaur <danielnachbaur@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQUTIL_FRAMEBUFFEROBJECT_H
21 #define EQUTIL_FRAMEBUFFEROBJECT_H
22 
23 #include <eq/util/texture.h> // member
24 #include <eq/util/types.h>
25 
26 #include <vector>
27 
28 namespace eq
29 {
30 namespace util
31 {
34 {
35 public:
37  EQ_API FrameBufferObject( const GLEWContext* const glewContext,
38  const unsigned textureTarget = 0x84F5
39  /*GL_TEXTURE_RECTANGLE_ARB*/ );
40 
42  EQ_API ~FrameBufferObject();
43 
55  EQ_API bool addColorTexture();
56 
72  EQ_API Error init( const int32_t width, const int32_t height,
73  const unsigned colorFormat, const int32_t depthSize,
74  const int32_t stencilSize,
75  const int32_t samplesSize = 1 );
76 
78  EQ_API void exit();
79 
88  EQ_API void bind( const uint32_t target = 0x8D40 /*GL_FRAMEBUFFER_EXT*/ );
89 
96  EQ_API void unbind( const uint32_t target = 0x8D40 /*GL_FRAMEBUFFER_EXT*/ );
97 
108  EQ_API Error resize( const int32_t width, const int32_t height );
109 
111  int32_t getWidth() const
112  { LBASSERT( !_colors.empty( )); return _colors.front()->getWidth();}
113 
115  int32_t getHeight() const
116  { LBASSERT( !_colors.empty()); return _colors.front()->getHeight();}
117 
119  const Textures& getColorTextures() const { return _colors; }
120 
122  const Texture& getDepthTexture() const { return _depth; }
123 
125  const GLEWContext* glewGetContext() const { return _glewContext; }
126 
128  bool isValid() const { return _valid; }
129 
130 private:
131  unsigned _fboID;
132 
133  Textures _colors;
134  Texture _depth;
135 
136  const GLEWContext* const _glewContext;
137 
138  bool _valid;
139 
140  LB_TS_VAR( _thread );
141 
143  Error _checkStatus();
144 };
145 }
146 }
147 
148 #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.
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 unbind(const uint32_t target=0x8D40)
Unbind any Frame Buffer Object and use the default drawable for the current context.
std::vector< Texture * > Textures
A vector of pointers to eq::util::Texture.
Definition: eq/util/types.h:41
EQ_API void bind(const uint32_t target=0x8D40)
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, const int32_t samplesSize=1)
Initialize the Frame Buffer Object.