Added a triangle
This commit is contained in:
parent
c20c6928b1
commit
fe7f7521d8
@ -3,7 +3,7 @@
|
||||
// Normal header
|
||||
|
||||
// Current progress
|
||||
// 3 - Graphics Pipeline - Doing PipelineBuilder functions
|
||||
// 3 - Graphics Pipeline - Doing mesh buffers
|
||||
|
||||
#include "descriptors.h" // Required for public interface custom allocator
|
||||
#include "Common/Types.h"
|
||||
@ -143,6 +143,9 @@ class Engine {
|
||||
void drawBackground(
|
||||
VkCommandBuffer cmd
|
||||
);
|
||||
void drawGeometry(
|
||||
VkCommandBuffer cmd
|
||||
);
|
||||
void drawImgui(
|
||||
VkCommandBuffer cmd,
|
||||
VkImageView targetImageView
|
||||
@ -352,11 +355,21 @@ void Engine::draw() {
|
||||
|
||||
drawBackground(cmd);
|
||||
|
||||
// Transfer the draw image and swapchain image to the correct layouts
|
||||
// Prepare for geometry draw
|
||||
vkutil::transitionImage(
|
||||
cmd,
|
||||
_drawImage.image,
|
||||
VK_IMAGE_LAYOUT_GENERAL,
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
|
||||
);
|
||||
|
||||
drawGeometry(cmd);
|
||||
|
||||
// Transfer the draw image and swapchain image to the correct layouts
|
||||
vkutil::transitionImage(
|
||||
cmd,
|
||||
_drawImage.image,
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
|
||||
);
|
||||
|
||||
@ -1330,6 +1343,51 @@ void Engine::drawBackground(
|
||||
|
||||
}
|
||||
|
||||
void Engine::drawGeometry(
|
||||
VkCommandBuffer cmd
|
||||
) {
|
||||
// Store some info
|
||||
uint32_t width = _drawExtent.width;
|
||||
uint32_t height = _drawExtent.height;
|
||||
// Begin rendering
|
||||
VkRenderingAttachmentInfo colorAttachment = vkinit::attachmentInfo(_drawImage.imageView, nullptr, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
|
||||
VkRenderingInfo renderInfo = vkinit::renderingInfo(_drawExtent, &colorAttachment, nullptr);
|
||||
vkCmdBeginRendering(cmd, &renderInfo);
|
||||
|
||||
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, _trianglePipeline);
|
||||
|
||||
// Dynamic viewport and scissor
|
||||
VkViewport viewport = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = (float)width,
|
||||
.height = (float)height,
|
||||
.minDepth = 0.f,
|
||||
.maxDepth = 1.f
|
||||
};
|
||||
|
||||
vkCmdSetViewport(cmd, 0, 1, &viewport);
|
||||
|
||||
VkRect2D scissor = {
|
||||
.offset = {
|
||||
.x = 0,
|
||||
.y = 0
|
||||
},
|
||||
.extent = {
|
||||
.width = (uint32_t)width,
|
||||
.height = (uint32_t)height
|
||||
}
|
||||
};
|
||||
|
||||
vkCmdSetScissor(cmd, 0, 1, &scissor);
|
||||
|
||||
//launch a draw command to draw 3 vertices
|
||||
vkCmdDraw(cmd, 3, 1, 0, 0);
|
||||
|
||||
vkCmdEndRendering(cmd);
|
||||
}
|
||||
|
||||
void Engine::drawImgui(
|
||||
VkCommandBuffer cmd,
|
||||
VkImageView targetImageView
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user