I'm trying to create a class for an "Entity" in Vulkan (An entity is a graphical object that can be rendered in a Window);
This class will contain the corresponding Vertex Buffer, along with the descriptor set layout, descriptor pool, descriptor sets and so on, the problem is how to manage the uniform buffers, because I'd like something like this:
class Entity final {
public:
enum class Uniform_Type : char {
MODEL_MATRIX, VIEW_MATRIX, PROJECTION_MATRIX, AMBIENT_VECTOR, DIFFUSE_VECTOR,
SPECULAR_VECTOR, SHININESS_FLOAT, LIGHT_AMBIENT_VECTOR, LIGHT_DIFFUSE_VECTOR,
LIGHT_SPECULAR_VECTOR, IS_LIGHT_SOURCE_BOOLEAN, LIGHT_POSITION_VECTOR,
VIEW_POSITION_VECTOR
};
// Private fields
std::unordered_map<Uniform_Type, std::pair<WHAT_HERE, std::vector<Uniform_Buffer>>> uniformsMap;
};
so if my class only needs the model, view and projection matrix, I'll do something like this (First element of the std::pair will hold the corresponding object (A matrix in this case), the second one is a vector of Uniform Buffers so they can be as much as the number of images in the swapchain):
uniformsMap[MODEL_MATRIX] = { glm::mat4(1.0f), std::vector<Uniform_Buffer>() };
uniformsMap[VIEW_MATRIX] = { glm::mat4(1.0f), std::vector<Uniform_Buffer>() };
uniformsMap[PROJECTION_MATRIX] = { glm::mat4(1.0f), std::vector<Uniform_Buffer>() };
The problem is that there are various kind of Uniform Buffers (matrix, vector, float, bool, etc...) so I'm stuck on what to write as the first element of the std::pair object.
Thanks for your time.