From 8adca56674bd51a39b278fb08f270624c825b002 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 19 Mar 2014 12:52:03 +0100 Subject: Resurrect advanced bindTexture() features in QtOpenGL During the Qt 4 -> 5 migration the setting of the extension flags in QOpenGLFunctions/Extensions suffered a regression: flags like GenerateMipmap were never set. This led to the unfortunate sitation that features that were tied to these flags, like compressed texture support or mipmap generation, got disabled. This is now corrected by checking for the extensions like Qt 4 did. Task-number: QTBUG-37588 Change-Id: I4a7beb1b435af11e05f5304aa04df2ec63b34c18 Reviewed-by: Gunnar Sletta --- tests/auto/opengl/qgl/tst_qgl.cpp | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 718b5263bf..22f284e365 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #endif class tst_QGL : public QObject @@ -99,6 +100,7 @@ private slots: void threadImages(); void nullRectCrash(); void graphicsViewClipping(); + void extensions(); }; tst_QGL::tst_QGL() @@ -2361,5 +2363,43 @@ void tst_QGL::nullRectCrash() fboPainter.end(); } +void tst_QGL::extensions() +{ + QGLWidget glw; + glw.makeCurrent(); + + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QVERIFY(ctx); + QOpenGLFunctions *funcs = ctx->functions(); + QVERIFY(funcs); + QSurfaceFormat format = ctx->format(); + +#ifdef QT_BUILD_INTERNAL + QOpenGLExtensions *exts = static_cast(funcs); + QOpenGLExtensions::OpenGLExtensions allExts = exts->openGLExtensions(); + // Mipmapping is always available in GL2/GLES2+. Verify this. + if (format.majorVersion() >= 2) + QVERIFY(allExts.testFlag(QOpenGLExtensions::GenerateMipmap)); +#endif + + // Now look for some features should always be available in a given version. + QOpenGLFunctions::OpenGLFeatures allFeatures = funcs->openGLFeatures(); + QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Multitexture)); + if (format.majorVersion() >= 2) { + QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Shaders)); + QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Buffers)); + QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Multisample)); + QVERIFY(!ctx->isES() || allFeatures.testFlag(QOpenGLFunctions::Framebuffers)); + QVERIFY(allFeatures.testFlag(QOpenGLFunctions::NPOTTextures) + && allFeatures.testFlag(QOpenGLFunctions::NPOTTextureRepeat)); + if (ctx->isES()) { + QVERIFY(!allFeatures.testFlag(QOpenGLFunctions::FixedFunctionPipeline)); + QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Framebuffers)); + } + } + if (format.majorVersion() >= 3) + QVERIFY(allFeatures.testFlag(QOpenGLFunctions::Framebuffers)); +} + QTEST_MAIN(tst_QGL) #include "tst_qgl.moc" -- cgit v1.2.3