-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Odd Kiva
committed
Nov 27, 2023
1 parent
5166d84
commit 8b4eba4
Showing
9 changed files
with
275 additions
and
73 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
cpp/examples/Shakti/Vulkan/hello_vulkan_image/Geometry.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// ========================================================================== // | ||
// This file is part of Sara, a basic set of libraries in C++ for computer | ||
// vision. | ||
// | ||
// Copyright (C) 2023 David Ok <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// you can obtain one at http://mozilla.org/MPL/2.0/. | ||
// ========================================================================== // | ||
|
||
#pragma once | ||
|
||
#include <vulkan/vulkan.h> | ||
|
||
#include <Eigen/Core> | ||
|
||
#include <vector> | ||
|
||
|
||
struct Vertex | ||
{ | ||
Eigen::Vector2f pos; | ||
Eigen::Vector3f color; | ||
Eigen::Vector2f uv; | ||
|
||
static auto get_binding_description() -> VkVertexInputBindingDescription | ||
{ | ||
VkVertexInputBindingDescription binding_description{}; | ||
binding_description.binding = 0; | ||
binding_description.stride = sizeof(Vertex); | ||
binding_description.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; | ||
|
||
return binding_description; | ||
} | ||
|
||
static auto get_attribute_descriptions() | ||
-> std::vector<VkVertexInputAttributeDescription> | ||
{ | ||
auto attribute_descriptions = | ||
std::vector<VkVertexInputAttributeDescription>(3); | ||
|
||
// Position | ||
attribute_descriptions[0].binding = 0; | ||
attribute_descriptions[0].location = 0; | ||
attribute_descriptions[0].format = VK_FORMAT_R32G32_SFLOAT; | ||
attribute_descriptions[0].offset = offsetof(Vertex, pos); | ||
|
||
// Color | ||
attribute_descriptions[1].binding = 0; | ||
attribute_descriptions[1].location = 1; | ||
attribute_descriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT; | ||
attribute_descriptions[1].offset = offsetof(Vertex, color); | ||
|
||
// UV texture coords | ||
attribute_descriptions[2].binding = 0; | ||
attribute_descriptions[2].location = 2; | ||
attribute_descriptions[2].format = VK_FORMAT_R32G32_SFLOAT; | ||
attribute_descriptions[2].offset = offsetof(Vertex, uv); | ||
|
||
return attribute_descriptions; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.