src/opengl/qglframebufferobject.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
child 30 5dc02b23752f
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
     8 **
     8 **
   327         fboFormat.setDepth(true);
   327         fboFormat.setDepth(true);
   328         fboFormat.setStencil(true);
   328         fboFormat.setStencil(true);
   329     } else if (attachment == QGLFramebufferObject::Depth) {
   329     } else if (attachment == QGLFramebufferObject::Depth) {
   330         fboFormat.setDepth(true);
   330         fboFormat.setDepth(true);
   331     }
   331     }
       
   332 
       
   333     GLenum format = f->format().internalTextureFormat();
       
   334     reqAlpha = (format != GL_RGB
       
   335 #ifndef QT_OPENGL_ES
       
   336                 && format != GL_RGB5 && format != GL_RGB8
       
   337 #endif
       
   338     );
   332 }
   339 }
   333 
   340 
   334 QGLContext *QGLFBOGLPaintDevice::context() const
   341 QGLContext *QGLFBOGLPaintDevice::context() const
   335 {
   342 {
   336     QGLContext *fboContext = const_cast<QGLContext *>(fbo->d_ptr->fbo_guard.context());
   343     QGLContext *fboContext = const_cast<QGLContext *>(fbo->d_ptr->fbo_guard.context());
   394                                        GLenum texture_target, GLenum internal_format, GLint samples)
   401                                        GLenum texture_target, GLenum internal_format, GLint samples)
   395 {
   402 {
   396     QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
   403     QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
   397     fbo_guard.setContext(ctx);
   404     fbo_guard.setContext(ctx);
   398 
   405 
   399     bool ext_detected = (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject);
   406     bool ext_detected = (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject);
   400     if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(ctx)))
   407     if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(ctx)))
   401         return;
   408         return;
   402 
   409 
   403     size = sz;
   410     size = sz;
   404     target = texture_target;
   411     target = texture_target;
   464         if (valid)
   471         if (valid)
   465             glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &samples);
   472             glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT, &samples);
   466     }
   473     }
   467 
   474 
   468     if (attachment == QGLFramebufferObject::CombinedDepthStencil
   475     if (attachment == QGLFramebufferObject::CombinedDepthStencil
   469         && (QGLExtensions::glExtensions & QGLExtensions::PackedDepthStencil)) {
   476         && (QGLExtensions::glExtensions() & QGLExtensions::PackedDepthStencil)) {
   470         // depth and stencil buffer needs another extension
   477         // depth and stencil buffer needs another extension
   471         glGenRenderbuffers(1, &depth_stencil_buffer);
   478         glGenRenderbuffers(1, &depth_stencil_buffer);
   472         Q_ASSERT(!glIsRenderbuffer(depth_stencil_buffer));
   479         Q_ASSERT(!glIsRenderbuffer(depth_stencil_buffer));
   473         glBindRenderbuffer(GL_RENDERBUFFER_EXT, depth_stencil_buffer);
   480         glBindRenderbuffer(GL_RENDERBUFFER_EXT, depth_stencil_buffer);
   474         Q_ASSERT(glIsRenderbuffer(depth_stencil_buffer));
   481         Q_ASSERT(glIsRenderbuffer(depth_stencil_buffer));
  1026     Returns true if the OpenGL \c{GL_EXT_framebuffer_object} extension
  1033     Returns true if the OpenGL \c{GL_EXT_framebuffer_object} extension
  1027     is present on this system; otherwise returns false.
  1034     is present on this system; otherwise returns false.
  1028 */
  1035 */
  1029 bool QGLFramebufferObject::hasOpenGLFramebufferObjects()
  1036 bool QGLFramebufferObject::hasOpenGLFramebufferObjects()
  1030 {
  1037 {
  1031     QGLExtensions::init();
  1038     return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject);
  1032     return (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject);
       
  1033 }
  1039 }
  1034 
  1040 
  1035 /*!
  1041 /*!
  1036     \since 4.4
  1042     \since 4.4
  1037 
  1043 
  1186 
  1192 
  1187     \sa blitFramebuffer()
  1193     \sa blitFramebuffer()
  1188 */
  1194 */
  1189 bool QGLFramebufferObject::hasOpenGLFramebufferBlit()
  1195 bool QGLFramebufferObject::hasOpenGLFramebufferBlit()
  1190 {
  1196 {
  1191     QGLExtensions::init();
  1197     return (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit);
  1192     return (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit);
       
  1193 }
  1198 }
  1194 
  1199 
  1195 /*!
  1200 /*!
  1196     \since 4.6
  1201     \since 4.6
  1197 
  1202 
  1227 void QGLFramebufferObject::blitFramebuffer(QGLFramebufferObject *target, const QRect &targetRect,
  1232 void QGLFramebufferObject::blitFramebuffer(QGLFramebufferObject *target, const QRect &targetRect,
  1228                                            QGLFramebufferObject *source, const QRect &sourceRect,
  1233                                            QGLFramebufferObject *source, const QRect &sourceRect,
  1229                                            GLbitfield buffers,
  1234                                            GLbitfield buffers,
  1230                                            GLenum filter)
  1235                                            GLenum filter)
  1231 {
  1236 {
  1232     if (!(QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit))
  1237     if (!(QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit))
  1233         return;
  1238         return;
  1234 
  1239 
  1235     const QGLContext *ctx = QGLContext::currentContext();
  1240     const QGLContext *ctx = QGLContext::currentContext();
  1236     if (!ctx)
  1241     if (!ctx)
  1237         return;
  1242         return;