Qt 4.8
Public Functions | Public Variables | List of all members
QGLFramebufferObjectPrivate Class Reference

#include <qglframebufferobject_p.h>

Public Functions

bool checkFramebufferStatus () const
 
GLuint fbo () const
 
void init (QGLFramebufferObject *q, const QSize &sz, QGLFramebufferObject::Attachment attachment, GLenum internal_format, GLenum texture_target, GLint samples=0, bool mipmap=false)
 
 QGLFramebufferObjectPrivate ()
 
 ~QGLFramebufferObjectPrivate ()
 

Public Variables

GLuint color_buffer
 
GLuint depth_buffer
 
QPaintEngineengine
 
QGLFramebufferObject::Attachment fbo_attachment
 
QGLSharedResourceGuard fbo_guard
 
QGLFramebufferObjectFormat format
 
QGLFBOGLPaintDevice glDevice
 
QSize size
 
GLuint stencil_buffer
 
GLenum target
 
GLuint texture
 
uint valid: 1
 

Detailed Description

Definition at line 130 of file qglframebufferobject_p.h.

Constructors and Destructors

◆ QGLFramebufferObjectPrivate()

QGLFramebufferObjectPrivate::QGLFramebufferObjectPrivate ( )
inline

◆ ~QGLFramebufferObjectPrivate()

QGLFramebufferObjectPrivate::~QGLFramebufferObjectPrivate ( )
inline

Definition at line 135 of file qglframebufferobject_p.h.

135 {}

Functions

◆ checkFramebufferStatus()

bool QGLFramebufferObjectPrivate::checkFramebufferStatus ( ) const

Definition at line 394 of file qglframebufferobject.cpp.

395 {
397  if (!ctx)
398  return false; // Context no longer exists.
400  switch(status) {
401  case GL_NO_ERROR:
403  return true;
404  break;
406  qDebug("QGLFramebufferObject: Unsupported framebuffer format.");
407  break;
409  qDebug("QGLFramebufferObject: Framebuffer incomplete attachment.");
410  break;
412  qDebug("QGLFramebufferObject: Framebuffer incomplete, missing attachment.");
413  break;
414 #ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT
416  qDebug("QGLFramebufferObject: Framebuffer incomplete, duplicate attachment.");
417  break;
418 #endif
420  qDebug("QGLFramebufferObject: Framebuffer incomplete, attached images must have same dimensions.");
421  break;
423  qDebug("QGLFramebufferObject: Framebuffer incomplete, attached images must have same format.");
424  break;
426  qDebug("QGLFramebufferObject: Framebuffer incomplete, missing draw buffer.");
427  break;
429  qDebug("QGLFramebufferObject: Framebuffer incomplete, missing read buffer.");
430  break;
432  qDebug("QGLFramebufferObject: Framebuffer incomplete, attachments must have same number of samples per pixel.");
433  break;
434  default:
435  qDebug() <<"QGLFramebufferObject: An undefined error has occurred: "<< status;
436  break;
437  }
438  return false;
439 }
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
#define GL_FRAMEBUFFER_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
Q_CORE_EXPORT void qDebug(const char *,...)
#define glCheckFramebufferStatus
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT
#define GL_FRAMEBUFFER_UNSUPPORTED_EXT
unsigned int GLenum
Definition: main.cpp:50
#define ctx
Definition: qgl.cpp:6094
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT
#define GL_FRAMEBUFFER_COMPLETE_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
#define QGL_FUNCP_CONTEXT
#define GL_NO_ERROR
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT

◆ fbo()

GLuint QGLFramebufferObjectPrivate::fbo ( ) const
inline

Definition at line 155 of file qglframebufferobject_p.h.

155 { return fbo_guard.id(); }
GLuint id() const
Definition: qgl_p.h:880
QGLSharedResourceGuard fbo_guard

◆ init()

void QGLFramebufferObjectPrivate::init ( QGLFramebufferObject q,
const QSize sz,
QGLFramebufferObject::Attachment  attachment,
GLenum  internal_format,
GLenum  texture_target,
GLint  samples = 0,
bool  mipmap = false 
)

Definition at line 441 of file qglframebufferobject.cpp.

445 {
447  fbo_guard.setContext(ctx);
448 
450  if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(ctx)))
451  return;
452 
453  size = sz;
454  target = texture_target;
455  // texture dimensions
456 
457  QT_RESET_GLERROR(); // reset error state
458  GLuint fbo = 0;
459  glGenFramebuffers(1, &fbo);
461  fbo_guard.setId(fbo);
462 
463  glDevice.setFBO(q, attachment);
464 
466  // init texture
467  if (samples == 0) {
468  glGenTextures(1, &texture);
469  glBindTexture(target, texture);
470  glTexImage2D(target, 0, internal_format, size.width(), size.height(), 0,
471  GL_RGBA, GL_UNSIGNED_BYTE, NULL);
472  if (mipmap)
474 #ifndef QT_OPENGL_ES
475  glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
476  glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
477  glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
478  glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
479 #else
480  glTexParameterf(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
481  glTexParameterf(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
482  glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
483  glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
484 #endif
486  target, texture, 0);
487 
490  glBindTexture(target, 0);
491 
492  color_buffer = 0;
493  } else {
494  mipmap = false;
495  GLint maxSamples;
496  glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
497 
498  samples = qBound(0, int(samples), int(maxSamples));
499 
502  if (glRenderbufferStorageMultisampleEXT && samples > 0) {
504  internal_format, size.width(), size.height());
505  } else {
506  samples = 0;
508  size.width(), size.height());
509  }
510 
513 
516 
517  if (valid)
519  }
520 
521  // In practice, a combined depth-stencil buffer is supported by all desktop platforms, while a
522  // separate stencil buffer is not. On embedded devices however, a combined depth-stencil buffer
523  // might not be supported while separate buffers are, according to QTBUG-12861.
524 
527  // depth and stencil buffer needs another extension
532  if (samples != 0 && glRenderbufferStorageMultisampleEXT)
535  else
538 
543  GL_RENDERBUFFER_EXT, stencil_buffer);
544 
546  if (!valid) {
548  stencil_buffer = depth_buffer = 0;
549  }
550  }
551 
553  || (attachment == QGLFramebufferObject::Depth)))
554  {
559  if (samples != 0 && glRenderbufferStorageMultisampleEXT) {
560 #ifdef QT_OPENGL_ES
564  } else {
567  }
568 #else
571 #endif
572  } else {
573 #ifdef QT_OPENGL_ES
576  size.width(), size.height());
577  } else {
579  size.width(), size.height());
580  }
581 #else
583 #endif
584  }
588  if (!valid) {
590  depth_buffer = 0;
591  }
592  }
593 
594  if (stencil_buffer == 0 && (attachment == QGLFramebufferObject::CombinedDepthStencil)) {
595  glGenRenderbuffers(1, &stencil_buffer);
596  Q_ASSERT(!glIsRenderbuffer(stencil_buffer));
597  glBindRenderbuffer(GL_RENDERBUFFER_EXT, stencil_buffer);
598  Q_ASSERT(glIsRenderbuffer(stencil_buffer));
599  if (samples != 0 && glRenderbufferStorageMultisampleEXT) {
600 #ifdef QT_OPENGL_ES
603 #else
606 #endif
607  } else {
608 #ifdef QT_OPENGL_ES
610  size.width(), size.height());
611 #else
613  size.width(), size.height());
614 #endif
615  }
617  GL_RENDERBUFFER_EXT, stencil_buffer);
619  if (!valid) {
620  glDeleteRenderbuffers(1, &stencil_buffer);
621  stencil_buffer = 0;
622  }
623  }
624 
625  // The FBO might have become valid after removing the depth or stencil buffer.
627 
628  if (depth_buffer && stencil_buffer) {
630  } else if (depth_buffer) {
632  } else {
634  }
635 
637  if (!valid) {
638  if (color_buffer)
640  else
641  glDeleteTextures(1, &texture);
642  if (depth_buffer)
644  if (stencil_buffer && depth_buffer != stencil_buffer)
645  glDeleteRenderbuffers(1, &stencil_buffer);
646  glDeleteFramebuffers(1, &fbo);
647  fbo_guard.setId(0);
648  }
650 
651  format.setTextureTarget(target);
652  format.setSamples(int(samples));
653  format.setAttachment(fbo_attachment);
654  format.setInternalTextureFormat(internal_format);
655  format.setMipmap(mipmap);
656 }
#define GL_RENDERBUFFER_SAMPLES_EXT
QScopedPointer< QGLContextPrivate > d_ptr
Definition: qgl.h:430
#define GL_CLAMP_TO_EDGE
Definition: glfunctions.h:62
#define GL_TEXTURE_MIN_FILTER
#define GL_STENCIL_INDEX
#define GL_DEPTH_COMPONENT
#define glGenRenderbuffers
bool qt_resolve_framebufferobject_extensions(QGLContext *ctx)
#define GL_TEXTURE_WRAP_S
#define GL_FRAMEBUFFER_EXT
#define GL_DEPTH24_STENCIL8_EXT
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define glBindFramebuffer
#define glRenderbufferStorageMultisampleEXT
#define QT_RESET_GLERROR()
#define GL_TEXTURE_2D
#define glDeleteRenderbuffers
#define GL_COLOR_ATTACHMENT0_EXT
static const QGLContext * currentContext()
Returns the current context, i.e.
Definition: qgl.cpp:3545
#define GL_STENCIL_ATTACHMENT_EXT
int width() const
Returns the width.
Definition: qsize.h:126
QGLSharedResourceGuard fbo_guard
#define QT_CHECK_GLERROR()
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
#define GL_DEPTH_COMPONENT16
#define GL_RENDERBUFFER_EXT
#define glDeleteFramebuffers
#define glIsRenderbuffer
void setContext(const QGLContext *context)
Definition: qgl.cpp:5983
#define glGenFramebuffers
#define GL_DEPTH_ATTACHMENT_EXT
#define glGetRenderbufferParameteriv
#define glBindRenderbuffer
#define GL_TEXTURE_WRAP_T
GLuint current_fbo
Definition: qgl_p.h:456
void setId(GLuint id)
Definition: qgl_p.h:885
#define GL_MAX_SAMPLES_EXT
#define GL_STENCIL_INDEX8_EXT
#define GL_UNSIGNED_BYTE
QGLFramebufferObject::Attachment fbo_attachment
#define ctx
Definition: qgl.cpp:6094
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
void setFBO(QGLFramebufferObject *f, QGLFramebufferObject::Attachment attachment)
int height() const
Returns the height.
Definition: qsize.h:129
static Extensions glExtensions()
Definition: qgl.cpp:5781
typedef GLint
Definition: glfunctions.h:67
#define GL_RGBA
#define glFramebufferRenderbuffer
#define GL_TEXTURE_MAG_FILTER
#define glFramebufferTexture2D
#define glGenerateMipmap
Definition: glfunctions.h:70
#define glRenderbufferStorage
#define GL_DEPTH_COMPONENT24_OES
#define GL_NEAREST

