Add RenderEngineSDK
This commit is contained in:
@@ -1,7 +1,47 @@
|
||||
#include "ModelManager.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "Log/Log.hpp"
|
||||
|
||||
ModelManager::StaticModel::StaticModel(const std::vector<Vertex>& vertices, const std::vector<uint32_t>& indices,
|
||||
VkPhysicalDevice physical_device, VkDevice device):
|
||||
physical_device_(physical_device),
|
||||
device_(device)
|
||||
{
|
||||
}
|
||||
|
||||
ModelManager::StaticModel::~StaticModel()
|
||||
{
|
||||
}
|
||||
|
||||
VkVertexInputBindingDescription ModelManager::Vertex::get_binding_description()
|
||||
{
|
||||
VkVertexInputBindingDescription description;
|
||||
description.binding = 0;
|
||||
description.stride = sizeof(Vertex);
|
||||
description.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
return description;
|
||||
}
|
||||
|
||||
std::array<VkVertexInputAttributeDescription, 2> ModelManager::Vertex::get_vertex_attribute_descriptions()
|
||||
{
|
||||
std::array<VkVertexInputAttributeDescription, 2> descriptions;
|
||||
// Bind vertex loc
|
||||
descriptions[0].binding = 0;
|
||||
descriptions[0].location = 0;
|
||||
descriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT;
|
||||
descriptions[0].offset = offsetof(Vertex, pos);
|
||||
|
||||
// Bind color
|
||||
descriptions[1].binding = 0;
|
||||
descriptions[1].location = 1;
|
||||
descriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT;
|
||||
descriptions[1].offset = offsetof(Vertex, color);
|
||||
|
||||
return descriptions;
|
||||
}
|
||||
|
||||
ModelManager::owner_counter::owner_counter(const owner_counter& other) : counter(other.counter.load()), model(other.model)
|
||||
{
|
||||
}
|
||||
@@ -19,6 +59,11 @@ unsigned int ModelManager::FNV1aHash(const char* buf)
|
||||
return h_val;
|
||||
}
|
||||
|
||||
ModelManager::ModelManager(VkPhysicalDevice physical_device, VkDevice device):
|
||||
physical_device_(physical_device),
|
||||
device_(device)
|
||||
{}
|
||||
|
||||
ModelManager::~ModelManager()
|
||||
{
|
||||
models.clear();
|
||||
@@ -37,11 +82,14 @@ ModelManager::StaticModel* ModelManager::LoadModel(const std::string& name)
|
||||
}
|
||||
|
||||
Loging::Log("Load new model: " + name);
|
||||
|
||||
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<uint32_t> indices;
|
||||
// Load model_data
|
||||
|
||||
owner_counter new_counter;
|
||||
new_counter.counter.store(1);
|
||||
new_counter.model = new StaticModel();
|
||||
new_counter.model = new StaticModel(vertices, indices, physical_device_, device_);
|
||||
models.try_emplace(hash, new_counter);
|
||||
return new_counter.model;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user