This class defines the layout of a mesh's vertices.
More...
#include <candlewick/core/MeshLayout.h>
|
std::vector< SDL_GPUVertexBufferDescription > | m_bufferDescs |
|
std::vector< SDL_GPUVertexAttribute > | m_attrs |
|
This class defines the layout of a mesh's vertices.
This is used to build both rasterization pipeline and create Mesh objects. Due to its large size, we store these objects in centralized storage and hand out handles to them.
- See also
- Mesh
-
MeshData
◆ MeshLayout()
candlewick::MeshLayout::MeshLayout |
( |
| ) |
|
|
inline |
◆ addAttribute()
MeshLayout & candlewick::MeshLayout::addAttribute |
( |
VertexAttrib | loc, |
|
|
Uint32 | binding, |
|
|
SDL_GPUVertexElementFormat | format, |
|
|
Uint32 | offset ) |
|
inlineconstexpr |
Add a vertex attribute.
- Parameters
-
name | The vertex attribute name. |
loc | Location index in the vertex shader. |
binding | Binding slot of the corresponding vertex buffer. |
format | Format of the vertex attribute. |
offset | Byte offset of the attribute relative to the start of the vertex buffer element. |
◆ addBinding()
MeshLayout & candlewick::MeshLayout::addBinding |
( |
Uint32 | slot, |
|
|
Uint32 | pitch ) |
|
inline |
Add a binding (i.e. a vertex binding) for the mesh.
Calling this multiple times allows to describe a mesh layout where e.g. positions and normals are non-interleaved and should be uploaded to different vertex buffers.
- Parameters
-
slot | Index for vertex buffer |
size | Equivalent of pitch in SDL_gpu, size of consecutive elements of the vertex buffer, i.e. sizeof(Vertex) if your vertices are of some type Vertex. |
◆ getAttribute()
const SDL_GPUVertexAttribute * candlewick::MeshLayout::getAttribute |
( |
VertexAttrib | loc | ) |
const |
|
inlinenoexcept |
◆ indexSize()
Uint32 candlewick::MeshLayout::indexSize |
( |
| ) |
const |
|
inline |
Size of mesh indices (in bytes).
◆ numAttributes()
Uint32 candlewick::MeshLayout::numAttributes |
( |
| ) |
const |
|
inline |
Number of vertex attributes.
◆ numBuffers()
Uint32 candlewick::MeshLayout::numBuffers |
( |
| ) |
const |
|
inline |
Number of vertex buffers.
◆ operator SDL_GPUVertexInputState()
candlewick::MeshLayout::operator SDL_GPUVertexInputState |
( |
| ) |
const |
|
inlinenoexcept |
◆ operator==()
bool candlewick::MeshLayout::operator== |
( |
const MeshLayout & | other | ) |
const |
|
inlinenoexcept |
◆ toVertexInputState()
SDL_GPUVertexInputState candlewick::MeshLayout::toVertexInputState |
( |
| ) |
const |
|
inlinenoexcept |
Cast to the SDL_GPU vertex input state struct, used to create pipelines.
- Warning
- The data here only references data internal to MeshLayout and not copied. It must stay in scope until the pipeline is created.
◆ vertexSize()
Uint32 candlewick::MeshLayout::vertexSize |
( |
| ) |
const |
|
inline |
Total size of a vertex (in bytes).
- Todo
- Make this compatible with multiple vertex bindings.
◆ m_attrs
std::vector<SDL_GPUVertexAttribute> candlewick::MeshLayout::m_attrs |
◆ m_bufferDescs
std::vector<SDL_GPUVertexBufferDescription> candlewick::MeshLayout::m_bufferDescs |
The documentation for this class was generated from the following file: