Developer Documentation
Loading...
Searching...
No Matches
FBO.hh
1/*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40\*===========================================================================*/
41
42#ifndef ACG_FBO_HH
43#define ACG_FBO_HH
44
45
46//== INCLUDES =================================================================
47
48#include <iostream>
49#include <cstdlib>
50#include <map>
51#include <vector>
52
53#include <ACG/Config/ACGDefines.hh>
54#include <ACG/GL/gl.hh>
55
56//== FORWARDDECLARATIONS ======================================================
57
58//== NAMESPACES ===============================================================
59
60namespace ACG {
61
62//== CLASS DEFINITION =========================================================
63
64
71class ACGDLLEXPORT FBO
72{
73public:
74
75 // fbo_ braucht initialen Wert.
77 FBO();
78
80 ~FBO();
81
83 void init();
84
86 void del();
87
90 GLsizei setMultisampling(GLsizei _samples, GLboolean _fixedsamplelocations = GL_TRUE);
91
93 GLsizei getMultisamplingCount() const {return samples_;}
94
96 void attachTexture( GLenum _attachment,
97 GLuint _texture,
98 GLuint _level = 0);
99
101 void attachTexture2D( GLenum _attachment,
102 GLsizei _width, GLsizei _height,
103 GLuint _internalFmt, GLenum _format,
104 GLint _wrapMode = GL_CLAMP_TO_EDGE,
105 GLint _minFilter = GL_NEAREST,
106 GLint _magFilter = GL_NEAREST);
107
108
110 void attachTexture2D( GLenum _attachment, GLuint _texture, GLenum _target = GL_TEXTURE_2D );
111
113 void attachTexture2DDepth( GLsizei _width, GLsizei _height, GLuint _internalFmt = GL_DEPTH_COMPONENT32, GLenum _format = GL_DEPTH_COMPONENT );
114
116 void attachTexture2DStencil(GLsizei _width, GLsizei _height);
117
120 void attachTexture3D( GLenum _attachment,
121 GLsizei _width, GLsizei _height, GLsizei _depth,
122 GLuint _internalFmt, GLenum _format,
123 GLint _wrapMode = GL_CLAMP,
124 GLint _minFilter = GL_NEAREST,
125 GLint _magFilter = GL_NEAREST);
126
128 void addDepthBuffer( GLuint _width, GLuint _height );
129
131 void addStencilBuffer( GLuint _width, GLuint _height );
132
134 void addDepthStencilBuffer( GLuint _width, GLuint _height );
135
137 GLuint getAttachment( GLenum _attachment );
138
140 GLuint getInternalFormat( GLenum _attachment );
141
143 GLuint getFboID();
144
146 void resize(GLsizei _width, GLsizei _height, bool _forceResize = false);
147
149 GLsizei width() const {return width_;}
150
152 GLsizei height() const {return height_;}
153
155 ACG::Vec2i size() const {return ACG::Vec2i(width_, height_);}
156
158 bool bind();
159
161 void unbind();
162
164 bool checkFramebufferStatus();
165
166private:
167
169 GLuint fbo_;
170
173
176
179 {
181
182 // opengl buf id
183 GLuint id;
184
185 // GL_TEXTURE_2D, GL_TEXTURE_2D_MULTISAMPLE..
186 GLenum target;
187
188 GLenum internalFormat, format, gltype;
189
190 // tex dimension
191 ACG::Vec3i dim;
192
193 // common sampler params
194 GLint wrapMode,
195 minFilter,
196 magFilter;
197
198 // created by FBO class
199 bool owner;
200 };
201
202 typedef std::map<GLenum, RenderTexture> AttachmentList;
203 AttachmentList attachments_; // key: attachment index, value: RenderTexture
204
205
207 GLsizei width_, height_;
208
210 GLsizei samples_;
211
214
215
217 GLuint prevFbo_;
218 GLuint prevDrawBuffer_;
219};
220
221
222//=============================================================================
223} // namespace ACG
224//=============================================================================
225#endif // ACG_FBO_HH defined
226//=============================================================================
227
GLsizei samples_
sample count if multisampling
Definition FBO.hh:210
GLuint fbo_
handle of frame buffer object
Definition FBO.hh:169
GLboolean fixedsamplelocation_
enable fixed sample location if multisampling
Definition FBO.hh:213
ACG::Vec2i size() const
get width and height of fbo texture
Definition FBO.hh:155
GLsizei width() const
get width of fbo texture
Definition FBO.hh:149
GLuint prevFbo_
handle of previously bound fbo
Definition FBO.hh:217
GLsizei height() const
get height of fbo texture
Definition FBO.hh:152
GLuint stencilbuffer_
stencilbuffer
Definition FBO.hh:175
GLuint depthbuffer_
depthbuffer
Definition FBO.hh:172
GLsizei width_
width and height of render textures
Definition FBO.hh:207
GLsizei getMultisamplingCount() const
get number of samples
Definition FBO.hh:93
Namespace providing different geometric functions concerning angles.
VectorT< signed int, 2 > Vec2i
Definition VectorT.hh:98
attached textures
Definition FBO.hh:179