diff options
author | kartofen <mladenovnasko0@gmail.com> | 2023-11-11 19:00:10 +0200 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2023-11-11 19:00:10 +0200 |
commit | 1e436946514f3a0e9fe3d091394db6b86e06f033 (patch) | |
tree | cddf3bb618ade66fd5bd4eacd028a7d54a760e37 /src/graphics.c | |
parent | 2a733f3d513a7279c1df4efe88fc5386ced2ed14 (diff) |
.obj loading
Diffstat (limited to 'src/graphics.c')
-rw-r--r-- | src/graphics.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/graphics.c b/src/graphics.c index e722abf..d603f68 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -643,7 +643,7 @@ static int create_pipeline(graphics_t graphics, struct graphics_info *info) // set up graphics pipeline stages VkVertexInputBindingDescription binding_description = {0}; - VkVertexInputAttributeDescription attribute_description[2] = {0}; + VkVertexInputAttributeDescription attribute_description[3] = {0}; vertex_populate_descriptions(&binding_description, attribute_description); VkPipelineVertexInputStateCreateInfo vertex_input = {0}; @@ -669,8 +669,13 @@ static int create_pipeline(graphics_t graphics, struct graphics_info *info) rasterizer.rasterizerDiscardEnable = VK_FALSE; rasterizer.polygonMode = VK_POLYGON_MODE_FILL; rasterizer.lineWidth = 1.0f; - rasterizer.cullMode = VK_CULL_MODE_BACK_BIT; - rasterizer.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; + + // it is actually counter clocwise because + // the y axis was reversed + // but cull mode is NONE so both sides are shown + rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE; + rasterizer.cullMode = VK_CULL_MODE_NONE; + rasterizer.depthBiasEnable = VK_FALSE; rasterizer.depthBiasConstantFactor = 0.0f; // Optional @@ -1275,9 +1280,13 @@ static int command_buffer_record(graphics_t graphics, u32 image_index) vkCmdBindDescriptorSets(CMND.buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, PPLN.layout, 0, 1, &UBOD.set, 0, NULL); - // 3 is the number of vertices + // 6 is the number of vertices // TODO: fix this - vkCmdDrawIndexed(CMND.buffer, 6, 1, 0, 0, 0); +// #ifndef MONKEY + // vkCmdDrawIndexed(CMND.buffer, 6, 1, 0, 0, 0); +// #else + vkCmdDraw(CMND.buffer, 8723, 1, 0, 0); // draw monkey +// #endif // Cleaning up vkCmdEndRenderPass(CMND.buffer); @@ -1317,13 +1326,18 @@ static int vertex_populate_descriptions(VkVertexInputBindingDescription *binding attribute_desc[0].binding = 0; attribute_desc[0].location = 0; - attribute_desc[0].format = VK_FORMAT_R32G32_SFLOAT; + attribute_desc[0].format = VK_FORMAT_R32G32B32_SFLOAT; attribute_desc[0].offset = offsetof(struct vertex, pos); attribute_desc[1].binding = 0; attribute_desc[1].location = 1; attribute_desc[1].format = VK_FORMAT_R32G32B32_SFLOAT; - attribute_desc[1].offset = offsetof(struct vertex, color); + attribute_desc[1].offset = offsetof(struct vertex, normal); + + attribute_desc[2].binding = 0; + attribute_desc[2].location = 2; + attribute_desc[2].format = VK_FORMAT_R32G32B32_SFLOAT; + attribute_desc[2].offset = offsetof(struct vertex, color); return 0; } |