basic rendering for both opengl and vulkan
This commit is contained in:
parent
4b18afa040
commit
dadd2edaf1
29 changed files with 1140 additions and 38 deletions
37
rendering/vk/framebuffer.c
Normal file
37
rendering/vk/framebuffer.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* SPDX-License-Identifier:BSD-3-Clause */
|
||||
#include "framebuffer.h"
|
||||
#include "../../core/log.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void vk_framebuffers_init(struct renderer_context *context)
|
||||
{
|
||||
context->swapchain.framebuffers = malloc(sizeof(VkFramebuffer) * context->swapchain.image_count);
|
||||
|
||||
for (u32 i = 0; i < context->swapchain.image_count; i++) {
|
||||
VkImageView attachments[] = { context->swapchain.image_views[i] };
|
||||
|
||||
VkFramebufferCreateInfo framebuffer_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
|
||||
.renderPass = context->render_pass,
|
||||
.attachmentCount = 1,
|
||||
.pAttachments = attachments,
|
||||
.width = context->swapchain.extent.width,
|
||||
.height = context->swapchain.extent.height,
|
||||
.layers = 1
|
||||
};
|
||||
|
||||
if (vkCreateFramebuffer(context->device, &framebuffer_info, NULL, &context->swapchain.framebuffers[i]) != VK_SUCCESS) {
|
||||
fatal("Can't create framebuffer.\n");
|
||||
}
|
||||
}
|
||||
|
||||
log_info("Framebuffers created.\n");
|
||||
}
|
||||
|
||||
void vk_framebuffers_deinit(struct renderer_context *context)
|
||||
{
|
||||
for (u32 i = 0; i < context->swapchain.image_count; i++) {
|
||||
vkDestroyFramebuffer(context->device, context->swapchain.framebuffers[i], NULL);
|
||||
}
|
||||
free(context->swapchain.framebuffers);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue