Fixed viewport swankiness by reversing the culling order

This commit is contained in:
Conál 2024-01-26 11:28:22 -05:00
parent 764044b01e
commit 15dc595753
3 changed files with 10 additions and 9 deletions

View File

@ -83,7 +83,7 @@ GraphicsPipeline::GraphicsPipeline(vk::Device dev, const std::vector<Shader>& sh
.depthClampEnable = vk::False, .depthClampEnable = vk::False,
.polygonMode = vk::PolygonMode::eFill, .polygonMode = vk::PolygonMode::eFill,
.cullMode = vk::CullModeFlagBits::eBack, .cullMode = vk::CullModeFlagBits::eBack,
.frontFace = vk::FrontFace::eClockwise, .frontFace = vk::FrontFace::eCounterClockwise,
.depthBiasEnable = vk::False, .depthBiasEnable = vk::False,
.lineWidth = 1.0, .lineWidth = 1.0,
}; };
@ -121,9 +121,9 @@ GraphicsPipeline::GraphicsPipeline(vk::Device dev, const std::vector<Shader>& sh
/* temporary viewport and scissor, since it is a dynamic state due to the existence of window resizing */ /* temporary viewport and scissor, since it is a dynamic state due to the existence of window resizing */
const auto viewport = vk::Viewport{ const auto viewport = vk::Viewport{
.x = 0.0, .x = 0.0,
.y = 0.0, .y = static_cast<float>(extent.height),
.width = static_cast<float>(extent.width), .width = static_cast<float>(extent.width),
.height = static_cast<float>(extent.height), .height = -static_cast<float>(extent.height),
}; };
const auto scissor = vk::Rect2D { const auto scissor = vk::Rect2D {

View File

@ -233,7 +233,7 @@ void Renderer::draw() {
}; };
/* flip viewport */ /* flip viewport */
auto viewport = vk::Viewport{ auto viewport = vk::Viewport{
.x = 0.0f, .x = 0.0f,
// .y = 0.0f, // .y = 0.0f,
.y = static_cast<float>(swapchain->extent.height), .y = static_cast<float>(swapchain->extent.height),
@ -243,7 +243,7 @@ void Renderer::draw() {
.maxDepth = 1.0f, .maxDepth = 1.0f,
}; };
auto scissor = vk::Rect2D{ auto scissor = vk::Rect2D {
.offset = {0, 0}, .offset = {0, 0},
.extent = swapchain->extent, .extent = swapchain->extent,
}; };
@ -253,6 +253,10 @@ void Renderer::draw() {
command_buffer->bind(*pipeline); command_buffer->bind(*pipeline);
command_buffer->command_buffer.setViewport(0, viewport);
command_buffer->command_buffer.setScissor(0, scissor);
command_buffer->bind(*vertex_buffer); command_buffer->bind(*vertex_buffer);
command_buffer->bind(pipeline->layout, pipeline->desc_set); command_buffer->bind(pipeline->layout, pipeline->desc_set);
@ -262,9 +266,6 @@ void Renderer::draw() {
pipeline->update(0, *uniform_buffer); pipeline->update(0, *uniform_buffer);
command_buffer->command_buffer.setViewport(0, viewport);
command_buffer->command_buffer.setScissor(0, scissor);
command_buffer->draw(9, 1, 0, 0); command_buffer->draw(9, 1, 0, 0);
command_buffer->command_buffer.endRenderPass(); command_buffer->command_buffer.endRenderPass();

View File

@ -13,7 +13,7 @@ namespace Log {
return static_cast<MessageLevelBit>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b)); return static_cast<MessageLevelBit>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b));
} }
static const MessageLevelBit log_mask = ERROR | INFO | DEBUG; static const MessageLevelBit log_mask = ERROR | INFO;
template<typename ...Args> template<typename ...Args>
static void print(MessageLevelBit level, const std::string& fmt, Args... args) { static void print(MessageLevelBit level, const std::string& fmt, Args... args) {