X-Git-Url: https://eleni.mutantstargoat.com/git/?p=demo;a=blobdiff_plain;f=src%2Fvulkan%2Fmesh-vk.cc;fp=src%2Fvulkan%2Fmesh-vk.cc;h=c1901995e266bc8d206d357a80d1040bbdabb95f;hp=2f0c5fb8db676d7b29b2fb3632117bd5ff26fae0;hb=d90ed8aef9e3547eee75ad793c352ee022d35050;hpb=855c42d8e50fff743fd7b1be5e91cb0db18def77 diff --git a/src/vulkan/mesh-vk.cc b/src/vulkan/mesh-vk.cc index 2f0c5fb..c190199 100644 --- a/src/vulkan/mesh-vk.cc +++ b/src/vulkan/mesh-vk.cc @@ -1,12 +1,16 @@ #include #include "mesh-vk.h" -MeshVK::MeshVK() {} +MeshVK::MeshVK() +{ +} + MeshVK::MeshVK(const MeshVK &mesh) { indices = mesh.indices; vertices = mesh.vertices; normals = mesh.normals; + tex_coords = mesh.tex_coords; } MeshVK &MeshVK::operator=(const MeshVK &mesh) @@ -18,25 +22,40 @@ MeshVK &MeshVK::operator=(const MeshVK &mesh) indices = mesh.indices; vertices = mesh.vertices; normals = mesh.normals; + tex_coords = mesh.tex_coords; return *this; } MeshVK::~MeshVK() { + vku_destroy_buffer(vk_vertices); + vku_destroy_buffer(vk_normals); + vku_destroy_buffer(vk_tex_coords); + vku_destroy_buffer(vk_indices); + vertices.clear(); normals.clear(); + tex_coords.clear(); + indices.clear(); } -void MeshVK::update_vertex_data() +bool MeshVK::update_vertex_data() { if(vertices.empty()) { printf("empty vertices!\n"); - return; + return false; + } + + /* create vertex buffer */ + + if(!(vk_vertices = vku_create_buffer(vertices.size() * sizeof(Vec3), + VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) { + fprintf(stderr, "Failed to create vertex buffer.\n"); + return false; } -// if(num_vertices != vertices.size()) { -// } + return true; } void MeshVK::draw() const