Muto 0.0.1
Cross-Platform Application Template
GitHub Repo | Muto Updates | Muto's Author
Loading...
Searching...
No Matches
Muto::BufferElement Struct Reference

Represents a single element in a buffer layout. More...

#include <Buffer.h>

Public Member Functions

 BufferElement ()
 
 BufferElement (ShaderDataType type, const std::string &name, bool normalized=false)
 Constructs a BufferElement with the given type, name, and normalization flag.
 
uint32_t GetComponentCount () const
 Returns the number of components in the buffer element based on its ShaderDataType.
 

Public Attributes

std::string Name
 The name of the buffer element.
 
bool Normalized
 Whether the buffer element is normalized.
 
uint32_t Offset
 The offset in bytes of the buffer element from the start of the buffer.
 
uint32_t Size
 The size in bytes of the buffer element.
 
ShaderDataType Type
 The data type of the buffer element.
 

Detailed Description

Represents a single element in a buffer layout.

Constructor & Destructor Documentation

◆ BufferElement() [1/2]

Muto::BufferElement::BufferElement ( )
inline
54{}

◆ BufferElement() [2/2]

Muto::BufferElement::BufferElement ( ShaderDataType  type,
const std::string &  name,
bool  normalized = false 
)
inline

Constructs a BufferElement with the given type, name, and normalization flag.

Parameters
typeThe ShaderDataType of the buffer element.
nameThe name of the buffer element.
normalizedWhether the buffer element is normalized.
61 : Name(name), Type(type), Size(ShaderDataTypeSize(type)), Offset(0), Normalized(normalized)
62 {
63 }
static uint32_t ShaderDataTypeSize(ShaderDataType type)
Returns the size in bytes of the given ShaderDataType.
Definition Buffer.h:22
std::string Name
The name of the buffer element.
Definition Buffer.h:44
bool Normalized
Whether the buffer element is normalized.
Definition Buffer.h:52
uint32_t Size
The size in bytes of the buffer element.
Definition Buffer.h:48
ShaderDataType Type
The data type of the buffer element.
Definition Buffer.h:46
uint32_t Offset
The offset in bytes of the buffer element from the start of the buffer.
Definition Buffer.h:50

References Name, Normalized, Offset, Muto::ShaderDataTypeSize(), Size, and Type.

Member Function Documentation

◆ GetComponentCount()

uint32_t Muto::BufferElement::GetComponentCount ( ) const
inline

Returns the number of components in the buffer element based on its ShaderDataType.

66 {
67 switch (Type) {
68 case ShaderDataType::SDT_Float: return 1;
69 case ShaderDataType::SDT_Float2: return 2;
70 case ShaderDataType::SDT_Float3: return 3;
71 case ShaderDataType::SDT_Float4: return 4;
72 case ShaderDataType::SDT_Mat3: return 3 * 3;
73 case ShaderDataType::SDT_Mat4: return 4 * 4;
74 case ShaderDataType::SDT_Int: return 1;
75 case ShaderDataType::SDT_Int2: return 2;
76 case ShaderDataType::SDT_Int3: return 3;
77 case ShaderDataType::SDT_Int4: return 4;
78 case ShaderDataType::SDT_Bool: return 1;
79 }
80 MU_CORE_ASSERT(false, "Unknown ShaderDataType!");
81 return 0;
82 }
#define MU_CORE_ASSERT(x,...)
Definition Asserts.h:32

References Muto::SDT_Bool, Muto::SDT_Float, Muto::SDT_Float2, Muto::SDT_Float3, Muto::SDT_Float4, Muto::SDT_Int, Muto::SDT_Int2, Muto::SDT_Int3, Muto::SDT_Int4, Muto::SDT_Mat3, Muto::SDT_Mat4, and Type.

Member Data Documentation

◆ Name

std::string Muto::BufferElement::Name

The name of the buffer element.

Referenced by BufferElement().

◆ Normalized

bool Muto::BufferElement::Normalized

Whether the buffer element is normalized.

Referenced by BufferElement().

◆ Offset

uint32_t Muto::BufferElement::Offset

The offset in bytes of the buffer element from the start of the buffer.

Referenced by BufferElement().

◆ Size

uint32_t Muto::BufferElement::Size

The size in bytes of the buffer element.

Referenced by BufferElement().

◆ Type

ShaderDataType Muto::BufferElement::Type

The data type of the buffer element.

Referenced by BufferElement(), and GetComponentCount().


The documentation for this struct was generated from the following file: