light/modules/renderer/components.cppm

76 lines
1.2 KiB
Text
Raw Normal View History

export module renderer.components;
import assets.shader;
import math.vec3;
import memory.reference;
import std;
2025-10-26 16:43:56 +03:30
export namespace lt::renderer::components {
2025-10-26 16:43:56 +03:30
enum class VertexFormat : std::uint8_t
{
2025-10-26 16:43:56 +03:30
r32_g32_b32_sfloat,
r32_g32_sfloat,
};
enum class VertexInputRate : std::uint8_t
{
2025-10-26 16:43:56 +03:30
per_vertex,
per_instance,
};
struct VertexInputAttributeDescriptipn
2025-10-26 16:43:56 +03:30
{
std::uint32_t location;
2025-10-26 16:43:56 +03:30
std::uint32_t binding;
2025-10-26 16:43:56 +03:30
std::uint32_t offset;
2025-10-26 16:43:56 +03:30
VertexFormat format;
};
struct VertexInputBindingDescription
2025-10-26 16:43:56 +03:30
{
std::uint32_t binding;
2025-10-26 16:43:56 +03:30
std::uint32_t stride;
2025-10-26 16:43:56 +03:30
};
/** Requires a math::components::Transform component on the same entity to be functional. */
struct Sprite
2025-10-26 16:43:56 +03:30
{
struct Vertex
{
math::vec3 position;
math::vec3 color;
[[nodiscard]] constexpr static auto get_attributes()
-> std::array<VertexInputAttributeDescriptipn, 2>
{
return {
VertexInputAttributeDescriptipn {
.location = 0u,
.binding = 0u,
.offset = 0u,
2025-10-26 16:43:56 +03:30
.format = VertexFormat::r32_g32_b32_sfloat,
},
VertexInputAttributeDescriptipn {
.location = 1u,
.binding = 0u,
.offset = sizeof(math::vec3),
2025-10-26 16:43:56 +03:30
.format = VertexFormat::r32_g32_b32_sfloat,
},
};
}
};
math::vec3 color;
2025-10-26 16:43:56 +03:30
};
} // namespace lt::renderer::components