QOpenGLVersionProfile Class
QOpenGLVersionProfile 类表示 OpenGL 上下文的版本和配置文件(如适用)。更多
Header: | #include <QOpenGLVersionProfile> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS OpenGL) target_link_libraries(mytarget PRIVATE Qt6::OpenGL) |
qmake: | QT += opengl |
公共函数
QOpenGLVersionProfile() | |
QOpenGLVersionProfile(const QSurfaceFormat &format) | |
QOpenGLVersionProfile(const QOpenGLVersionProfile &other) | |
~QOpenGLVersionProfile() | |
bool | hasProfiles() const |
bool | isLegacyVersion() const |
bool | isValid() const |
QSurfaceFormat::OpenGLContextProfile | profile() const |
void | setProfile(QSurfaceFormat::OpenGLContextProfile profile) |
void | setVersion(int majorVersion, int minorVersion) |
std::pair<int, int> | version() const |
QOpenGLVersionProfile & | operator=(const QOpenGLVersionProfile &rhs) |
详细说明
该类的对象可传递给 QOpenGLContext::versionFunctions(),以请求特定版本和 OpenGL 配置文件的函数对象。
它还包含一些辅助函数,用于检查某个版本是否支持配置文件或是否为旧版本。
成员函数文档
QOpenGLVersionProfile::QOpenGLVersionProfile()
创建默认的无效 QOpenGLVersionProfile 对象。
[explicit]
QOpenGLVersionProfile::QOpenGLVersionProfile(const QSurfaceFormat &format)
创建一个 QOpenGLVersionProfile 对象,初始化时使用format 中的版本和配置文件。
QOpenGLVersionProfile::QOpenGLVersionProfile(const QOpenGLVersionProfile &other)
构造other 的副本。
[noexcept]
QOpenGLVersionProfile::~QOpenGLVersionProfile()
销毁QOpenGLVersionProfile 对象。
bool QOpenGLVersionProfile::hasProfiles() const
如果version() 返回的 OpenGL 版本支持配置文件,则返回true
。只有 >= 3.2 的 OpenGL 版本支持配置文件。
bool QOpenGLVersionProfile::isLegacyVersion() const
如果version() 返回的 OpenGL 版本包含过时函数且不支持配置文件,即 OpenGL 版本 <= 3.1,则返回true
。
bool QOpenGLVersionProfile::isValid() const
如果版本号有效,则返回true
。请注意,对于默认构造的QOpenGLVersionProfile 对象,该函数将返回false
。
另请参阅 setVersion() 和version()。
QSurfaceFormat::OpenGLContextProfile QOpenGLVersionProfile::profile() const
返回 OpenGL 配置文件。只有当该版本支持配置文件时才有意义。
另请参见 setProfile()。
void QOpenGLVersionProfile::setProfile(QSurfaceFormat::OpenGLContextProfile profile)
设置 OpenGL 配置文件profile 。只有当该版本支持配置文件时才有意义。
另请参阅 profile() 。
void QOpenGLVersionProfile::setVersion(int majorVersion, int minorVersion)
将主版本号和次版本号分别设置为majorVersion 和minorVersion 。
另请参阅 version().
std::pair<int, int> QOpenGLVersionProfile::version() const
返回一个 std::pair<int,int>,其中的分量分别代表主要和次要 OpenGL 版本号。
另请参见 setVersion()。
QOpenGLVersionProfile &QOpenGLVersionProfile::operator=(const QOpenGLVersionProfile &rhs)
将rhs 的版本和配置文件分配给QOpenGLVersionProfile 对象。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.