mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
big refactoring ! ci skip
This commit is contained in:
31
runtime/Sources/Graphics/Mesh.cpp
git.filemode.normal_file
31
runtime/Sources/Graphics/Mesh.cpp
git.filemode.normal_file
@@ -0,0 +1,31 @@
|
||||
#include <PreCompiled.h>
|
||||
#include <Graphics/Mesh.h>
|
||||
#include <Utils/Buffer.h>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
void Mesh::Draw(VkCommandBuffer cmd, std::size_t& drawcalls, std::size_t& polygondrawn) const noexcept
|
||||
{
|
||||
for(std::size_t i = 0; i < m_sub_meshes.size(); i++)
|
||||
Draw(cmd, drawcalls, polygondrawn, i);
|
||||
}
|
||||
|
||||
void Mesh::Draw(VkCommandBuffer cmd, std::size_t& drawcalls, std::size_t& polygondrawn, std::size_t submesh_index) const noexcept
|
||||
{
|
||||
Verify(submesh_index < m_sub_meshes.size(), "invalid submesh index");
|
||||
m_sub_meshes[submesh_index].vbo.Bind(cmd);
|
||||
m_sub_meshes[submesh_index].ibo.Bind(cmd);
|
||||
vkCmdDrawIndexed(cmd, static_cast<std::uint32_t>(m_sub_meshes[submesh_index].ibo.GetSize() / sizeof(std::uint32_t)), 1, 0, 0, 0);
|
||||
polygondrawn += m_sub_meshes[submesh_index].triangle_count;
|
||||
drawcalls++;
|
||||
}
|
||||
|
||||
Mesh::~Mesh()
|
||||
{
|
||||
for(auto& mesh : m_sub_meshes)
|
||||
{
|
||||
mesh.vbo.Destroy();
|
||||
mesh.ibo.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user