summaryrefslogtreecommitdiff
path: root/src/blucat/texture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/blucat/texture.cpp')
-rw-r--r--src/blucat/texture.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/blucat/texture.cpp b/src/blucat/texture.cpp
index 1213528..4c94945 100644
--- a/src/blucat/texture.cpp
+++ b/src/blucat/texture.cpp
@@ -16,8 +16,8 @@
#include "texture.hpp"
-#include "../command.hpp"
-#include "../core.hpp"
+#include "command.hpp"
+#include "core.hpp"
#include "image.hpp"
#include "qoi.hpp"
#include "source_buffer.hpp"
@@ -36,7 +36,7 @@ create_vulkan_image(
vk_extent3d.depth = 1;
BluCat::Image::create(
- cg_core.vk_device_with_swapchain,
+ BluCat::core.vk_device_with_swapchain,
image,
device_memory,
VK_FORMAT_R8G8B8A8_UNORM,
@@ -91,7 +91,7 @@ load_image(void *obj)
size_t image_size{static_cast<size_t>(
qoi_image.header.width * qoi_image.header.height * num_channels)};
BluCat::SourceBuffer source_image_buffer{
- cg_core.vk_device_with_swapchain, pixels, image_size};
+ BluCat::core.vk_device_with_swapchain, pixels, image_size};
{ // Create vulkan image.
try
@@ -156,10 +156,11 @@ unload_image(void *obj)
auto self = static_cast<ImageBuilder*>(obj);
vkDestroyImage(
- cg_core.vk_device_with_swapchain->device, self->texture->image, nullptr);
+ BluCat::core.vk_device_with_swapchain->device, self->texture->image,
+ nullptr);
vkFreeMemory(
- cg_core.vk_device_with_swapchain->device, self->texture->device_memory,
- nullptr);
+ BluCat::core.vk_device_with_swapchain->device,
+ self->texture->device_memory, nullptr);
}
void
@@ -188,7 +189,7 @@ load_sampler(void *obj)
sampler_info.unnormalizedCoordinates = VK_FALSE;
if(vkCreateSampler(
- cg_core.vk_device_with_swapchain->device, &sampler_info, nullptr,
+ BluCat::core.vk_device_with_swapchain->device, &sampler_info, nullptr,
&self->texture->sampler) != VK_SUCCESS)
throw CommandError{"Failed to create texture sampler."};
}
@@ -199,7 +200,8 @@ unload_sampler(void *obj)
auto self = static_cast<ImageBuilder*>(obj);
vkDestroySampler(
- cg_core.vk_device_with_swapchain->device, self->texture->sampler, nullptr);
+ BluCat::core.vk_device_with_swapchain->device, self->texture->sampler,
+ nullptr);
}
void
@@ -210,7 +212,7 @@ load_view(void *obj)
try
{
BluCat::Image::create_view(
- cg_core.vk_device_with_swapchain, &self->texture->view,
+ BluCat::core.vk_device_with_swapchain, &self->texture->view,
self->texture->image,
VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT);
}
@@ -226,7 +228,8 @@ unload_view(void *obj)
auto self = static_cast<ImageBuilder*>(obj);
vkDestroyImageView(
- cg_core.vk_device_with_swapchain->device, self->texture->view, nullptr);
+ BluCat::core.vk_device_with_swapchain->device, self->texture->view,
+ nullptr);
}
const CommandChain image_loader{
@@ -331,7 +334,7 @@ load_text_image(void *obj)
}
}
BluCat::SourceBuffer source_image_buffer{
- cg_core.vk_device_with_swapchain, pixels.data(), image_size};
+ BluCat::core.vk_device_with_swapchain, pixels.data(), image_size};
{ // Create vulkan image.
try
@@ -351,7 +354,8 @@ load_text_image(void *obj)
{ // Render text
auto queue_family{
- cg_core.vk_device_with_swapchain->get_queue_family_with_presentation()};
+ BluCat::core.vk_device_with_swapchain->
+ get_queue_family_with_presentation()};
auto queue{queue_family->get_queue()};
BluCat::CommandPool command_pool{queue_family, 1};
VkCommandBuffer vk_command_buffer{command_pool.command_buffers[0]};
@@ -436,13 +440,13 @@ load_descriptor_set_pool(void *obj)
std::array<VkDescriptorPoolSize, 1> descriptor_pool_sizes{};
descriptor_pool_sizes[0].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
descriptor_pool_sizes[0].descriptorCount =
- cg_core.vk_swapchain->images_count;
+ BluCat::core.vk_swapchain->images_count;
VkDescriptorPoolCreateInfo pool_info{};
pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
pool_info.pNext = nullptr;
pool_info.flags = 0;
- pool_info.maxSets = cg_core.vk_swapchain->images_count;
+ pool_info.maxSets = BluCat::core.vk_swapchain->images_count;
pool_info.poolSizeCount = descriptor_pool_sizes.size();
pool_info.pPoolSizes = descriptor_pool_sizes.data();
@@ -467,8 +471,8 @@ load_descriptor_sets(void *obj)
auto self = static_cast<BluCat::Texture*>(obj);
std::vector<VkDescriptorSetLayout> layouts(
- cg_core.vk_swapchain->images_count,
- cg_core.vk_descriptor_set_layout->texture);
+ BluCat::core.vk_swapchain->images_count,
+ BluCat::core.vk_descriptor_set_layout->texture);
VkDescriptorSetAllocateInfo alloc_info{};
alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
@@ -488,7 +492,7 @@ load_data_to_descriptor_sets(void *obj)
{
auto self = static_cast<BluCat::Texture*>(obj);
- for(auto i{0}; i < cg_core.vk_swapchain->images_count; i++)
+ for(auto i{0}; i < BluCat::core.vk_swapchain->images_count; i++)
{
VkDescriptorImageInfo image_info{};
image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
@@ -508,7 +512,7 @@ load_data_to_descriptor_sets(void *obj)
write_descriptors[0].pTexelBufferView = nullptr;
vkUpdateDescriptorSets(
- cg_core.vk_device_with_swapchain->device, write_descriptors.size(),
+ BluCat::core.vk_device_with_swapchain->device, write_descriptors.size(),
write_descriptors.data(), 0, nullptr);
}
}
@@ -527,7 +531,8 @@ namespace BluCat
Texture::Texture(Font *font, const char* str)
{
this->queue_family =
- cg_core.vk_device_with_swapchain->get_queue_family_with_presentation();
+ BluCat::core.vk_device_with_swapchain->
+ get_queue_family_with_presentation();
TextTextureBuilder text_builder(this, font, str);
text_loader.execute(&text_builder);
@@ -537,7 +542,8 @@ Texture::Texture(Font *font, const char* str)
Texture::Texture(std::string texture_path)
{
this->queue_family =
- cg_core.vk_device_with_swapchain->get_queue_family_with_presentation();
+ BluCat::core.vk_device_with_swapchain->
+ get_queue_family_with_presentation();
ImageTextureBuilder texture_builder(this, texture_path);
image_loader.execute(&texture_builder);