-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.hpp
45 lines (34 loc) · 1.22 KB
/
model.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include "device.hpp"
// libs
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <vector>
namespace vraus_VulkanEngine {
/* The purpose of this class is to be able to take vertex data created by or read in a file on the cpu,
and then allocate the memory and copy the data over to our device GPU so it can be rendered efficiently.
*/
class Model {
public:
struct Vertex {
glm::vec2 position;
glm::vec3 color;
static std::vector<VkVertexInputBindingDescription> getBindingDescriptions();
static std::vector<VkVertexInputAttributeDescription> getAttributeDescriptions();
};
Model(Device &device, const std::vector<Vertex> &vertices);
~Model();
// We must delete the copy constructor because model class manages the vulkan buffer and memory object
Model(const Model&) = delete;
Model& operator=(const Model&) = delete;
void bind(VkCommandBuffer commandBuffer);
void draw(VkCommandBuffer commandBuffer);
private:
void createVertexBuffers(const std::vector<Vertex>& vertices);
Device& device;
VkBuffer vertexBuffer; // Buffer and its assigned memory are two seperate objects
VkDeviceMemory vertexBufferMemory;
uint32_t vertexCount;
};
}