1 #include <vulkan/vulkan.h>
8 MeshVK::MeshVK(const MeshVK &mesh)
10 indices = mesh.indices;
11 vertices = mesh.vertices;
12 normals = mesh.normals;
13 tex_coords = mesh.tex_coords;
16 MeshVK &MeshVK::operator=(const MeshVK &mesh)
21 /* what the copy constructor does */
22 indices = mesh.indices;
23 vertices = mesh.vertices;
24 normals = mesh.normals;
25 tex_coords = mesh.tex_coords;
32 vku_destroy_buffer(vk_vertices);
33 vku_destroy_buffer(vk_normals);
34 vku_destroy_buffer(vk_tex_coords);
35 vku_destroy_buffer(vk_indices);
43 bool MeshVK::update_vertex_data()
45 if(vertices.empty()) {
46 printf("empty vertices!\n");
50 /* create the buffers */
52 if(!(vk_vertices = vku_create_buffer(vertices.size() * sizeof(Vec3),
53 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) {
54 fprintf(stderr, "Failed to create the buffer for the vertices.\n");
58 if(!(vk_normals = vku_create_buffer(normals.size() * sizeof(Vec3),
59 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) {
60 fprintf(stderr, "Failed to create the buffer for the normals.\n");
64 if(!(vk_tex_coords = vku_create_buffer(tex_coords.size() * sizeof(Vec2),
65 VK_BUFFER_USAGE_VERTEX_BUFFER_BIT))) {
67 "Failed to create the buffer for the texture coordinates.\n");
71 if(!(vk_indices = vku_create_buffer(indices.size() * 2,
72 VK_BUFFER_USAGE_INDEX_BUFFER_BIT))) {
73 fprintf(stderr, "Failed to create the indices buffer.\n");
83 void MeshVK::draw() const
87 void MeshVK::draw_normals(float scale) const