Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
CubemapTexture.h
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
94 CubemapTexture( const CubemapTexture & ) = delete;
95
100
105 CubemapTexture( CubemapTexture && other ) noexcept;
106
113
120 void createResourcesAndUpload( VkCommandPool commandPool, VkQueue queue );
121
125 void cleanup();
126
131 [[nodiscard]] VkDescriptorImageInfo getDescriptorInfo() const;
132
137 [[nodiscard]] bool isValid() const { return imageView_ != VK_NULL_HANDLE && sampler_ != VK_NULL_HANDLE; }
138
139 private:
142 VkImage image_ = VK_NULL_HANDLE;
143 VkDeviceMemory memory_ = VK_NULL_HANDLE;
144 VkImageView imageView_ = VK_NULL_HANDLE;
145 VkSampler sampler_ = VK_NULL_HANDLE;
146
148 };
149}
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
Copy assignment is disabled because Vulkan image handles are uniquely owned.
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
Copy construction is disabled because Vulkan image handles are uniquely owned.
The application context is the core class which stores the basic openxr and vulkan objects.
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.