src/opengl/qwindowsurface_gl.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 30 5dc02b23752f
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     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 **
   293 
   293 
   294 QGLWindowSurface::QGLWindowSurface(QWidget *window)
   294 QGLWindowSurface::QGLWindowSurface(QWidget *window)
   295     : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
   295     : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
   296 {
   296 {
   297     Q_ASSERT(window->isTopLevel());
   297     Q_ASSERT(window->isTopLevel());
   298     QGLExtensions::init();
       
   299     d_ptr->pb = 0;
   298     d_ptr->pb = 0;
   300     d_ptr->fbo = 0;
   299     d_ptr->fbo = 0;
   301     d_ptr->ctx = 0;
   300     d_ptr->ctx = 0;
   302 #if defined (QT_OPENGL_ES_2)
   301 #if defined (QT_OPENGL_ES_2)
   303     d_ptr->tried_fbo = true;
   302     d_ptr->tried_fbo = true;
   518         size = parent->size();
   517         size = parent->size();
   519     }
   518     }
   520 
   519 
   521     glDisable(GL_SCISSOR_TEST);
   520     glDisable(GL_SCISSOR_TEST);
   522 
   521 
   523     if (d_ptr->fbo && (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit)) {
   522     if (d_ptr->fbo && (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit)) {
   524         const int h = d_ptr->fbo->height();
   523         const int h = d_ptr->fbo->height();
   525 
   524 
   526         const int sx0 = br.left();
   525         const int sx0 = br.left();
   527         const int sx1 = br.left() + br.width();
   526         const int sx1 = br.left() + br.width();
   528         const int sy0 = h - (br.top() + br.height());
   527         const int sy0 = h - (br.top() + br.height());
   696 #endif
   695 #endif
   697         return;
   696         return;
   698     }
   697     }
   699 
   698 
   700     if (d_ptr->destructive_swap_buffers
   699     if (d_ptr->destructive_swap_buffers
   701         && (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject)
   700         && (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject)
   702         && (d_ptr->fbo || !d_ptr->tried_fbo)
   701         && (d_ptr->fbo || !d_ptr->tried_fbo)
   703         && qt_gl_preferGL2Engine())
   702         && qt_gl_preferGL2Engine())
   704     {
   703     {
   705         d_ptr->tried_fbo = true;
   704         d_ptr->tried_fbo = true;
   706         ctx->d_ptr->internal_context = true;
   705         ctx->d_ptr->internal_context = true;
   710         QGLFramebufferObjectFormat format;
   709         QGLFramebufferObjectFormat format;
   711         format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
   710         format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
   712         format.setInternalTextureFormat(GLenum(GL_RGBA));
   711         format.setInternalTextureFormat(GLenum(GL_RGBA));
   713         format.setTextureTarget(target);
   712         format.setTextureTarget(target);
   714 
   713 
   715         if (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit)
   714         if (QGLExtensions::glExtensions() & QGLExtensions::FramebufferBlit)
   716             format.setSamples(8);
   715             format.setSamples(8);
   717 
   716 
   718         d_ptr->fbo = new QGLFramebufferObject(rect.size(), format);
   717         d_ptr->fbo = new QGLFramebufferObject(rect.size(), format);
   719 
   718 
   720         if (d_ptr->fbo->isValid()) {
   719         if (d_ptr->fbo->isValid()) {