summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qglfunctions.h5
-rw-r--r--src/opengl/qwindowsurface_gl.cpp20
-rw-r--r--src/opengl/qwindowsurface_gl_p.h3
3 files changed, 24 insertions, 4 deletions
diff --git a/src/opengl/qglfunctions.h b/src/opengl/qglfunctions.h
index e06de7f..88f43c0 100644
--- a/src/opengl/qglfunctions.h
+++ b/src/opengl/qglfunctions.h
@@ -42,6 +42,11 @@
#ifndef QGLFUNCTIONS_H
#define QGLFUNCTIONS_H
+#ifdef __GLEW_H__
+#warning qglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
+#warning To use GLEW with Qt, do not include <QtOpenGL> or <QGLFunctions> after glew.h
+#endif
+
#include <QtOpenGL/qgl.h>
QT_BEGIN_HEADER
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 6185ff8..81575e3 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -302,6 +302,7 @@ struct QGLWindowSurfacePrivate
};
QGLFormat QGLWindowSurface::surfaceFormat;
+QGLWindowSurface::SwapMode QGLWindowSurface::swapBehavior = QGLWindowSurface::AutomaticSwap;
void QGLWindowSurfaceGLPaintDevice::endPaint()
{
@@ -549,9 +550,10 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
// did_paint is set to true in ::beginPaint. ::beginPaint means that we
// at least cleared the background (= painted something). In EGL API it's a
- // mistakte to call swapBuffers if nothing was painted. This check protects
- // the flush func from being executed if it's for nothing.
- if (!d_ptr->did_paint)
+ // mistake to call swapBuffers if nothing was painted unless
+ // EGL_BUFFER_PRESERVED is set. This check protects the flush func from
+ // being executed if it's for nothing.
+ if (!hasPartialUpdateSupport() && !d_ptr->did_paint)
return;
QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
@@ -576,6 +578,9 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
const GLenum target = GL_TEXTURE_2D;
Q_UNUSED(target);
+ if (QGLWindowSurface::swapBehavior == QGLWindowSurface::KillSwap)
+ return;
+
if (context()) {
context()->makeCurrent();
@@ -623,7 +628,14 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
}
}
#endif
- bool doingPartialUpdate = hasPartialUpdateSupport() && br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2;
+ bool doingPartialUpdate = false;
+ if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AutomaticSwap)
+ doingPartialUpdate = hasPartialUpdateSupport() && br.width() * br.height() < parent->geometry().width() * parent->geometry().height() * 0.2;
+ else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysFullSwap)
+ doingPartialUpdate = false;
+ else if (QGLWindowSurface::swapBehavior == QGLWindowSurface::AlwaysPartialSwap)
+ doingPartialUpdate = hasPartialUpdateSupport();
+
QGLContext *ctx = reinterpret_cast<QGLContext *>(parent->d_func()->extraData()->glContext);
if (widget != window()) {
if (initializeOffscreenTexture(window()->size()))
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
index 22bd5f0..09a6a30 100644
--- a/src/opengl/qwindowsurface_gl_p.h
+++ b/src/opengl/qwindowsurface_gl_p.h
@@ -112,6 +112,9 @@ public:
static QGLFormat surfaceFormat;
+ enum SwapMode { AutomaticSwap, AlwaysFullSwap, AlwaysPartialSwap, KillSwap };
+ static SwapMode swapBehavior;
+
private slots:
void deleted(QObject *object);