1// Copyright (C) 2014 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_GLBUFFER_P_H
5#define QT3DRENDER_RENDER_OPENGL_GLBUFFER_P_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 <QOpenGLContext>
19#include <Qt3DCore/qnodeid.h>
20#include <qbytearray.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace Qt3DRender {
25
26namespace Render {
27
28namespace OpenGL {
29
30class GraphicsContext;
31
32class GLBuffer
33{
34public:
35 GLBuffer();
36
37 enum Type
38 {
39 ArrayBuffer = 0,
40 UniformBuffer,
41 IndexBuffer,
42 ShaderStorageBuffer,
43 PixelPackBuffer,
44 PixelUnpackBuffer,
45 DrawIndirectBuffer
46 };
47
48 bool bind(GraphicsContext *ctx, Type t);
49 bool release(GraphicsContext *ctx);
50 bool create(GraphicsContext *ctx);
51 void destroy(GraphicsContext *ctx);
52 void allocate(GraphicsContext *ctx, uint size, bool dynamic = true);
53 void allocate(GraphicsContext *ctx, const void *data, uint size, bool dynamic = true);
54 void update(GraphicsContext *ctx, const void *data, uint size, int offset = 0);
55 QByteArray download(GraphicsContext *ctx, uint size);
56 void bindBufferBase(GraphicsContext *ctx, int bindingPoint, Type t);
57 void bindBufferBase(GraphicsContext *ctx, int bindingPoint);
58
59 inline GLuint bufferId() const { return m_bufferId; }
60 inline bool isCreated() const { return m_isCreated; }
61 inline bool isBound() const { return m_bound; }
62
63private:
64 GLuint m_bufferId;
65 bool m_isCreated;
66 bool m_bound;
67 GLenum m_lastTarget;
68};
69
70} // namespace OpenGL
71
72} // namespace Render
73
74} // namespace Qt3DRender
75
76QT_END_NAMESPACE
77
78#endif // QT3DRENDER_RENDER_OPENGL_GLBUFFER_P_H
79

source code of qt3d/src/plugins/renderers/opengl/io/glbuffer_p.h