Now Models can be loaded
This commit is contained in:
+24
-4
@@ -13,20 +13,19 @@
|
||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/hash.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace vapp{
|
||||
// Change here for other presentMode
|
||||
@@ -67,8 +66,13 @@ namespace vapp{
|
||||
|
||||
return attributeDescriptions;
|
||||
}
|
||||
|
||||
bool operator==(const Vertex &other) const{
|
||||
return pos == other.pos && color == other.color && texCoord == other.texCoord;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
const std::vector<Vertex> vertices = {
|
||||
{{-0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f}},
|
||||
{{0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
|
||||
@@ -86,6 +90,7 @@ namespace vapp{
|
||||
0, 1, 2, 2, 3, 0,
|
||||
4, 5, 6, 6, 7, 4
|
||||
};
|
||||
*/
|
||||
// END Remove
|
||||
|
||||
struct UniformBufferObject{
|
||||
@@ -154,6 +159,8 @@ namespace vapp{
|
||||
const int MAX_FRAMES_IN_FLIGHT = 2;
|
||||
uint32_t currentFrame = 0;
|
||||
|
||||
std::vector<Vertex> vertices;
|
||||
std::vector<uint32_t> indices;
|
||||
VkBuffer vertexBuffer;
|
||||
VkDeviceMemory vertexBufferMemory;
|
||||
VkBuffer indexBuffer;
|
||||
@@ -216,6 +223,7 @@ namespace vapp{
|
||||
void createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer &buffer, VkDeviceMemory &bufferMemory);
|
||||
void copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size);
|
||||
void copyBufferOld(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size);
|
||||
void loadModel();
|
||||
void createVertexBuffer();
|
||||
void createIndexBuffer();
|
||||
void createUniformBuffers();
|
||||
@@ -241,9 +249,21 @@ namespace vapp{
|
||||
#endif
|
||||
|
||||
bool framebufferResized = false;
|
||||
std::string MODEL_PATH;
|
||||
std::string TEXTURE_PATH;
|
||||
|
||||
void run(const char *windowName, const uint32_t width = 800, const uint32_t height = 600);
|
||||
};
|
||||
} // vapp
|
||||
|
||||
namespace std{
|
||||
template<> struct hash<vapp::Vertex>{
|
||||
size_t operator()(vapp::Vertex const &vertex) const{
|
||||
return ((hash<glm::vec3>()(vertex.pos) ^
|
||||
(hash<glm::vec3>()(vertex.color) << 1)) >> 1) ^
|
||||
(hash<glm::vec2>()(vertex.texCoord) << 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //VULKAN_APP_H
|
||||
|
||||
Reference in New Issue
Block a user