summaryrefslogtreecommitdiff
path: root/src/blucat/framebuffer.cpp
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2024-05-16 14:22:35 -0300
committerFrederico Linhares <fred@linhares.blue>2024-05-16 14:22:35 -0300
commitd5a2b6bca9f9cc57dcca19962d5ba9b83d26da3e (patch)
treefa4decb441b0cc5cd189183166a324079f37c45a /src/blucat/framebuffer.cpp
parent43821b0cffc5aa419c0218992f06f8962ae54a13 (diff)
refa Move BluCan initialization to BluCat folderHEADmaster
Diffstat (limited to 'src/blucat/framebuffer.cpp')
-rw-r--r--src/blucat/framebuffer.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/blucat/framebuffer.cpp b/src/blucat/framebuffer.cpp
index e761ff2..c4d3230 100644
--- a/src/blucat/framebuffer.cpp
+++ b/src/blucat/framebuffer.cpp
@@ -16,7 +16,8 @@
#include "framebuffer.hpp"
-#include "../core.hpp"
+#include "command.hpp"
+#include "core.hpp"
#include "image.hpp"
namespace
@@ -27,14 +28,14 @@ load_depth_image(void *obj)
auto self = static_cast<BluCat::Framebuffer*>(obj);
VkExtent3D extent3d{};
- extent3d.width = cg_core.display_width;
- extent3d.height = cg_core.display_height;
+ extent3d.width = BluCat::core.display_width;
+ extent3d.height = BluCat::core.display_height;
extent3d.depth = 1;
try
{
BluCat::Image::create(
- cg_core.vk_device_with_swapchain,
+ BluCat::core.vk_device_with_swapchain,
&self->depth_image,
&self->depth_image_memory,
VK_FORMAT_D32_SFLOAT,
@@ -58,10 +59,10 @@ unload_depth_image(void *obj)
auto self = static_cast<BluCat::Framebuffer*>(obj);
vkDestroyImage(
- cg_core.vk_device_with_swapchain->device, self->depth_image,
+ BluCat::core.vk_device_with_swapchain->device, self->depth_image,
nullptr);
vkFreeMemory(
- cg_core.vk_device_with_swapchain->device,
+ BluCat::core.vk_device_with_swapchain->device,
self->depth_image_memory, nullptr);
}
@@ -73,7 +74,7 @@ load_depth_image_view(void *obj)
try
{
BluCat::Image::create_view(
- cg_core.vk_device_with_swapchain, &self->depth_image_view,
+ BluCat::core.vk_device_with_swapchain, &self->depth_image_view,
self->depth_image,
VK_FORMAT_D32_SFLOAT, VK_IMAGE_ASPECT_DEPTH_BIT);
}
@@ -91,7 +92,8 @@ unload_depth_image_view(void *obj)
auto self = static_cast<BluCat::Framebuffer*>(obj);
vkDestroyImageView(
- cg_core.vk_device_with_swapchain->device, self->depth_image_view, nullptr);
+ BluCat::core.vk_device_with_swapchain->device, self->depth_image_view,
+ nullptr);
}
void
@@ -99,26 +101,26 @@ load_3d(void *obj)
{
auto self = static_cast<BluCat::Framebuffer*>(obj);
- self->pipeline_3d.resize(cg_core.vk_swapchain->images_count);
- for (auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
+ self->pipeline_3d.resize(BluCat::core.vk_swapchain->images_count);
+ for (auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++)
{
std::array<VkImageView, 2> attachments = {
- cg_core.vk_swapchain->image_views[i],
+ BluCat::core.vk_swapchain->image_views[i],
self->depth_image_view
};
VkFramebufferCreateInfo framebuffer_info{};
framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
- framebuffer_info.renderPass = cg_core.vk_render_pass->pipeline_3d;
+ framebuffer_info.renderPass = BluCat::core.vk_render_pass->pipeline_3d;
framebuffer_info.attachmentCount = attachments.size();
framebuffer_info.pAttachments = attachments.data();
- framebuffer_info.width = cg_core.display_width;
- framebuffer_info.height = cg_core.display_height;
+ framebuffer_info.width = BluCat::core.display_width;
+ framebuffer_info.height = BluCat::core.display_height;
framebuffer_info.layers = 1;
if(vkCreateFramebuffer(
- cg_core.vk_device_with_swapchain->device, &framebuffer_info, nullptr,
+ BluCat::core.vk_device_with_swapchain->device, &framebuffer_info, nullptr,
&self->pipeline_3d[i]) != VK_SUCCESS)
throw CommandError{"Failed to create Vulkan Framebuffer."};
}
@@ -131,7 +133,7 @@ unload_3d(void *obj)
for(auto framebuffer: self->pipeline_3d)
vkDestroyFramebuffer(
- cg_core.vk_device_with_swapchain->device, framebuffer, nullptr);
+ BluCat::core.vk_device_with_swapchain->device, framebuffer, nullptr);
}
void
@@ -139,25 +141,25 @@ load_2d(void *obj)
{
auto self = static_cast<BluCat::Framebuffer*>(obj);
- self->pipeline_2d.resize(cg_core.vk_swapchain->images_count);
- for (auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
+ self->pipeline_2d.resize(BluCat::core.vk_swapchain->images_count);
+ for (auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++)
{
std::array<VkImageView, 1> attachments = {
- cg_core.vk_swapchain->image_views[i]
+ BluCat::core.vk_swapchain->image_views[i]
};
VkFramebufferCreateInfo framebuffer_info{};
framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
- framebuffer_info.renderPass = cg_core.vk_render_pass->pipeline_2d;
+ framebuffer_info.renderPass = BluCat::core.vk_render_pass->pipeline_2d;
framebuffer_info.attachmentCount = attachments.size();
framebuffer_info.pAttachments = attachments.data();
- framebuffer_info.width = cg_core.display_width;
- framebuffer_info.height = cg_core.display_height;
+ framebuffer_info.width = BluCat::core.display_width;
+ framebuffer_info.height = BluCat::core.display_height;
framebuffer_info.layers = 1;
if(vkCreateFramebuffer(
- cg_core.vk_device_with_swapchain->device, &framebuffer_info, nullptr,
- &self->pipeline_2d[i])
+ BluCat::core.vk_device_with_swapchain->device, &framebuffer_info,
+ nullptr, &self->pipeline_2d[i])
!= VK_SUCCESS)
throw CommandError{"Failed to create Vulkan Framebuffer."};
}
@@ -170,7 +172,7 @@ unload_2d(void *obj)
for(auto framebuffer: self->pipeline_2d)
vkDestroyFramebuffer(
- cg_core.vk_device_with_swapchain->device, framebuffer, nullptr);
+ BluCat::core.vk_device_with_swapchain->device, framebuffer, nullptr);
}
const CommandChain loader{