FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_vertex.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_VULKAN_C_VERTEX_HPP_INCLUDED
18#define _FGE_VULKAN_C_VERTEX_HPP_INCLUDED
19
20#include "volk.h"
21#include <array>
22
23#include "FastEngine/C_vector.hpp"
24
25namespace fge::vulkan
26{
27
28struct Vertex
29{
30 glm::vec2 _position{0.0f, 0.0f};
31 uint32_t _color{std::numeric_limits<uint32_t>::max()};
32 glm::vec2 _texCoords{0.0f, 0.0f};
33
34 static VkVertexInputBindingDescription getBindingDescription()
35 {
36 VkVertexInputBindingDescription bindingDescription{};
37 bindingDescription.binding = 0;
38 bindingDescription.stride = sizeof(Vertex);
39 bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
40
41 return bindingDescription;
42 }
43
44 static std::array<VkVertexInputAttributeDescription, 3> getAttributeDescriptions()
45 {
46 std::array<VkVertexInputAttributeDescription, 3> attributeDescriptions{};
47
48 attributeDescriptions[0].binding = 0;
49 attributeDescriptions[0].location = 0;
50 attributeDescriptions[0].format = VK_FORMAT_R32G32_SFLOAT;
51 attributeDescriptions[0].offset = offsetof(Vertex, _position);
52
53 attributeDescriptions[1].binding = 0;
54 attributeDescriptions[1].location = 1;
55 attributeDescriptions[1].format = VK_FORMAT_R8G8B8A8_UINT;
56 attributeDescriptions[1].offset = offsetof(Vertex, _color);
57
58 attributeDescriptions[2].binding = 0;
59 attributeDescriptions[2].location = 2;
60 attributeDescriptions[2].format = VK_FORMAT_R32G32_SFLOAT;
61 attributeDescriptions[2].offset = offsetof(Vertex, _texCoords);
62
63 return attributeDescriptions;
64 }
65};
66
67} // namespace fge::vulkan
68
69#endif //_FGE_VULKAN_C_VERTEX_HPP_INCLUDED
Definition C_vertex.hpp:29