From c8c5becc81679eb8a9a0f8baa454bc43fd3cccf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 13 May 2009 14:47:54 +0200 Subject: Reverted use of GL 2 engine as default on desktop. Using GL 2 as default engine breaks the use cases where OpenGL commands are inter-mixed with QPainter commands, such as when using raw OpenGL in graphicsview. For now we'll use the old OpenGL engine for QGLWidget, QGLPixelBuffer, and QGLFramebufferObject on desktop, and the OpenGL 2 paint engine when the OpenGL graphics system is used. Reviewed-by: Trond --- src/opengl/qgl.cpp | 4 ++-- src/opengl/qgl_p.h | 5 ++--- src/opengl/qglframebufferobject.cpp | 3 ++- src/opengl/qglpixelbuffer.cpp | 2 +- src/opengl/qpixmapdata_gl.cpp | 8 ++++---- src/opengl/qwindowsurface_gl.cpp | 20 ++++---------------- 6 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 779ed9a..12f781e 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1366,7 +1366,7 @@ QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alp int w = size.width(); int h = size.height(); #if !defined(QT_OPENGL_ES_2) //### glGetTexImage not in GL ES 2.0, need to do something else here! - glGetTexImage(qt_gl_preferredTextureTarget(), 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); #endif convertFromGLImage(img, w, h, alpha_format, include_alpha); return img; @@ -1971,7 +1971,7 @@ GLuint QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, GLin { Q_Q(QGLContext); QPixmapData *pd = pixmap.pixmapData(); - if (target == qt_gl_preferredTextureTarget() && pd->classId() == QPixmapData::OpenGLClass) { + if (target == GL_TEXTURE_2D && pd->classId() == QPixmapData::OpenGLClass) { const QGLPixmapData *data = static_cast(pd); if (data->isValidContext(q)) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 1513ee8..a294af9 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -424,9 +424,8 @@ inline bool qt_gl_preferGL2Engine() #if defined(QT_OPENGL_ES_2) return true; #else - QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags(); - bool hasOpenGL2 = (flags & QGLFormat::OpenGL_Version_2_0); - return hasOpenGL2 && qgetenv("QT_GL_NO_OPENGL2ENGINE").isEmpty(); + return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) + && !qgetenv("QT_GL_USE_OPENGL2ENGINE").isEmpty(); #endif } diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 87e0dda..5f106ff 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -906,8 +906,9 @@ Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) /*! \reimp */ QPaintEngine *QGLFramebufferObject::paintEngine() const { + Q_D(const QGLFramebufferObject); #if !defined(QT_OPENGL_ES_2) - if (qt_gl_preferGL2Engine()) + if (d->ctx->d_func()->internal_context || qt_gl_preferGL2Engine()) return qt_buffer_2_engine(); else return qt_buffer_engine(); diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index cb24177..00b58d3 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -375,7 +375,7 @@ Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) QPaintEngine *QGLPixelBuffer::paintEngine() const { #if !defined(QT_OPENGL_ES_2) - if (qt_gl_preferGL2Engine()) + if (d_ptr->qctx->d_func()->internal_context || qt_gl_preferGL2Engine()) return qt_buffer_2_engine(); else return qt_buffer_engine(); diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 89e6749..e3af864 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -160,7 +160,7 @@ void QGLPixmapData::ensureCreated() const m_ctx = ctx; const GLenum format = qt_gl_preferredTextureFormat(); - const GLenum target = qt_gl_preferredTextureTarget(); + const GLenum target = GL_TEXTURE_2D; if (!m_textureId) { glGenTextures(1, &m_textureId); @@ -252,7 +252,7 @@ QImage QGLPixmapData::toImage() const QGLShareContextScope ctx(qt_gl_share_widget()->context()); extern QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha); - glBindTexture(qt_gl_preferredTextureTarget(), m_textureId); + glBindTexture(GL_TEXTURE_2D, m_textureId); return qt_gl_read_texture(QSize(m_width, m_height), true, true); } @@ -280,7 +280,7 @@ void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->fbo); glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - qt_gl_preferredTextureTarget(), m_textureId, 0); + GL_TEXTURE_2D, m_textureId, 0); const int x0 = 0; const int x1 = m_width; @@ -398,7 +398,7 @@ GLuint QGLPixmapData::bind(bool copyBack) const ensureCreated(); GLuint id = m_textureId; - glBindTexture(qt_gl_preferredTextureTarget(), id); + glBindTexture(GL_TEXTURE_2D, id); return id; } diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index c732174..6fce3e3 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -72,10 +72,6 @@ #include -#ifndef QT_OPENGL_ES_2 -#include -#endif - #ifndef GLX_ARB_multisample #define GLX_SAMPLE_BUFFERS_ARB 100000 #define GLX_SAMPLES_ARB 100001 @@ -295,17 +291,9 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine) -#ifndef QT_OPENGL_ES_2 -Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine) -#endif - /*! \reimp */ QPaintEngine *QGLWindowSurface::paintEngine() const { -#if !defined(QT_OPENGL_ES_2) - if (!qt_gl_preferGL2Engine()) - return qt_gl_window_surface_engine(); -#endif return qt_gl_window_surface_2_engine(); } @@ -361,7 +349,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & QPoint wOffset = qt_qwidget_data(parent)->wrect.topLeft(); QRect rect = br.translated(-offset - wOffset); - const GLenum target = qt_gl_preferredTextureTarget(); + const GLenum target = GL_TEXTURE_2D; if (context()) { context()->makeCurrent(); @@ -502,7 +490,7 @@ void QGLWindowSurface::updateGeometry() { QRect rect = QWindowSurface::geometry(); - const GLenum target = qt_gl_preferredTextureTarget(); + const GLenum target = GL_TEXTURE_2D; if (rect.width() <= 0 || rect.height() <= 0) return; @@ -643,7 +631,7 @@ bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy) return true; #endif - const GLenum target = qt_gl_preferredTextureTarget(); + const GLenum target = GL_TEXTURE_2D; glBindTexture(target, d_ptr->tex_id); glCopyTexImage2D(target, 0, GL_RGBA, br.x(), d_ptr->pb->height() - (br.y() + br.height()), br.width(), br.height(), 0); @@ -656,7 +644,7 @@ bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy) static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br) { - const GLenum target = qt_gl_preferredTextureTarget(); + const GLenum target = GL_TEXTURE_2D; QRectF src = br.isEmpty() ? QRectF(QPointF(), texSize) : QRectF(QPointF(br.x(), texSize.height() - br.bottom()), br.size()); -- cgit v0.12