summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/lancelot
diff options
context:
space:
mode:
authorJulian Thijssen <Nimthora@gmail.com>2016-07-27 15:45:31 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-01-23 11:34:05 +0000
commit7dc88b68904c7f1b7e012bd65ccdcbf48cc6e2e0 (patch)
tree6de47b86b99200b999eddd8de0f07c2e86d8e027 /tests/auto/other/lancelot
parentda4b6c4774c0adf8dee5ee4a9a8d9d24967ede3c (diff)
Add support for OpenGL 3.2+ core profile contexts in QPainter
This change allows painting via QPainter onto a QOpenGLWindow, QOpenGLWidget or QOpenGLFramebufferObject when an core profile context is in use. This is important on macOS in particular, where compatibility profiles are not available, and so the only way to use modern OpenGL is via a core profile context. Added core profile compatible shaders with moder GLSL keywords. The paint engine binds a VAO and two VBOs from now on, whenever VAOs are supported. Note that this changes behavior also for OpenGL 2.x context that have VAO support via extensions. The Lancelot test suite gains support for core profile contexts. This can be triggered via -coreglbuffer in place of -glbuffer when manually inspecting via 'lance', while tst_lancelot will automatically run core context-based tests whenever supported. Task-number: QTBUG-33535 Change-Id: I6323a7ea2aaa9e111651ebbffd3e40259c8e7a9c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/other/lancelot')
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp2
-rw-r--r--tests/auto/other/lancelot/tst_lancelot.cpp53
2 files changed, 52 insertions, 3 deletions
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index 2e6cb09aa5..971b9b5fe7 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -2378,6 +2378,8 @@ void PaintCommands::command_surface_begin(QRegExp re)
#ifndef QT_NO_OPENGL
m_default_glcontext = QOpenGLContext::currentContext();
m_surface_glcontext = new QOpenGLContext();
+ // Pick up the format from the current context; this is especially
+ // important in order to pick the right version/profile to test.
m_surface_glcontext->setFormat(m_default_glcontext->format());
m_surface_glcontext->create();
m_surface_glcontext->makeCurrent(m_default_glcontext->surface());
diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp
index 972e5ca967..63c62bab86 100644
--- a/tests/auto/other/lancelot/tst_lancelot.cpp
+++ b/tests/auto/other/lancelot/tst_lancelot.cpp
@@ -53,7 +53,7 @@ private:
};
void setupTestSuite(const QStringList& blacklist = QStringList());
- void runTestSuite(GraphicsEngine engine, QImage::Format format);
+ void runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat = QSurfaceFormat());
void paint(QPaintDevice *device, GraphicsEngine engine, const QStringList &script, const QString &filePath);
QStringList qpsFiles;
@@ -85,8 +85,11 @@ private slots:
#ifndef QT_NO_OPENGL
void testOpenGL_data();
void testOpenGL();
+ void testCoreOpenGL_data();
+ void testCoreOpenGL();
private:
bool checkSystemGLSupport();
+ bool checkSystemCoreGLSupport();
#endif
};
@@ -236,6 +239,32 @@ bool tst_Lancelot::checkSystemGLSupport()
return true;
}
+bool tst_Lancelot::checkSystemCoreGLSupport()
+{
+ if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL)
+ return false;
+
+ QSurfaceFormat coreFormat;
+ coreFormat.setVersion(3, 2);
+ coreFormat.setProfile(QSurfaceFormat::CoreProfile);
+ QWindow win;
+ win.setSurfaceType(QSurface::OpenGLSurface);
+ win.setFormat(coreFormat);
+ win.create();
+ QOpenGLFramebufferObjectFormat fmt;
+ fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ fmt.setSamples(4);
+ QOpenGLContext ctx;
+ ctx.setFormat(coreFormat);
+ if (!ctx.create() || !ctx.makeCurrent(&win))
+ return false;
+ QOpenGLFramebufferObject fbo(800, 800, fmt);
+ if (!fbo.isValid() || !fbo.bind())
+ return false;
+
+ return true;
+}
+
void tst_Lancelot::testOpenGL_data()
{
if (!checkSystemGLSupport())
@@ -249,6 +278,22 @@ void tst_Lancelot::testOpenGL()
{
runTestSuite(OpenGL, QImage::Format_RGB32);
}
+
+void tst_Lancelot::testCoreOpenGL_data()
+{
+ if (!checkSystemCoreGLSupport())
+ QSKIP("System under test does not meet preconditions for Core Profile GL testing. Skipping.");
+ QStringList localBlacklist = QStringList() << QLatin1String("rasterops.qps");
+ setupTestSuite(localBlacklist);
+}
+
+void tst_Lancelot::testCoreOpenGL()
+{
+ QSurfaceFormat coreFormat;
+ coreFormat.setVersion(3, 2);
+ coreFormat.setProfile(QSurfaceFormat::CoreProfile);
+ runTestSuite(OpenGL, QImage::Format_RGB32, coreFormat);
+}
#endif
@@ -263,7 +308,7 @@ void tst_Lancelot::setupTestSuite(const QStringList& blacklist)
}
-void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format)
+void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat)
{
QFETCH(QString, qpsFile);
@@ -279,11 +324,13 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format)
} else if (engine == OpenGL) {
QWindow win;
win.setSurfaceType(QSurface::OpenGLSurface);
+ win.setFormat(contextFormat);
win.create();
QOpenGLFramebufferObjectFormat fmt;
fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
fmt.setSamples(4);
QOpenGLContext ctx;
+ ctx.setFormat(contextFormat);
QVERIFY(ctx.create());
QVERIFY(ctx.makeCurrent(&win));
QOpenGLFramebufferObject fbo(800, 800, fmt);
@@ -304,7 +351,7 @@ void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, const QStr
//pcmd.setShouldDrawText(false);
switch (engine) {
case OpenGL:
- pcmd.setType(OpenGLBufferType);
+ pcmd.setType(OpenGLBufferType); // version/profile is communicated through the context's format()
break;
case Raster: // fallthrough
default: