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 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | namespace Qt3DRender { |
24 | namespace Render { |
25 | |
26 | class GeometryManager; |
27 | |
28 | typedef QPair<HGeometry, Qt3DCore::QNodeId> VAOIdentifier; |
29 | |
30 | namespace OpenGL { |
31 | |
32 | class GLShaderManager; |
33 | |
34 | class Q_AUTOTEST_EXPORT OpenGLVertexArrayObject |
35 | { |
36 | public: |
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 | |
56 | private: |
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 | |
77 | QT_END_NAMESPACE |
78 | |
79 | #endif // QT3DRENDER_RENDER_OPENGL_OPENGLVERTEXARRAYOBJECT_H |
80 |