BartSiwek / Gris

Small graphics engine to try stuff out
MIT License
0 stars 0 forks source link

Make Vertex and Mesh composible from indvidual fields at compile time #57

Open BartSiwek opened 3 years ago

BartSiwek commented 3 years ago

Something like this:

namespace Gris::Graphics::VertexData
{

struct Position3
{
    glm::vec3 Position;
};

struct Position3
{
    glm::vec3 Position;
};

struct Color3
{
    glm::vec3 Color;
};

struct Color4
{
    glm::vec4 Color;
};

struct TextureCoords
{
    glm::vec2 TextureCoords;
};

}

namespace Gris::Graphics
{

template<typename... Fields>
struct Vertex : public Fields...
{
};

template<typename VertexT>
struct Mesh
{
    std::vector<VertexT> Vertices = {};
    std::vector<uint32_t> Indices = {};
    uint32_t BaseVertex = 0;
};

}  // namespace Gris::Graphics