diff options
Diffstat (limited to 'src/gui/opengl')
-rw-r--r-- | src/gui/opengl/qopenglframebufferobject.cpp | 21 | ||||
-rw-r--r-- | src/gui/opengl/qopenglfunctions.cpp | 12 | ||||
-rw-r--r-- | src/gui/opengl/qopenglfunctions.h | 3 |
3 files changed, 25 insertions, 11 deletions
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 90416db72b..247ecf7351 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1012,23 +1012,28 @@ QOpenGLFramebufferObjectFormat QOpenGLFramebufferObject::format() const Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) { - QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied - : QImage::Format_RGB32); int w = size.width(); int h = size.height(); + while (glGetError()); + +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied + : QImage::Format_RGB32); #ifdef QT_OPENGL_ES GLint fmt = GL_BGRA_EXT; #else GLint fmt = GL_BGRA; #endif - while (glGetError()); glReadPixels(0, 0, w, h, fmt, GL_UNSIGNED_BYTE, img.bits()); - if (glGetError()) { - glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); - img = img.rgbSwapped(); - } - return img.mirrored(); + if (!glGetError()) + return img.mirrored(); +#endif + + QImage rgbaImage(size, (alpha_format && include_alpha) ? QImage::Format_RGBA8888_Premultiplied + : QImage::Format_RGBX8888); + glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, rgbaImage.bits()); + return rgbaImage.mirrored(); } /*! diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 3737df7497..60591a34d2 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -141,8 +141,8 @@ QT_BEGIN_NAMESPACE /*! \enum QOpenGLFunctions::OpenGLFeature - This enum defines OpenGL/ES 2.0 features that may be optional - on other platforms. + This enum defines OpenGL and OpenGL ES features whose presence + may depend on the implementation. \value Multitexture glActiveTexture() function is available. \value Shaders Shader functions are available. @@ -158,6 +158,7 @@ QT_BEGIN_NAMESPACE \value StencilSeparate Separate stencil functions are available. \value NPOTTextures Non power of two textures are available. \value NPOTTextureRepeat Non power of two textures can use GL_REPEAT as wrap parameter. + \value FixedFunctionPipeline The fixed function pipeline is available. */ // Hidden private fields for additional extension data. @@ -331,6 +332,13 @@ static int qt_gl_resolve_features() if (format.majorVersion() >= 3) features |= QOpenGLFunctions::Framebuffers; + const QPair<int, int> version = format.version(); + if (version < qMakePair(3, 0) + || (version == qMakePair(3, 0) && format.testOption(QSurfaceFormat::DeprecatedFunctions)) + || (version == qMakePair(3, 1) && extensions.match("GL_ARB_compatibility")) + || (version >= qMakePair(3, 2) && format.profile() == QSurfaceFormat::CompatibilityProfile)) { + features |= QOpenGLFunctions::FixedFunctionPipeline; + } return features; #endif } diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h index 1548ad4a24..9d8da209ad 100644 --- a/src/gui/opengl/qopenglfunctions.h +++ b/src/gui/opengl/qopenglfunctions.h @@ -199,7 +199,8 @@ public: Multisample = 0x0400, StencilSeparate = 0x0800, NPOTTextures = 0x1000, - NPOTTextureRepeat = 0x2000 + NPOTTextureRepeat = 0x2000, + FixedFunctionPipeline = 0x4000 }; Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) |