Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
CubemapTexture.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <filesystem>
6#include <string>
7#include <vector>
8
9#include <vulkan/vulkan_core.h>
10
11namespace Engine::Core
12{
14}
15
16namespace Engine::Assets
17{
24 {
28 uint32_t width = 0;
29
33 uint32_t height = 0;
34
38 std::array<std::vector<uint8_t>, 6> faces;
39
43 std::string uri;
44 };
45
53 {
54 public:
61 CubemapTextureData loadFromDirectory( const std::filesystem::path & directory ) const;
62 };
63
72 {
73 public:
77 CubemapTexture() = default;
78
85
90
91 CubemapTexture( const CubemapTexture & ) = delete;
93
98 CubemapTexture( CubemapTexture && other ) noexcept;
99
106
113 void createResourcesAndUpload( VkCommandPool commandPool, VkQueue queue );
114
118 void cleanup();
119
124 [[nodiscard]] VkDescriptorImageInfo getDescriptorInfo() const;
125
130 [[nodiscard]] bool isValid() const { return imageView_ != VK_NULL_HANDLE && sampler_ != VK_NULL_HANDLE; }
131
132 private:
135 VkImage image_ = VK_NULL_HANDLE;
136 VkDeviceMemory memory_ = VK_NULL_HANDLE;
137 VkImageView imageView_ = VK_NULL_HANDLE;
138 VkSampler sampler_ = VK_NULL_HANDLE;
139
141 };
142}
Loads cubemap face images from a directory.
CubemapTextureData loadFromDirectory(const std::filesystem::path &directory) const
Loads six cubemap faces from a directory.
CubemapTexture(CubemapTexture &&other) noexcept
Move-constructs a cubemap texture and transfers Vulkan handles.
~CubemapTexture()
Releases owned Vulkan resources.
void cleanup()
Releases the Vulkan image, image memory, and image view.
CubemapTexture & operator=(CubemapTexture &&other) noexcept
Move-assigns a cubemap texture and transfers Vulkan handles.
Core::ApplicationContext * context_
bool isValid() const
Checks whether the texture has sampling resources.
void createResourcesAndUpload(VkCommandPool commandPool, VkQueue queue)
Creates Vulkan resources and uploads all cubemap faces.
CubemapTexture & operator=(const CubemapTexture &)=delete
CubemapTexture(CubemapTextureData data, Core::ApplicationContext *context)
Creates a cubemap texture from CPU data and an application context.
VkDescriptorImageInfo getDescriptorInfo() const
Gets descriptor data for shader sampling.
CubemapTexture()=default
Creates an empty cubemap texture with no Vulkan resources.
CubemapTexture(const CubemapTexture &)=delete
The application context is the core class which stores the basic openxr and vulkan objects.
Manages IBL (Image-Based Lighting) resources for specular reflections.
CPU-side RGBA cubemap image data.
uint32_t height
Height in pixels for every face.
std::string uri
Source path or URI used to load this cubemap.
std::array< std::vector< uint8_t >, 6 > faces
RGBA8 pixel data for the six cubemap faces.
uint32_t width
Width in pixels for every face.