summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward O'Callaghan <funfunctor@folklore1984.net>2017-02-08 00:55:23 +1100
committerEdward O'Callaghan <funfunctor@folklore1984.net>2017-02-08 00:55:23 +1100
commitfa3f688360218b3f8a049797342e8026064fd4c1 (patch)
treed50cf9feae53153e6cafef6e69b8cf10bb515fd3 /src
parenteda3e214131903e03a9ebf69e9746c2d2d609be0 (diff)
src/main.cpp: Implement Framebuffers
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 001b4e5..31a0c14 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -45,6 +45,7 @@ private:
VkExtent2D swapChainExtent;
std::vector<VDeleter<VkImageView>> swapChainImageViews;
+ std::vector<VDeleter<VkFramebuffer>> swapChainFramebuffers;
struct QueueFamilyIndices {
int graphicsFamily = -1;
@@ -92,6 +93,29 @@ private:
createImageViews();
createRenderPass();
createGraphicsPipeline();
+ createFramebuffers();
+ }
+
+ void createFramebuffers() {
+ swapChainFramebuffers.resize(swapChainImageViews.size(), VDeleter<VkFramebuffer>{device, vkDestroyFramebuffer});
+
+ for (size_t i = 0; i < swapChainImageViews.size(); i++) {
+ VkImageView attachments[] = {
+ swapChainImageViews[i]
+ };
+
+ VkFramebufferCreateInfo framebufferInfo = {};
+ framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
+ framebufferInfo.renderPass = renderPass;
+ framebufferInfo.attachmentCount = 1;
+ framebufferInfo.pAttachments = attachments;
+ framebufferInfo.width = swapChainExtent.width;
+ framebufferInfo.height = swapChainExtent.height;
+ framebufferInfo.layers = 1;
+
+ if (vkCreateFramebuffer(device, &framebufferInfo, nullptr, swapChainFramebuffers[i].replace()) != VK_SUCCESS)
+ throw std::runtime_error("failed to create framebuffer!");
+ }
}
void createRenderPass() {