summaryrefslogtreecommitdiff
path: root/src/vk
diff options
context:
space:
mode:
Diffstat (limited to 'src/vk')
-rw-r--r--src/vk/graphics_pipeline.cpp13
-rw-r--r--src/vk/model.cpp46
-rw-r--r--src/vk/vertex.hpp1
3 files changed, 10 insertions, 50 deletions
diff --git a/src/vk/graphics_pipeline.cpp b/src/vk/graphics_pipeline.cpp
index bd0406c..de08945 100644
--- a/src/vk/graphics_pipeline.cpp
+++ b/src/vk/graphics_pipeline.cpp
@@ -533,7 +533,7 @@ load_pipeline(void *obj)
vertex_input_binding.stride = sizeof(VK::Vertex);
vertex_input_binding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
- std::array<VkVertexInputAttributeDescription, 4> vertex_attribute{};
+ std::array<VkVertexInputAttributeDescription, 3> vertex_attribute{};
// Position.
vertex_attribute[0].location = 0;
vertex_attribute[0].binding = 0;
@@ -544,16 +544,11 @@ load_pipeline(void *obj)
vertex_attribute[1].binding = 0;
vertex_attribute[1].format = VK_FORMAT_R32G32B32_SFLOAT;
vertex_attribute[1].offset = offsetof(VK::Vertex, normal);
- // Color.
+ // Texture coordinate.
vertex_attribute[2].location = 2;
vertex_attribute[2].binding = 0;
- vertex_attribute[2].format = VK_FORMAT_R32G32B32_SFLOAT;
- vertex_attribute[2].offset = offsetof(VK::Vertex, color);
- // Texture coordinate.
- vertex_attribute[3].location = 3;
- vertex_attribute[3].binding = 0;
- vertex_attribute[3].format = VK_FORMAT_R32G32_SFLOAT;
- vertex_attribute[3].offset = offsetof(VK::Vertex, texture_coord);
+ vertex_attribute[2].format = VK_FORMAT_R32G32_SFLOAT;
+ vertex_attribute[2].offset = offsetof(VK::Vertex, texture_coord);
VkPipelineVertexInputStateCreateInfo vertex_input_info = {};
vertex_input_info.sType =
diff --git a/src/vk/model.cpp b/src/vk/model.cpp
index d47db8a..5cf96b6 100644
--- a/src/vk/model.cpp
+++ b/src/vk/model.cpp
@@ -48,16 +48,6 @@ ModelBuilder::ModelBuilder(VK::Model *m, const char *mp):
{
}
-struct MeshData
-{
- glm::vec3 color;
-
- uint32_t vertex_base;
- uint32_t vertex_count;
- uint32_t index_base;
- uint32_t index_count;
-};
-
uint32_t read_uint32_from_file(std::ifstream &input_file)
{
uint32_t data{};
@@ -90,42 +80,20 @@ load_mesh(void *obj)
std::ifstream input_file{self->model_path};
if(!input_file.is_open()) throw CommandError{"Failed to open file."};
- std::vector<MeshData> meshes{};
-
self->model->queue_family =
cg_core.vk_device_with_swapchain->get_queue_family_with_graphics();
VK::Queue transfer_queue{self->model->queue_family->get_queue()};
- // Load meshes.
- {
- uint32_t meshes_count{read_uint32_from_file(input_file)};
- meshes.resize(meshes_count);
-
- for(uint32_t i{0}; i < meshes_count; i++)
- {
- meshes[i].color = read_vec3_from_file(input_file);
-
- meshes[i].vertex_base = read_uint32_from_file(input_file);
- meshes[i].vertex_count = read_uint32_from_file(input_file);
- meshes[i].index_base = read_uint32_from_file(input_file);
- meshes[i].index_count = read_uint32_from_file(input_file);
- }
- }
-
// Load vertexes.
{
- uint32_t vertex_count{read_uint32_from_file(input_file)};
+ auto vertex_count{read_uint32_from_file(input_file)};
std::vector<VK::Vertex> vertexes{vertex_count};
- for(auto mesh: meshes)
+ for(auto i{0}; i < vertex_count; i++)
{
- for(uint32_t i{mesh.vertex_base}; i < mesh.vertex_count; i++)
- {
- vertexes[i].position = read_vec3_from_file(input_file);
- vertexes[i].normal = read_vec3_from_file(input_file);
- vertexes[i].texture_coord = read_vec2_from_file(input_file);
- vertexes[i].color = mesh.color;
- }
+ vertexes[i].position = read_vec3_from_file(input_file);
+ vertexes[i].normal = read_vec3_from_file(input_file);
+ vertexes[i].texture_coord = read_vec2_from_file(input_file);
}
void *vertexes_data{vertexes.data()};
@@ -142,10 +110,8 @@ load_mesh(void *obj)
self->model->index_count = read_uint32_from_file(input_file);
std::vector<uint32_t> indexes(self->model->index_count);
- for(uint32_t i{0}; i < self->model->index_count; i++)
- {
+ for(auto i{0}; i < self->model->index_count; i++)
indexes[i] = read_uint32_from_file(input_file);
- }
void *indexes_data{indexes.data()};
size_t indexes_size{sizeof(indexes[0]) * indexes.size()};
diff --git a/src/vk/vertex.hpp b/src/vk/vertex.hpp
index 735d0a7..07332a8 100644
--- a/src/vk/vertex.hpp
+++ b/src/vk/vertex.hpp
@@ -26,7 +26,6 @@ struct Vertex
{
glm::vec3 position;
glm::vec3 normal;
- glm::vec3 color;
glm::vec2 texture_coord;
};