#pragma once #if defined(_WIN64) #define VK_USE_PLATFORM_WIN32_KHR #elif defined(__APPLE__) #define VK_USE_PLATFORM_METAL_EXT #else #define VK_USE_PLATFORM_XCB_KHR #endif #define GLFW_INCLUDE_VULKAN #include #if defined(_WIN64) #define GLFW_EXPOSE_NATIVE_WIN32 #elif defined(__APPLE__) #define GLFW_EXPOSE_NATIVE_COCOA #else #define GLFW_EXPOSE_NATIVE_X11 #endif #include #define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1 #include #pragma endregion #define GLM_FORCE_RADIANS #include #include struct Vertex { glm::vec2 pos; glm::vec3 col; glm::vec2 texCoord; static vk::VertexInputBindingDescription getBindingDescription() { vk::VertexInputBindingDescription desc; desc.binding = 0; desc.stride = sizeof(Vertex); desc.inputRate = vk::VertexInputRate::eVertex; return desc; } static std::array getAttributeDescriptions() { std::array descs; { vk::VertexInputAttributeDescription desc; desc.location = 0; desc.binding = 0; desc.format = vk::Format::eR32G32Sfloat; desc.offset = offsetof(Vertex, pos); descs[0] = desc; } { vk::VertexInputAttributeDescription desc; desc.location = 1; desc.binding = 0; desc.format = vk::Format::eR32G32B32Sfloat; desc.offset = offsetof(Vertex, col); descs[1] = desc; } { vk::VertexInputAttributeDescription desc; desc.location = 2; desc.binding = 0; desc.format = vk::Format::eR32G32Sfloat; desc.offset = offsetof(Vertex, texCoord); descs[2] = desc; } return descs; } }; inline const std::vector vertices = { {{ -0.5f, -0.5f }, { 1.f, 0.f, 0.f }, { 1.f, 0.f }}, {{ 0.5f, -0.5f }, { 0.f, 1.f, 0.f }, { 0.f, 0.f }}, {{ 0.5f, 0.5f }, { 0.f, 0.f, 1.f }, { 0.f, 1.f }}, {{ -0.5f, 0.5f }, { 1.f, 1.f, 0.f }, { 1.f, 1.f }}, }; inline const std::vector indices = { 0, 1, 2, 2, 3, 0, }; struct UniformBufferObject { alignas(16) glm::mat4 model; alignas(16) glm::mat4 view; alignas(16) glm::mat4 proj; };