summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-03-19 12:52:03 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-20 14:11:33 +0100
commit8adca56674bd51a39b278fb08f270624c825b002 (patch)
tree02d234e612ef1a74758566eb9c403e45c25664ad
parent33cac84df30770de2a2c27d4b1288a658db1b638 (diff)
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 <gunnar.sletta@jollamobile.com>
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp45
-rw-r--r--tests/auto/opengl/qgl/tst_qgl.cpp40
2 files changed, 82 insertions, 3 deletions
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index fe6eb4c098..d52b1a314f 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -359,10 +359,37 @@ static int qt_gl_resolve_extensions()
{
int extensions = 0;
QOpenGLExtensionMatcher extensionMatcher;
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ QSurfaceFormat format = ctx->format();
+
if (extensionMatcher.match("GL_EXT_bgra"))
extensions |= QOpenGLExtensions::BGRATextureFormat;
-
- if (QOpenGLContext::currentContext()->isES()) {
+ if (extensionMatcher.match("GL_ARB_texture_rectangle"))
+ extensions |= QOpenGLExtensions::TextureRectangle;
+ if (extensionMatcher.match("GL_SGIS_generate_mipmap"))
+ extensions |= QOpenGLExtensions::GenerateMipmap;
+ if (extensionMatcher.match("GL_ARB_texture_compression"))
+ extensions |= QOpenGLExtensions::TextureCompression;
+ if (extensionMatcher.match("GL_EXT_texture_compression_s3tc"))
+ extensions |= QOpenGLExtensions::DDSTextureCompression;
+ if (extensionMatcher.match("GL_OES_compressed_ETC1_RGB8_texture"))
+ extensions |= QOpenGLExtensions::ETC1TextureCompression;
+ if (extensionMatcher.match("GL_IMG_texture_compression_pvrtc"))
+ extensions |= QOpenGLExtensions::PVRTCTextureCompression;
+ if (extensionMatcher.match("GL_ARB_texture_mirrored_repeat"))
+ extensions |= QOpenGLExtensions::MirroredRepeat;
+ if (extensionMatcher.match("GL_EXT_stencil_two_side"))
+ extensions |= QOpenGLExtensions::StencilTwoSide;
+ if (extensionMatcher.match("GL_EXT_stencil_wrap"))
+ extensions |= QOpenGLExtensions::StencilWrap;
+ if (extensionMatcher.match("GL_NV_float_buffer"))
+ extensions |= QOpenGLExtensions::NVFloatBuffer;
+ if (extensionMatcher.match("GL_ARB_pixel_buffer_object"))
+ extensions |= QOpenGLExtensions::PixelBufferObject;
+
+ if (ctx->isES()) {
+ if (format.majorVersion() >= 2)
+ extensions |= QOpenGLExtensions::GenerateMipmap;
if (extensionMatcher.match("GL_OES_mapbuffer"))
extensions |= QOpenGLExtensions::MapBuffer;
if (extensionMatcher.match("GL_OES_packed_depth_stencil"))
@@ -375,7 +402,6 @@ static int qt_gl_resolve_extensions()
if (extensionMatcher.match("GL_IMG_texture_format_BGRA8888") || extensionMatcher.match("GL_EXT_texture_format_BGRA8888"))
extensions |= QOpenGLExtensions::BGRATextureFormat;
} else {
- QSurfaceFormat format = QOpenGLContext::currentContext()->format();
extensions |= QOpenGLExtensions::ElementIndexUint | QOpenGLExtensions::MapBuffer;
// Recognize features by extension name.
@@ -394,6 +420,19 @@ static int qt_gl_resolve_extensions()
extensions |= QOpenGLExtensions::PackedDepthStencil;
}
}
+
+ if (format.renderableType() == QSurfaceFormat::OpenGL && format.version() >= qMakePair(3, 2))
+ extensions |= QOpenGLExtensions::GeometryShaders;
+
+#ifndef QT_OPENGL_ES
+ if (extensionMatcher.match("GL_EXT_framebuffer_sRGB")) {
+ GLboolean srgbCapableFramebuffers = false;
+ ctx->functions()->glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgbCapableFramebuffers);
+ if (srgbCapableFramebuffers)
+ extensions |= QOpenGLExtensions::SRGBFrameBuffer;
+ }
+#endif
+
return extensions;
}
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 <QtOpenGL/private/qgl_p.h>
#include <QtGui/private/qimage_p.h>
#include <QtGui/private/qimagepixmapcleanuphooks_p.h>
+#include <QtGui/private/qopenglextensions_p.h>
#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<QOpenGLExtensions *>(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"