1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QOPENGLVERSIONPROFILE_H
5#define QOPENGLVERSIONPROFILE_H
6
7#include <QtOpenGL/qtopenglglobal.h>
8
9#include <QtGui/QSurfaceFormat>
10
11#include <QtCore/QPair>
12#include <QtCore/qhashfunctions.h>
13
14QT_BEGIN_NAMESPACE
15
16class QOpenGLVersionProfilePrivate;
17class QDebug;
18
19class Q_OPENGL_EXPORT QOpenGLVersionProfile
20{
21public:
22 QOpenGLVersionProfile();
23 explicit QOpenGLVersionProfile(const QSurfaceFormat &format);
24 QOpenGLVersionProfile(const QOpenGLVersionProfile &other);
25 ~QOpenGLVersionProfile();
26
27 QOpenGLVersionProfile &operator=(const QOpenGLVersionProfile &rhs);
28
29 QPair<int, int> version() const;
30 void setVersion(int majorVersion, int minorVersion);
31
32 QSurfaceFormat::OpenGLContextProfile profile() const;
33 void setProfile(QSurfaceFormat::OpenGLContextProfile profile);
34
35 bool hasProfiles() const;
36 bool isLegacyVersion() const;
37 bool isValid() const;
38
39private:
40 QOpenGLVersionProfilePrivate* d;
41
42 friend bool operator==(const QOpenGLVersionProfile &lhs, const QOpenGLVersionProfile &rhs) noexcept
43 {
44 if (lhs.profile() != rhs.profile())
45 return false;
46 return lhs.version() == rhs.version();
47 }
48
49 friend bool operator!=(const QOpenGLVersionProfile &lhs, const QOpenGLVersionProfile &rhs) noexcept
50 {
51 return !operator==(lhs, rhs);
52 }
53};
54
55inline size_t qHash(const QOpenGLVersionProfile &v, size_t seed = 0) noexcept
56{
57 return qHash(key: static_cast<int>(v.profile() * 1000)
58 + v.version().first * 100 + v.version().second * 10, seed);
59}
60
61
62#ifndef QT_NO_DEBUG_STREAM
63Q_OPENGL_EXPORT QDebug operator<<(QDebug debug, const QOpenGLVersionProfile &vp);
64#endif // !QT_NO_DEBUG_STREAM
65
66QT_END_NAMESPACE
67
68#endif // QOPENGLVERSIONPROFILE_H
69

source code of qtbase/src/opengl/qopenglversionprofile.h