本页内容

QOpenGLVertexArrayObject::Binder Class

class QOpenGLVertexArrayObject::Binder

QOpenGLVertexArrayObject::Binder 类是一个便利类,用于辅助 OpenGL 顶点数组对象的绑定和释放。更多内容...

注意:该类中的所有函数均为可重入函数。

公共函数

Binder(QOpenGLVertexArrayObject *v)
~Binder()
void rebind()
void release()

详细说明

QOpenGLVertexArrayObject::Binder 是一个简单的便利类,可用于辅助绑定和释放QOpenGLVertexArrayObject 实例。该类之于QOpenGLVertexArrayObject ,正如QMutexLocker 之于QMutex 。

该类实现了RAII原则,有助于确保在复杂代码中或出现异常时的行为一致性。

该类的构造函数接受一个QOpenGLVertexArrayObject (VAO)作为参数,并尝试绑定该VAO,必要时会调用QOpenGLVertexArrayObject::create()。该类的析构函数会调用QOpenGLVertexArrayObject::release(),从而解除对VAO的绑定。

如有需要,可通过release()函数暂时解除VAO的绑定,并使用rebind()将其重新绑定。

另请参阅 QOpenGLVertexArrayObject 。

成员函数文档

Binder::Binder(QOpenGLVertexArrayObject *v)

通过调用QOpenGLVertexArrayObject::bind(),创建一个QOpenGLVertexArrayObject::Binder 对象,并将v 绑定到该对象上。如有必要,会先调用QOpenGLVertexArrayObject::create()。

[noexcept] Binder::~Binder()

销毁QOpenGLVertexArrayObject::Binder ,并释放相关的顶点数组对象。

void Binder::rebind()

可用于重新绑定关联的顶点数组对象。

另请参阅 release()。

void Binder::release()

可用于临时释放关联的顶点数组对象。

另请参阅 rebind()。

© 2026 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.