1+ #pragma once
2+
3+ #include " ../VkIncludes.h"
4+ #include " ../VkSetup.h"
5+ #include " ../VkMemory.h"
6+ #include " VkBufferCreation.h"
7+
8+ namespace VkRenderer
9+ {
10+ struct Vertex
11+ {
12+ glm::vec3 pos;
13+ glm::vec3 color;
14+ glm::vec2 texCoord;
15+
16+ static VkVertexInputBindingDescription getBindingDescription () {
17+ VkVertexInputBindingDescription bindingDescription{};
18+ bindingDescription.binding = 0 ;
19+ bindingDescription.stride = sizeof (Vertex);
20+ bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
21+
22+ return bindingDescription;
23+ }
24+
25+ static std::array<VkVertexInputAttributeDescription, 3 > getAttributeDescriptions () {
26+ std::array<VkVertexInputAttributeDescription, 3 > attributeDescriptions{};
27+
28+ attributeDescriptions[0 ].binding = 0 ;
29+ attributeDescriptions[0 ].location = 0 ;
30+ attributeDescriptions[0 ].format = VK_FORMAT_R32G32B32_SFLOAT;
31+ attributeDescriptions[0 ].offset = offsetof (Vertex, pos);
32+
33+ attributeDescriptions[1 ].binding = 0 ;
34+ attributeDescriptions[1 ].location = 1 ;
35+ attributeDescriptions[1 ].format = VK_FORMAT_R32G32B32_SFLOAT;
36+ attributeDescriptions[1 ].offset = offsetof (Vertex, color);
37+
38+ attributeDescriptions[2 ].binding = 0 ;
39+ attributeDescriptions[2 ].location = 2 ;
40+ attributeDescriptions[2 ].format = VK_FORMAT_R32G32_SFLOAT;
41+ attributeDescriptions[2 ].offset = offsetof (Vertex, texCoord);
42+
43+ return attributeDescriptions;
44+ }
45+ bool operator ==(const Vertex& other) const {
46+ return pos == other.pos && color == other.color && texCoord == other.texCoord ;
47+ }
48+ };
49+
50+
51+
52+ class VkVbuffer
53+ {
54+ public:
55+ void createVertexBuffer (VkCommandPool& commandPool);
56+ VkBuffer vertexBuffer;
57+ VkDeviceMemory vertexBufferMemory;
58+ VkSetup *setup_ref;
59+ VkBufferCreation *buffer_ref;
60+ std::vector<Vertex> vertices;
61+ };
62+ }
0 commit comments