Properties

◆ color_buffer

GLuint QGLFramebufferObjectPrivate::color_buffer

Definition at line 146 of file qglframebufferobject_p.h.

◆ depth_buffer

GLuint QGLFramebufferObjectPrivate::depth_buffer

Definition at line 144 of file qglframebufferobject_p.h.

◆ engine

QPaintEngine* QGLFramebufferObjectPrivate::engine
mutable

Definition at line 152 of file qglframebufferobject_p.h.

◆ fbo_attachment

QGLFramebufferObject::Attachment QGLFramebufferObjectPrivate::fbo_attachment

Definition at line 151 of file qglframebufferobject_p.h.

◆ fbo_guard

QGLSharedResourceGuard QGLFramebufferObjectPrivate::fbo_guard

Definition at line 142 of file qglframebufferobject_p.h.

◆ format

QGLFramebufferObjectFormat QGLFramebufferObjectPrivate::format

Definition at line 149 of file qglframebufferobject_p.h.

◆ glDevice

QGLFBOGLPaintDevice QGLFramebufferObjectPrivate::glDevice

Definition at line 153 of file qglframebufferobject_p.h.

◆ size

QSize QGLFramebufferObjectPrivate::size

Definition at line 148 of file qglframebufferobject_p.h.

◆ stencil_buffer

GLuint QGLFramebufferObjectPrivate::stencil_buffer

Definition at line 145 of file qglframebufferobject_p.h.

◆ target

GLenum QGLFramebufferObjectPrivate::target

Definition at line 147 of file qglframebufferobject_p.h.

◆ texture

GLuint QGLFramebufferObjectPrivate::texture

Definition at line 143 of file qglframebufferobject_p.h.

◆ valid

uint QGLFramebufferObjectPrivate::valid

Definition at line 150 of file qglframebufferobject_p.h.


The documentation for this class was generated from the following files: