src/opengl/qwindowsurface_gl.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
    80 #ifndef GLX_ARB_multisample
    80 #ifndef GLX_ARB_multisample
    81 #define GLX_SAMPLE_BUFFERS_ARB  100000
    81 #define GLX_SAMPLE_BUFFERS_ARB  100000
    82 #define GLX_SAMPLES_ARB         100001
    82 #define GLX_SAMPLES_ARB         100001
    83 #endif
    83 #endif
    84 
    84 
    85 #ifdef QT_OPENGL_ES_1_CL
    85 #ifndef QT_NO_EGL
    86 #include "qgl_cl_p.h"
    86 #include <private/qeglcontext_p.h>
    87 #endif
       
    88 
       
    89 #ifdef QT_OPENGL_ES
       
    90 #include <private/qegl_p.h>
       
    91 #endif
    87 #endif
    92 
    88 
    93 QT_BEGIN_NAMESPACE
    89 QT_BEGIN_NAMESPACE
    94 
    90 
    95 //
    91 //
    96 // QGLGraphicsSystem
    92 // QGLGraphicsSystem
    97 //
    93 //
    98 #ifdef Q_WS_WIN
    94 #ifdef Q_WS_WIN
    99 extern Q_GUI_EXPORT bool qt_win_owndc_required;
    95 extern Q_GUI_EXPORT bool qt_win_owndc_required;
   100 #endif
    96 #endif
   101 QGLGraphicsSystem::QGLGraphicsSystem()
    97 QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
   102     : QGraphicsSystem()
    98     : QGraphicsSystem(), m_useX11GL(useX11GL)
   103 {
    99 {
   104 #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
   100 #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
   105     // only override the system defaults if the user hasn't already
   101     // only override the system defaults if the user hasn't already
   106     // picked a visual
   102     // picked a visual
   107     if (X11->visual == 0 && X11->visual_id == -1 && X11->visual_class == -1) {
   103     if (X11->visual == 0 && X11->visual_id == -1 && X11->visual_class == -1) {
   355         return;
   351         return;
   356 
   352 
   357     QGLContext *ctx = new QGLContext(surfaceFormat, widget);
   353     QGLContext *ctx = new QGLContext(surfaceFormat, widget);
   358     ctx->create(qt_gl_share_widget()->context());
   354     ctx->create(qt_gl_share_widget()->context());
   359 
   355 
   360 #if defined(Q_WS_X11) && defined(QT_OPENGL_ES)
   356 #ifndef QT_NO_EGL
   361     // Create the EGL surface to draw into.  QGLContext::chooseContext()
   357     if (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED)
   362     // does not do this for X11/EGL, but does do it for other platforms.
   358         setPartialUpdateSupport(false); // Force full-screen updates
   363     // This probably belongs in qgl_x11egl.cpp.
       
   364     QGLContextPrivate *ctxpriv = ctx->d_func();
       
   365     ctxpriv->eglSurface = ctxpriv->eglContext->createSurface(widget);
       
   366     if (ctxpriv->eglSurface == EGL_NO_SURFACE) {
       
   367         qWarning() << "hijackWindow() could not create EGL surface";
       
   368     }
       
   369     qDebug("QGLWindowSurface - using EGLConfig %d", reinterpret_cast<int>(ctxpriv->eglContext->config()));
       
   370 #endif
   359 #endif
   371 
   360 
   372     widgetPrivate->extraData()->glContext = ctx;
   361     widgetPrivate->extraData()->glContext = ctx;
   373 
   362 
   374     union { QGLContext **ctxPtr; void **voidPtr; };
   363     union { QGLContext **ctxPtr; void **voidPtr; };
   836         src.setRight(src.right() / width);
   825         src.setRight(src.right() / width);
   837         src.setTop(src.top() / height);
   826         src.setTop(src.top() / height);
   838         src.setBottom(src.bottom() / height);
   827         src.setBottom(src.bottom() / height);
   839     }
   828     }
   840 
   829 
   841     const q_vertexType tx1 = f2vt(src.left());
   830     const GLfloat tx1 = src.left();
   842     const q_vertexType tx2 = f2vt(src.right());
   831     const GLfloat tx2 = src.right();
   843     const q_vertexType ty1 = f2vt(src.top());
   832     const GLfloat ty1 = src.top();
   844     const q_vertexType ty2 = f2vt(src.bottom());
   833     const GLfloat ty2 = src.bottom();
   845 
   834 
   846     q_vertexType texCoordArray[4*2] = {
   835     GLfloat texCoordArray[4*2] = {
   847         tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1
   836         tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1
   848     };
   837     };
   849 
   838 
   850     q_vertexType vertexArray[4*2];
   839     GLfloat vertexArray[4*2];
   851     extern void qt_add_rect_to_array(const QRectF &r, q_vertexType *array); // qpaintengine_opengl.cpp
   840     extern void qt_add_rect_to_array(const QRectF &r, GLfloat *array); // qpaintengine_opengl.cpp
   852     qt_add_rect_to_array(rect, vertexArray);
   841     qt_add_rect_to_array(rect, vertexArray);
   853 
   842 
   854 #if !defined(QT_OPENGL_ES_2)
   843 #if !defined(QT_OPENGL_ES_2)
   855     glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
   844     glVertexPointer(2, GL_FLOAT, 0, vertexArray);
   856     glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray);
   845     glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray);
   857 
   846 
   858     glBindTexture(target, tex_id);
   847     glBindTexture(target, tex_id);
   859     glEnable(target);
   848     glEnable(target);
   860 
   849 
   861     glEnableClientState(GL_VERTEX_ARRAY);
   850     glEnableClientState(GL_VERTEX_ARRAY);