1// Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
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 QT3DRENDER_RENDER_OPENGL_OPENGLVERTEXARRAYOBJECT_H
5#define QT3DRENDER_RENDER_OPENGL_OPENGLVERTEXARRAYOBJECT_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QOpenGLVertexArrayObject>
19#include <submissioncontext_p.h>
20
21QT_BEGIN_NAMESPACE
22
23namespace Qt3DRender {
24namespace Render {
25
26class GeometryManager;
27
28typedef QPair<HGeometry, Qt3DCore::QNodeId> VAOIdentifier;
29
30namespace OpenGL {
31
32class GLShaderManager;
33
34class Q_AUTOTEST_EXPORT OpenGLVertexArrayObject
35{
36public:
37 OpenGLVertexArrayObject();
38
39 void bind();
40 void release();
41
42 void create(SubmissionContext *ctx, const VAOIdentifier &key);
43 VAOIdentifier key() const;
44 void destroy();
45 void cleanup();
46
47 bool isAbandoned(GeometryManager *geomMgr, GLShaderManager *shaderMgr);
48
49 QOpenGLVertexArrayObject *vao() { return m_vao.data(); }
50 const QOpenGLVertexArrayObject *vao() const { return m_vao.data(); }
51
52 void setSpecified(bool b) { m_specified = b; }
53 bool isSpecified() const { return m_specified; }
54
55
56private:
57 QMutex m_mutex;
58 SubmissionContext *m_ctx;
59 QScopedPointer<QOpenGLVertexArrayObject> m_vao;
60 bool m_specified;
61 bool m_supportsVao;
62 VAOIdentifier m_owners;
63
64 friend class SubmissionContext;
65
66 void saveVertexAttribute(const SubmissionContext::VAOVertexAttribute &attr);
67 inline void saveIndexAttribute(HGLBuffer glBufferHandle) { m_indexAttribute = glBufferHandle; }
68
69 std::vector<SubmissionContext::VAOVertexAttribute> m_vertexAttributes;
70 SubmissionContext::VAOIndexAttribute m_indexAttribute;
71};
72
73} // namespace OpenGL
74} // namespace Render
75} // namespace Qt3DRender
76
77QT_END_NAMESPACE
78
79#endif // QT3DRENDER_RENDER_OPENGL_OPENGLVERTEXARRAYOBJECT_H
80

source code of qt3d/src/plugins/renderers/opengl/renderer/openglvertexarrayobject_p.h