.. _program_listing_file_PrismEngine_src_vertex.cpp: Program Listing for File vertex.cpp =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``PrismEngine/src/vertex.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include "vertex.h" #include VkVertexInputBindingDescription prism::PGC::Vertex::getBindingDescription() { VkVertexInputBindingDescription bindingDescription{}; bindingDescription.binding = 0; bindingDescription.stride = sizeof(Vertex); bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; return bindingDescription; } std::array prism::PGC::Vertex::getAttributeDescriptions() { std::array attributeDescriptions{}; attributeDescriptions[0].binding = 0; attributeDescriptions[0].location = 0; attributeDescriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT; attributeDescriptions[0].offset = offsetof(Vertex, pos); attributeDescriptions[1].binding = 0; attributeDescriptions[1].location = 1; attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT; attributeDescriptions[1].offset = offsetof(Vertex, color); attributeDescriptions[2].binding = 0; attributeDescriptions[2].location = 2; attributeDescriptions[2].format = VK_FORMAT_R32G32_SFLOAT; attributeDescriptions[2].offset = offsetof(Vertex, texCoord); attributeDescriptions[3].binding = 0; attributeDescriptions[3].location = 3; attributeDescriptions[3].format = VK_FORMAT_R32G32B32_SFLOAT; attributeDescriptions[3].offset = offsetof(Vertex, normal); return attributeDescriptions; } bool prism::PGC::Vertex::operator==(const Vertex& other) const { return pos == other.pos && color == other.color && texCoord == other.texCoord; } size_t prism::PGC::VertexHasher::operator()(const Vertex& v) const noexcept { size_t seed = 0; auto hash_combine = [&seed](float value) { seed ^= std::hash{}(value)+0x9e3779b9 + (seed << 6) + (seed >> 2); }; hash_combine(v.pos.x); hash_combine(v.pos.y); hash_combine(v.pos.z); hash_combine(v.color.r); hash_combine(v.color.g); hash_combine(v.color.b); hash_combine(v.texCoord.x); hash_combine(v.texCoord.y); hash_combine(v.normal.x); hash_combine(v.normal.y); hash_combine(v.normal.z); return seed; }