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