From bfa1584162960a76170f941d490014f070e4a676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 8 Feb 2013 08:11:55 +0100 Subject: Added version() and setVersion() convenience API to QSurfaceFormat. This lets you write code like format.version() >= qMakePair(3, 2), and format.setVersion(4, 2) instead of format.setMajorVersion(4); format.setMinorVersion(2); Change-Id: Ib052091cc12865ea0d5db52e468ed6cd28f14840 Reviewed-by: Sean Harmer Reviewed-by: Gunnar Sletta --- src/gui/kernel/qsurfaceformat.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/gui/kernel/qsurfaceformat.cpp') diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index e7c93f4e48..6d42613727 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -583,6 +583,30 @@ int QSurfaceFormat::minorVersion() const return d->minor; } +/*! + Returns a QPair representing the OpenGL version. + + Useful for version checks, for example format.version() >= qMakePair(3, 2) +*/ +QPair QSurfaceFormat::version() const +{ + return qMakePair(d->major, d->minor); +} + +/*! + Sets the desired \a major and \a minor OpenGL versions. + + The default version is 2.0. +*/ +void QSurfaceFormat::setVersion(int major, int minor) +{ + if (d->minor != minor || d->major != major) { + detach(); + d->minor = minor; + d->major = major; + } +} + /*! Returns true if all the options of the two QSurfaceFormat objects \a a and \a b are equal. -- cgit v1.2.3