1// Copyright (C) 2015 Paul Lemire paul.lemire350@gmail.com
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_BUFFERUTILS_P_H
5#define QT3DRENDER_RENDER_BUFFERUTILS_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 <Qt3DCore/QAttribute>
19#include <QByteArray>
20#include <private/qglobal_p.h>
21
22QT_BEGIN_NAMESPACE
23
24
25namespace Qt3DRender {
26
27namespace Render {
28
29class GeometryRenderer;
30class NodeManagers;
31class Attribute;
32class Buffer;
33
34struct BufferInfo
35{
36 BufferInfo()
37 : type(Qt3DCore::QAttribute::VertexBaseType::Float)
38 , dataSize(0)
39 , count(0)
40 , byteStride(0)
41 , byteOffset(0)
42 , restartEnabled(false)
43 , restartIndexValue(-1)
44 {}
45
46 QByteArray data;
47 Qt3DCore::QAttribute::VertexBaseType type;
48 uint dataSize;
49 uint count;
50 uint byteStride;
51 uint byteOffset;
52 bool restartEnabled;
53 int restartIndexValue;
54};
55
56
57namespace BufferTypeInfo {
58
59 template <Qt3DCore::QAttribute::VertexBaseType> struct EnumToType;
60 template <> struct EnumToType<Qt3DCore::QAttribute::Byte> { typedef const char type; };
61 template <> struct EnumToType<Qt3DCore::QAttribute::UnsignedByte> { typedef const uchar type; };
62 template <> struct EnumToType<Qt3DCore::QAttribute::Short> { typedef const short type; };
63 template <> struct EnumToType<Qt3DCore::QAttribute::UnsignedShort> { typedef const ushort type; };
64 template <> struct EnumToType<Qt3DCore::QAttribute::Int> { typedef const int type; };
65 template <> struct EnumToType<Qt3DCore::QAttribute::UnsignedInt> { typedef const uint type; };
66 template <> struct EnumToType<Qt3DCore::QAttribute::Float> { typedef const float type; };
67 template <> struct EnumToType<Qt3DCore::QAttribute::Double> { typedef const double type; };
68
69 template<Qt3DCore::QAttribute::VertexBaseType v>
70 typename EnumToType<v>::type *castToType(const QByteArray &u, uint byteOffset)
71 {
72 return reinterpret_cast< typename EnumToType<v>::type *>(u.constData() + byteOffset);
73 }
74
75} // namespace BufferTypeInfo
76
77} // namespace Render
78
79} // namespace Qt3DRender
80
81QT_END_NAMESPACE
82
83
84#endif // QT3DRENDER_RENDER_BUFFERUTILS_P_H
85

source code of qt3d/src/render/backend/bufferutils_p.h