Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:27:23

0001 // Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Sean Harmer <sean.harmer@kdab.com>
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QOPENGLVERTEXARRAYOBJECT_H
0005 #define QOPENGLVERTEXARRAYOBJECT_H
0006 
0007 #include <QtOpenGL/qtopenglglobal.h>
0008 
0009 #ifndef QT_NO_OPENGL
0010 
0011 #include <QtCore/QObject>
0012 #include <QtGui/qopengl.h>
0013 
0014 QT_BEGIN_NAMESPACE
0015 
0016 class QOpenGLVertexArrayObjectPrivate;
0017 
0018 class Q_OPENGL_EXPORT QOpenGLVertexArrayObject : public QObject
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     explicit QOpenGLVertexArrayObject(QObject* parent = nullptr);
0024     ~QOpenGLVertexArrayObject();
0025 
0026     bool create();
0027     void destroy();
0028     bool isCreated() const;
0029     GLuint objectId() const;
0030     void bind();
0031     void release();
0032 
0033     class Binder
0034     {
0035     public:
0036         inline Binder(QOpenGLVertexArrayObject *v)
0037             : vao(v)
0038         {
0039             Q_ASSERT(v);
0040             if (vao->isCreated() || vao->create())
0041                 vao->bind();
0042         }
0043 
0044         inline ~Binder()
0045         {
0046             release();
0047         }
0048 
0049         inline void release()
0050         {
0051             vao->release();
0052         }
0053 
0054         inline void rebind()
0055         {
0056             vao->bind();
0057         }
0058 
0059     private:
0060         Q_DISABLE_COPY(Binder)
0061         QOpenGLVertexArrayObject *vao;
0062     };
0063 
0064 private:
0065     Q_DISABLE_COPY(QOpenGLVertexArrayObject)
0066     Q_DECLARE_PRIVATE(QOpenGLVertexArrayObject)
0067     Q_PRIVATE_SLOT(d_func(), void _q_contextAboutToBeDestroyed())
0068     QOpenGLVertexArrayObject(QOpenGLVertexArrayObjectPrivate &dd);
0069 };
0070 
0071 QT_END_NAMESPACE
0072 
0073 #endif
0074 
0075 #endif // QOPENGLVERTEXARRAYOBJECT_H