Add depth buffering
This commit is contained in:
1 parent
548ed57969
commit
d328e38761
9 files changed
+323
-39
No files matched your search
@@ -202,6 +202,7 @@ void update_uniform_buffers()
|
||||
struct vec3_t eye = {0};
|
||||
struct vec3_t center = {0};
|
||||
struct vec3_t up = {0};
|
||||
struct vec3_t rotation_vec = {1.0f, 0.0f, 0.0f};
|
||||
float fovy;
|
||||
float z_near;
|
||||
float z_far;
|
||||
@@ -214,7 +215,7 @@ void update_uniform_buffers()
|
||||
z_near = 0.1f;
|
||||
z_far = 20.0f;
|
||||
|
||||
ubo.model = rse_math_uniform_mat4();
|
||||
ubo.model = rse_math_rotate(rse_math_uniform_mat4(), rse_math_deg_to_radians(0.0f), rotation_vec);
|
||||
ubo.view = rse_math_look_at(&eye, ¢er, &up);
|
||||
ubo.proj = rse_math_perspective(fovy,
|
||||
g_vulkan_state.swapchain_extent.width / (float)g_vulkan_state.swapchain_extent.height,
|
||||
@@ -330,13 +331,20 @@ uint8_t record_command_buffer(uint32_t image_index)
|
||||
{
|
||||
VkCommandBuffer command_buffer = g_vulkan_state.command_buffers[g_vulkan_state.current_frame];
|
||||
VkCommandBufferBeginInfo begin_info = {};
|
||||
VkClearValue clear_color = {{{0.0f, 0.0f, 0.0f, 1.0f}}};
|
||||
VkRenderPassBeginInfo render_pass_info = {};
|
||||
VkViewport viewport = {};
|
||||
VkRect2D scissor = {};
|
||||
VkDeviceSize offsets[] = {0};
|
||||
VkClearValue clear_values[2] = {}; //For color and depth stencil
|
||||
size_t i = 0U;
|
||||
|
||||
clear_values[0].color.float32[0] = 0.0f;
|
||||
clear_values[0].color.float32[1] = 0.0f;
|
||||
clear_values[0].color.float32[2] = 0.0f;
|
||||
|
||||
clear_values[1].depthStencil.depth = 1.0f;
|
||||
clear_values[1].depthStencil.stencil = 0.0f;
|
||||
|
||||
begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
||||
begin_info.flags = 0;
|
||||
begin_info.pInheritanceInfo = NULL;
|
||||
@@ -352,8 +360,8 @@ uint8_t record_command_buffer(uint32_t image_index)
|
||||
render_pass_info.renderArea.offset.x = 0;
|
||||
render_pass_info.renderArea.offset.y = 0;
|
||||
render_pass_info.renderArea.extent = g_vulkan_state.swapchain_extent;
|
||||
render_pass_info.clearValueCount = 1;
|
||||
render_pass_info.pClearValues = &clear_color;
|
||||
render_pass_info.clearValueCount = 2;
|
||||
render_pass_info.pClearValues = clear_values;
|
||||
|
||||
vkCmdBeginRenderPass(command_buffer, &render_pass_info, VK_SUBPASS_CONTENTS_INLINE);
|
||||
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_vulkan_state.graphics_pipeline);
|
||||
|
||||
Reference in new issue
Block a user