Developer Documentation

FBO.cc
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 //=============================================================================
43 //
44 // CLASS FBO - IMPLEMENTATION
45 //
46 //=============================================================================
47
48 //== INCLUDES =================================================================
49
50 #include <ACG/GL/acg_glew.hh>
51 #include "FBO.hh"
52 #include "GLState.hh"
53 #include "GLError.hh"
54 #include "GLFormatInfo.hh"
55
56 //== NAMESPACES ===============================================================
57
58 namespace ACG
59 {
60
61 //== IMPLEMENTATION ==========================================================
62
63
64 FBO::RenderTexture::RenderTexture()
65 : id(0), target(0), internalFormat(0), format(0), gltype(0),
66 dim(0,0,0), wrapMode(0), minFilter(0), magFilter(0), owner(false)
67 {
68 }
69
70
71 FBO::FBO()
72 : fbo_(0), depthbuffer_(0), stencilbuffer_(0), width_(0), height_(0), samples_(0), fixedsamplelocation_(GL_TRUE), prevFbo_(0), prevDrawBuffer_(GL_NONE)
73 {
74 }
75
76 FBO::
77 ~FBO()
78 {
79 del();
80 }
81
82 //-----------------------------------------------------------------------------
83
84 void
85 FBO::
86 init()
87 {
88 // Create framebuffer object
89
90 //EXT_framebuffer_object was removed in OpenGL version 3.1
91 //hence no core profile has the extension explicitly, but fbos
92 //were adopted in opengl v 3.0 so don use this extension on core profiles
93 if(!ACG::openGLVersion(3,0))
94 {
95 if (!checkExtensionSupported("GL_EXT_framebuffer_object")) {
96 std::cerr << "Framebuffer object not supported! " << std::endl;
97 exit( 1 );
98 }
99 }
100
101 // test whether fbo hasn't been created before
102 if(!fbo_)
103 glGenFramebuffers( 1, &fbo_ );
104
105 // check status
106 checkFramebufferStatus();
107 }
108
109 //-----------------------------------------------------------------------------
110
111 void FBO::del()
112 {
113 // delete framebuffer object
114 if(fbo_)
115 glDeleteFramebuffers( 1, &fbo_ );
116
117 // delete render buffer
118 if(depthbuffer_)
119 glDeleteRenderbuffers(1, &depthbuffer_);
120
121 // delete stencil buffer
122 if(stencilbuffer_)
123 glDeleteRenderbuffers(1, &stencilbuffer_);
124
125 for (AttachmentList::iterator it = attachments_.begin(); it != attachments_.end(); ++it)
126 if (it->second.id && it->second.owner)
127 glDeleteTextures(1, &it->second.id);
128 }
129
130
131 //-----------------------------------------------------------------------------
132
133 void FBO::attachTexture( GLenum _attachment, GLuint _texture, GLuint _level )
134 {
135 #ifdef GL_VERSION_3_2
136 // bind fbo
137 bind();
138
139 // add texture to frame buffer object
140 glFramebufferTexture( GL_FRAMEBUFFER_EXT, _attachment, _texture, _level );
141
142 // GLint layered = 0;
143 // glGetFramebufferAttachmentParameteriv( GL_FRAMEBUFFER_EXT, _attachment, GL_FRAMEBUFFER_ATTACHMENT_LAYERED, &layered);
144
145 checkGLError();
146
147 // check status
148 checkFramebufferStatus();
149
150 // unbind fbo
151 unbind();
152
153
154 // store texture id in internal array
155 RenderTexture intID;
156 intID.id = _texture;
157
158 // free previously bound texture
159 const RenderTexture& prevTex = attachments_[_attachment];
160 if (prevTex.owner && prevTex.id)
161 glDeleteTextures(1, &prevTex.id);
162
163 // track texture id
164 attachments_[_attachment] = intID;
165 #else
166 std::cerr << "error: FBO::attachTexture unsupported - update glew headers and rebuild" << std::endl;
167 #endif
168 }
169
170 //-----------------------------------------------------------------------------
171
172 void
173 FBO::
174 attachTexture2D( GLenum _attachment, GLuint _texture, GLenum _target )
175 {
176 // bind fbo
177 bind();
178
179 // add texture to frame buffer object
180 glFramebufferTexture2D( GL_FRAMEBUFFER_EXT, _attachment, _target, _texture, 0 );
181
182 checkGLError();
183
184 // check status
185 checkFramebufferStatus();
186
187 // unbind fbo
188 unbind();
189
190
191 // store texture id in internal array
192 RenderTexture intID;
193 intID.id = _texture;
194 intID.target = _target;
195
196 // free previously bound texture
197 const RenderTexture& prevTex = attachments_[_attachment];
198 if (prevTex.owner && prevTex.id)
199 glDeleteTextures(1, &prevTex.id);
200
201 // track texture id
202 attachments_[_attachment] = intID;
203 }
204
205 //-----------------------------------------------------------------------------
206
207 void FBO::attachTexture2D( GLenum _attachment, GLsizei _width, GLsizei _height, GLuint _internalFmt, GLenum _format, GLint _wrapMode /*= GL_CLAMP*/, GLint _minFilter /*= GL_LINEAR*/, GLint _magFilter /*= GL_LINEAR*/ )
208 {
209 // gen texture id
210 GLuint texID;
211 glGenTextures(1, &texID);
212
213 #ifdef GL_ARB_texture_multisample
214 GLenum target = samples_ ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
215 #else
216 GLenum target = GL_TEXTURE_2D;
217 #endif // GL_ARB_texture_multisample
218
219
220 // if multisampled, texfilter must be GL_NEAREST
221 // texelFetch returns darker color otherwise!
222 if (samples_)
223 {
224 if (_minFilter != GL_NEAREST || _magFilter != GL_NEAREST)
225 {
226 std::cerr << "ACG::FBO - Multisampled texture must be filtered with GL_NEAREST!" << std::endl;
227
228 _minFilter = _magFilter = GL_NEAREST;
229 }
230 }
231
232 // store texture id in internal array
233 RenderTexture intID;
234 intID.id = texID;
235 intID.internalFormat = _internalFmt;
236 intID.format = _format;
237 intID.gltype = GLFormatInfo(_internalFmt).type();
238 intID.target = target;
239 intID.dim = ACG::Vec3i(_width, _height, 1);
240 intID.wrapMode = _wrapMode;
241 intID.minFilter = _minFilter;
242 intID.magFilter = _magFilter;
243 intID.owner = true;
244
245
246 // specify texture
247 glBindTexture(target, texID);
248
249
250 #ifdef GL_ARB_texture_multisample
251 if (!samples_)
252 {
253 glTexParameteri(target, GL_TEXTURE_WRAP_S, _wrapMode);
254 glTexParameteri(target, GL_TEXTURE_WRAP_T, _wrapMode);
255 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, _minFilter);
256 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, _magFilter);
257 glTexImage2D(target, 0, _internalFmt, _width, _height, 0, _format, intID.gltype, 0);
258 }
259 else
260 glTexImage2DMultisample(target, samples_, _internalFmt, _width, _height, fixedsamplelocation_);
261 #else
262 glTexParameteri(target, GL_TEXTURE_WRAP_S, _wrapMode);
263 glTexParameteri(target, GL_TEXTURE_WRAP_T, _wrapMode);
264 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, _minFilter);
265 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, _magFilter);
266 glTexImage2D(target, 0, _internalFmt, _width, _height, 0, _format, intID.gltype, 0);
267 #endif // GL_ARB_texture_multisample
268
269
270 checkGLError();
271
272 width_ = _width;
273 height_ = _height;
274
275 glBindTexture(target, 0);
276
277 // attach
278 attachTexture2D(_attachment, texID, target);
279
280 // track texture id
281 attachments_[_attachment] = intID;
282 }
283
284 //-----------------------------------------------------------------------------
285
286 void FBO::attachTexture3D( GLenum _attachment, GLsizei _width, GLsizei _height, GLsizei _depth, GLuint _internalFmt, GLenum _format, GLint _wrapMode , GLint _minFilter , GLint _magFilter )
287 {
288 // gen texture id
289 GLuint texID;
290 glGenTextures(1, &texID);
291
292 GLenum target = GL_TEXTURE_3D;
293
294 // store texture id in internal array
295 RenderTexture intID;
296 intID.id = texID;
297 intID.internalFormat = _internalFmt;
298 intID.format = _format;
299 intID.gltype = GLFormatInfo(_internalFmt).type();
300 intID.target = target;
301 intID.dim = ACG::Vec3i(_width, _height, _depth);
302 intID.wrapMode = _wrapMode;
303 intID.minFilter = _minFilter;
304 intID.magFilter = _magFilter;
305 intID.owner = true;
306
307
308 // specify texture
309 glBindTexture(target, texID);
310
311 glTexParameteri(target, GL_TEXTURE_WRAP_S, _wrapMode);
312 glTexParameteri(target, GL_TEXTURE_WRAP_T, _wrapMode);
313 glTexParameteri(target, GL_TEXTURE_WRAP_R, _wrapMode);
314 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, _minFilter);
315 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, _magFilter);
316 glTexImage3D(target, 0, _internalFmt, _width, _height, _depth, 0, _format, GL_FLOAT, 0);
317
318 checkGLError();
319
320 width_ = _width;
321 height_ = _height;
322
323 glBindTexture(target, 0);
324
325 // attach
326 attachTexture(_attachment, texID, 0);
327
328 // track texture id
329 attachments_[_attachment] = intID;
330 }
331
332 //-----------------------------------------------------------------------------
333
334 void FBO::attachTexture2DDepth( GLsizei _width, GLsizei _height, GLuint _internalFmt /*= GL_DEPTH_COMPONENT32*/, GLenum _format /*= GL_DEPTH_COMPONENT */ )
335 {
336 attachTexture2D(GL_DEPTH_ATTACHMENT, _width, _height, _internalFmt, _format, GL_CLAMP_TO_EDGE, GL_NEAREST, GL_NEAREST);
337 }
338
339 //-----------------------------------------------------------------------------
340
341 void FBO::attachTexture2DStencil( GLsizei _width, GLsizei _height )
342 {
343 attachTexture2D(GL_STENCIL_ATTACHMENT_EXT, _width, _height, GL_STENCIL_INDEX8, GL_STENCIL_INDEX, GL_CLAMP_TO_EDGE, GL_NEAREST, GL_NEAREST);
344 }
345
346 //-----------------------------------------------------------------------------
347
348 void
349 FBO::
350 addDepthBuffer( GLuint _width, GLuint _height )
351 {
352 if (depthbuffer_)
353 glDeleteRenderbuffers(1, &depthbuffer_);
354
355 // create renderbuffer
356 glGenRenderbuffers(1, &depthbuffer_);
357
358 // bind renderbuffer
359 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer_);
360
361 // malloc
362 #ifdef GL_ARB_texture_multisample
363 glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, samples_, GL_DEPTH_COMPONENT, _width, _height);
364 #else
365 glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, _width, _height);
366 #endif
367
368 // attach to framebuffer object
369 if ( bind() )
370 glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
371
372 // check status
373 checkFramebufferStatus();
374
375 // normal render mode
376 unbind();
377 }
378
379 //-----------------------------------------------------------------------------
380
381 void
382 FBO::
383 addStencilBuffer( GLuint _width, GLuint _height )
384 {
385 if (stencilbuffer_)
386 glDeleteRenderbuffers(1, &stencilbuffer_);
387
388 // create renderbuffer
389 glGenRenderbuffers(1, &stencilbuffer_);
390
391 // bind renderbuffer
392 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, stencilbuffer_);
393
394 // malloc
395 #ifdef GL_ARB_texture_multisample
396 glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, samples_, GL_STENCIL_INDEX, _width, _height);
397 #else
398 glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX, _width, _height);
399 #endif
400
401 // attach to framebuffer object
402 if ( bind() )
403 glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, stencilbuffer_);
404
405 // check status
406 checkFramebufferStatus();
407
408 // normal render mode
409 unbind();
410 }
411
412 //-----------------------------------------------------------------------------
413
414 void
415 FBO::
416 addDepthStencilBuffer( GLuint _width, GLuint _height )
417 {
418 if (depthbuffer_)
419 glDeleteRenderbuffers(1, &depthbuffer_);
420
421 if (stencilbuffer_)
422 glDeleteRenderbuffers(1, &stencilbuffer_);
423
424 depthbuffer_ = stencilbuffer_ = 0;
425
426 // create renderbuffer
427 glGenRenderbuffers(1, &depthbuffer_);
428
429 // bind renderbuffer
430 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer_);
431
432 // malloc
433 #ifdef GL_ARB_texture_multisample
434 glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, samples_, GL_DEPTH_STENCIL, _width, _height);
435 #else
436 glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL, _width, _height);
437 #endif
438
439 // attach to framebuffer object
440 if (bind())
441 {
442 glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
443 glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
444 }
445
446 // check status
447 checkFramebufferStatus();
448
449 // normal render mode
450 unbind();
451 }
452
453
454 //-----------------------------------------------------------------------------
455
456 bool
457 FBO::
458 bind()
459 {
460 // save previous fbo id
461 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&prevFbo_);
462 glGetIntegerv(GL_DRAW_BUFFER, (GLint*)&prevDrawBuffer_);
463
464 if ( !fbo_ )
465 init();
466
467 if ( !fbo_)
468 return false;
469
470 // bind framebuffer object
471 ACG::GLState::bindFramebuffer( GL_FRAMEBUFFER_EXT, fbo_ );
472
473
474 return true;
475 }
476
477 //-----------------------------------------------------------------------------
478
479 void
480 FBO::
481 unbind()
482 {
483 //set to normal rendering
484 ACG::GLState::bindFramebuffer( GL_FRAMEBUFFER_EXT, prevFbo_ );
485 ACG::GLState::drawBuffer( prevDrawBuffer_ );
486 }
487
488 //-----------------------------------------------------------------------------
489
490 bool
491 FBO::
492 checkFramebufferStatus()
493 {
494 GLenum status;
495 status = ( GLenum ) glCheckFramebufferStatus( GL_FRAMEBUFFER_EXT );
496 //std::cout << "Framebuffer status: " << status << std::endl;
497 switch ( status )
498 {
499 case GL_FRAMEBUFFER_COMPLETE_EXT:
500 //std::cout << "Framebuffer ok\n";
501 break;
502 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
503 std::cout << " Framebuffer incomplete attachment\n";
504 break;
505 case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
506 std::cout << "Unsupported framebuffer format\n";
507 break;
508 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
509 std::cout << "Framebuffer incomplete, missing attachment\n";
510 break;
511 case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
512 std::cout << "Framebuffer incomplete, attached images must have same dimensions\n";
513 break;
514 case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
515 std::cout << "Framebuffer incomplete, attached images must have same format\n";
516 break;
517 case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
518 std::cout << "Framebuffer incomplete, missing draw buffer\n";
519 break;
520 case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
521 std::cout << "Framebuffer incomplete, missing read buffer\n";
522 break;
523 case 0x8D56: // GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
524 std::cout << "Framebuffer incomplete, attached images must have same multisample count\n";
525 break;
526 default:
527 std::cout << "Unhandled case\n";
528 break;
529 }
530
531 return ( status == GL_FRAMEBUFFER_COMPLETE_EXT );
532 }
533
534 //-----------------------------------------------------------------------------
535
536 GLuint FBO::getAttachment( GLenum _attachment )
537 {
538 return attachments_[_attachment].id;
539 }
540
541 //-----------------------------------------------------------------------------
542
543 GLuint FBO::getInternalFormat( GLenum _attachment )
544 {
545 return attachments_[_attachment].internalFormat;
546 }
547
548 //-----------------------------------------------------------------------------
549
550 void FBO::resize( GLsizei _width, GLsizei _height, bool _forceResize )
551 {
552 if (_width != width_ ||_height != height_ || _forceResize)
553 {
554 // resizing already existing textures is highly driver dependent and does not always
555 // work for all combinations of texture type (2d, 2dms, 3d) and format
556 // safest way to resize is to first delete the FBO and all its internal textures, and then rebuild
557
558 if (fbo_)
559 glDeleteFramebuffers(1, &fbo_);
560 glGenFramebuffers(1, &fbo_);
561
562 // "detach" all textures
563 AttachmentList temp;
564 temp.swap(attachments_);
565
566 // reattach all targets
567 for (AttachmentList::iterator it = temp.begin(); it != temp.end(); ++it)
568 {
569 RenderTexture* rt = &it->second;
570
571 // only resize textures that are owned by the FBO
572 if (rt->owner)
573 {
574 glDeleteTextures(1, &rt->id);
575
576 switch (rt->target)
577 {
578 case GL_TEXTURE_2D:
579 #ifdef GL_ARB_texture_multisample
580 case GL_TEXTURE_2D_MULTISAMPLE:
581 #endif
582 attachTexture2D(it->first, _width, _height, rt->internalFormat, rt->format, rt->wrapMode, rt->minFilter, rt->magFilter);
583 break;
584
585 case GL_TEXTURE_3D:
586 attachTexture3D(it->first, _width, _height, rt->dim[2], rt->internalFormat, rt->format, rt->wrapMode, rt->minFilter, rt->magFilter);
587 break;
588
589 default:
590 std::cout << "FBO::resize - unknown resize target " << rt->target << std::endl;
591 }
592 }
593 }
594
595 // reattach render buffers
596 if(depthbuffer_)
597 addDepthBuffer(_width, _height);
598
599 if(stencilbuffer_)
600 addStencilBuffer(_width, _height);
601 }
602 }
603
604 GLuint FBO::getFboID()
605 {
606 return fbo_;
607 }
608
609 GLsizei FBO::setMultisampling( GLsizei _samples, GLboolean _fixedsamplelocations /*= GL_TRUE*/ )
610 {
611 // recreate textures when params changed
612 bool recreateTextures = fixedsamplelocation_ != _fixedsamplelocations;
613
614 if (samples_ != _samples)
615 {
616 // clamp sample count to max supported
617 static GLint maxSamples = -1;
618 if (maxSamples < 0)
619 glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
620
621 if (_samples >= maxSamples) _samples = maxSamples - 1;
622
623 // gpu driver might cause crash on calling glTexImage2DMultisample if _samples is not a power of 2
624 // -> avoid by seeking to next native MSAA sample-count
625
626 if (_samples)
627 {
628 int safeSampleCount = 1;
629
630 while (safeSampleCount < _samples)
631 safeSampleCount <<= 1;
632
633 while (safeSampleCount >= maxSamples)
634 safeSampleCount >>= 1;
635
636 _samples = safeSampleCount;
637 }
638
639 recreateTextures = recreateTextures || (samples_ != _samples);
640
641 samples_ = _samples;
642 }
643
644 fixedsamplelocation_ = _fixedsamplelocations;
645
646 // force texture reloading to apply new multisampling
647 if (recreateTextures)
648 resize(width_, height_, true);
649
650 return samples_;
651 }
652
653
654 //=============================================================================
655 } // namespace ACG
656 //=============================================================================
ACG::FBO::width_
GLsizei width_
width and height of render textures
Definition: FBO.hh:207
ACG::FBO::attachTexture2DDepth
void attachTexture2DDepth(GLsizei _width, GLsizei _height, GLuint _internalFmt=GL_DEPTH_COMPONENT32, GLenum _format=GL_DEPTH_COMPONENT)
function to attach a depth-buffer texture to fbo (using GL_DEPTH_ATTACHMENT)
Definition: FBO.cc:334
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::FBO::depthbuffer_
GLuint depthbuffer_
depthbuffer
Definition: FBO.hh:172
ACG::FBO::getFboID
GLuint getFboID()
return opengl id
Definition: FBO.cc:604
ACG::FBO::addDepthBuffer
void addDepthBuffer(GLuint _width, GLuint _height)
function to add a depth renderbuffer to the fbo
Definition: FBO.cc:350
ACG::FBO::stencilbuffer_
GLuint stencilbuffer_
stencilbuffer
Definition: FBO.hh:175
ACG::FBO::init
void init()
function to generate the framebuffer object
Definition: FBO.cc:86
ACG::FBO::addDepthStencilBuffer
void addDepthStencilBuffer(GLuint _width, GLuint _height)
add a packed depth24_stencil8 renderbuffer
Definition: FBO.cc:416
ACG::FBO::attachTexture3D
void attachTexture3D(GLenum _attachment, GLsizei _width, GLsizei _height, GLsizei _depth, GLuint _internalFmt, GLenum _format, GLint _wrapMode=GL_CLAMP, GLint _minFilter=GL_NEAREST, GLint _magFilter=GL_NEAREST)
Definition: FBO.cc:286
ACG::FBO::setMultisampling
GLsizei setMultisampling(GLsizei _samples, GLboolean _fixedsamplelocations=GL_TRUE)
Definition: FBO.cc:609
ACG::FBO::prevFbo_
GLuint prevFbo_
handle of previously bound fbo
Definition: FBO.hh:217
ACG::GLFormatInfo
Definition: GLFormatInfo.hh:70
ACG::GLState::bindFramebuffer
static void bindFramebuffer(GLenum _target, GLuint _framebuffer)
replaces glBindFramebuffer, supports locking
Definition: GLState.cc:2089
ACG::FBO::bind
bool bind()
bind the fbo and sets it as rendertarget
Definition: FBO.cc:458
ACG::Vec3i
VectorT< signed int, 3 > Vec3i
Definition: VectorT.hh:115
ACG::GLState::drawBuffer
static void drawBuffer(GLenum _mode)
replaces glDrawBuffer, supports locking
Definition: GLState.cc:2033
ACG::FBO::resize
void resize(GLsizei _width, GLsizei _height, bool _forceResize=false)
resize function (if textures created by this class)
Definition: FBO.cc:550
ACG::FBO::RenderTexture
attached textures
Definition: FBO.hh:178
ACG::FBO::checkFramebufferStatus
bool checkFramebufferStatus()
function to check the framebuffer status
Definition: FBO.cc:492
ACG::FBO::attachTexture2D
void attachTexture2D(GLenum _attachment, GLsizei _width, GLsizei _height, GLuint _internalFmt, GLenum _format, GLint _wrapMode=GL_CLAMP_TO_EDGE, GLint _minFilter=GL_NEAREST, GLint _magFilter=GL_NEAREST)
function to attach a texture to fbo
Definition: FBO.cc:207
ACG::FBO::attachTexture
void attachTexture(GLenum _attachment, GLuint _texture, GLuint _level=0)
attach a texture of arbitrary dimension (requires OpenGL 3.2)
Definition: FBO.cc:133
ACG::FBO::unbind
void unbind()
unbind fbo, go to normal rendering mode
Definition: FBO.cc:481
ACG::FBO::del
void del()
delete fbo and all internally created render textures
Definition: FBO.cc:111
ACG::FBO::samples_
GLsizei samples_
sample count if multisampling
Definition: FBO.hh:210
ACG::FBO::getInternalFormat
GLuint getInternalFormat(GLenum _attachment)
return internal texture format of attachment
Definition: FBO.cc:543
ACG::checkExtensionSupported
bool checkExtensionSupported(const std::string &_extension)
Definition: gl.cc:107
ACG::FBO::~FBO
~FBO()
Destructor.
Definition: FBO.cc:77
ACG::FBO::fbo_
GLuint fbo_
handle of frame buffer object
Definition: FBO.hh:169
ACG::FBO::fixedsamplelocation_
GLboolean fixedsamplelocation_
enable fixed sample location if multisampling
Definition: FBO.hh:213
ACG::FBO::getAttachment
GLuint getAttachment(GLenum _attachment)
return attached texture id
Definition: FBO.cc:536
ACG::FBO::addStencilBuffer
void addStencilBuffer(GLuint _width, GLuint _height)
function to add a stencil renderbuffer to the fbo
Definition: FBO.cc:383
ACG::FBO::attachTexture2DStencil
void attachTexture2DStencil(GLsizei _width, GLsizei _height)
function to attach a stencil-buffer texture to fbo (texformat = GL_STENCIL_INDEX8) ...
Definition: FBO.cc:341
ACG::openGLVersion
bool openGLVersion(const int _major, const int _minor, bool _verbose)
Definition: gl.cc:129