| 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/qhashfunctions.h> |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | class QOpenGLVersionProfilePrivate; |
| 16 | class QDebug; |
| 17 | |
| 18 | class Q_OPENGL_EXPORT QOpenGLVersionProfile |
| 19 | { |
| 20 | public: |
| 21 | QOpenGLVersionProfile(); |
| 22 | explicit QOpenGLVersionProfile(const QSurfaceFormat &format); |
| 23 | QOpenGLVersionProfile(const QOpenGLVersionProfile &other); |
| 24 | ~QOpenGLVersionProfile(); |
| 25 | |
| 26 | QOpenGLVersionProfile &operator=(const QOpenGLVersionProfile &rhs); |
| 27 | |
| 28 | std::pair<int, int> version() const; |
| 29 | void setVersion(int majorVersion, int minorVersion); |
| 30 | |
| 31 | QSurfaceFormat::OpenGLContextProfile profile() const; |
| 32 | void setProfile(QSurfaceFormat::OpenGLContextProfile profile); |
| 33 | |
| 34 | bool hasProfiles() const; |
| 35 | bool isLegacyVersion() const; |
| 36 | bool isValid() const; |
| 37 | |
| 38 | private: |
| 39 | QOpenGLVersionProfilePrivate* d; |
| 40 | |
| 41 | friend bool operator==(const QOpenGLVersionProfile &lhs, const QOpenGLVersionProfile &rhs) noexcept |
| 42 | { |
| 43 | if (lhs.profile() != rhs.profile()) |
| 44 | return false; |
| 45 | return lhs.version() == rhs.version(); |
| 46 | } |
| 47 | |
| 48 | friend bool operator!=(const QOpenGLVersionProfile &lhs, const QOpenGLVersionProfile &rhs) noexcept |
| 49 | { |
| 50 | return !operator==(lhs, rhs); |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | inline size_t qHash(const QOpenGLVersionProfile &v, size_t seed = 0) noexcept |
| 55 | { |
| 56 | return qHash(key: static_cast<int>(v.profile() * 1000) |
| 57 | + v.version().first * 100 + v.version().second * 10, seed); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | #ifndef QT_NO_DEBUG_STREAM |
| 62 | Q_OPENGL_EXPORT QDebug operator<<(QDebug debug, const QOpenGLVersionProfile &vp); |
| 63 | #endif // !QT_NO_DEBUG_STREAM |
| 64 | |
| 65 | QT_END_NAMESPACE |
| 66 | |
| 67 | #endif // QOPENGLVERSIONPROFILE_H |
| 68 |
