RAMSES Documentation  27.0.130
Information for RAMSES users and developers
EDataType.h
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // Copyright (C) 2017 BMW Car IT GmbH
3 // -------------------------------------------------------------------------
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 // -------------------------------------------------------------------------
8 
9 #ifndef RAMSES_EDATATYPE_H
10 #define RAMSES_EDATATYPE_H
11 #include <cstdint> // for integer datatypes
12 #include <stddef.h> // for size_t
13 
14 namespace ramses
15 {
19  enum class EDataType
20  {
21  UInt16 = 0,
22  UInt32,
23  Float,
24  Vector2F,
25  Vector3F,
26  Vector4F,
27  ByteBlob,
28  };
29 
36  constexpr size_t GetNumberOfComponents(EDataType dataType)
37  {
38  return (dataType == EDataType::UInt16) ? 1u :
39  (dataType == EDataType::UInt32) ? 1u :
40  (dataType == EDataType::Float) ? 1u :
41  (dataType == EDataType::Vector2F) ? 2u :
42  (dataType == EDataType::Vector3F) ? 3u :
43  (dataType == EDataType::Vector4F) ? 4u :
44  (dataType == EDataType::ByteBlob) ? 1u : 0u;
45  }
46 
55  constexpr size_t GetSizeOfComponent(EDataType dataType)
56  {
57  return (dataType == EDataType::Float) ? sizeof(float) :
58  (dataType == EDataType::UInt16) ? sizeof(uint16_t) :
59  (dataType == EDataType::UInt32) ? sizeof(uint32_t) :
60  (dataType == EDataType::Vector2F) ? sizeof(float) :
61  (dataType == EDataType::Vector3F) ? sizeof(float) :
62  (dataType == EDataType::Vector4F) ? sizeof(float) :
63  (dataType == EDataType::ByteBlob) ? 1u : 0u;
64  }
65 
72  constexpr size_t GetSizeOfDataType(EDataType dataType)
73  {
74  return GetNumberOfComponents(dataType) * GetSizeOfComponent(dataType);
75  }
76 }
77 
78 #endif
The RAMSES namespace contains all client side objects and functions used to implement RAMSES applicat...
Definition: AnimatedProperty.h:15
constexpr size_t GetSizeOfDataType(EDataType dataType)
Retrieve size of one element of specified data type in bytes.
Definition: EDataType.h:72
EDataType
Specifies the data type used for creating data buffers.
Definition: EDataType.h:20
@ Float
one component of type float per data element
@ Vector4F
four components of type float per data element
@ Vector2F
two components of type float per data element
@ UInt16
one component of type uint16_t per data element
@ ByteBlob
array of raw bytes which gets typed later (e.g. interleaved vertex buffer) where one element is alway...
@ UInt32
one component of type uint32_t per data element
@ Vector3F
three components of type float per data element
constexpr size_t GetSizeOfComponent(EDataType dataType)
Retrieve size of one component of specified data type in bytes.
Definition: EDataType.h:55
constexpr size_t GetNumberOfComponents(EDataType dataType)
Retrieve number of components per element of specified data type.
Definition: EDataType.h:36