summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qsurfaceformat.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2013-02-08 08:11:55 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-08 20:00:00 +0100
commitbfa1584162960a76170f941d490014f070e4a676 (patch)
tree1d2872fc25ad7736ec108f4c1c4440133ac8658e /src/gui/kernel/qsurfaceformat.cpp
parentefbecc1a94250e6fc55b3c31bab18819d2a07ccf (diff)
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 <sean.harmer@kdab.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/gui/kernel/qsurfaceformat.cpp')
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp24
1 files changed, 24 insertions, 0 deletions
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
@@ -584,6 +584,30 @@ int QSurfaceFormat::minorVersion() const
}
/*!
+ Returns a QPair<int, int> representing the OpenGL version.
+
+ Useful for version checks, for example format.version() >= qMakePair(3, 2)
+*/
+QPair<int, int> 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.