From b27cc55aa631c52dae4a1a9c8c6888fc063fe022 Mon Sep 17 00:00:00 2001 From: quou Date: Mon, 30 Dec 2024 10:25:26 +1100 Subject: backface culling --- video.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'video.cpp') diff --git a/video.cpp b/video.cpp index d5efb34..3148500 100644 --- a/video.cpp +++ b/video.cpp @@ -250,6 +250,15 @@ struct Vram_Allocator { void free(Allocation& alloc); }; +static VkCullModeFlags get_vk_cull_mode(Cull_Mode mode) { + switch (mode) { + case Cull_Mode::none: return VK_CULL_MODE_NONE; + case Cull_Mode::back: return VK_CULL_MODE_BACK_BIT; + case Cull_Mode::front: return VK_CULL_MODE_FRONT_BIT; + } + assert(0); + return VK_CULL_MODE_NONE; +} static VkFormat get_vk_format(Texture_Format fmt) { switch (fmt) { @@ -2631,14 +2640,13 @@ void Pipeline_Vk::init_rasterisation( sizeof ri ); (void)dev; - (void)desc; zero(&ri, sizeof ri); ri.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; ri.depthClampEnable = VK_FALSE; ri.rasterizerDiscardEnable = VK_FALSE; ri.polygonMode = VK_POLYGON_MODE_FILL; ri.lineWidth = 1.0f; - ri.cullMode = VK_CULL_MODE_NONE; + ri.cullMode = get_vk_cull_mode(desc.cull_mode); ri.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; ri.depthBiasEnable = VK_FALSE; info.pRasterizationState = &ri; -- cgit v1.2.3-54-g00ecf