PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
ImageCube.hpp
1#pragma once
2
3#include "PixelBullet/Filesystem/Resources/Resource.hpp"
4#include "PixelBullet/Filesystem/VirtualPath.hpp"
5#include "PixelBullet/Graphics/Images/Image.hpp"
6#include "PixelBullet/Serialization/Node.hpp"
7
8#include <glm/glm.hpp>
9
10#include <string>
11#include <typeindex>
12#include <vector>
13
14namespace PixelBullet
15{
16 class Bitmap;
17
21 class ImageCube : public Image, public Resource
22 {
23 public:
29 static std::shared_ptr<ImageCube> Create(const Node& node);
30
41 static std::shared_ptr<ImageCube>
42 Create(const VirtualPath& assetPath, const std::string& fileSuffix, VkFilter filter = VK_FILTER_LINEAR,
43 VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, bool anisotropic = true,
44 bool mipmap = true);
45
56 explicit ImageCube(const VirtualPath& assetPath, std::string fileSuffix = ".png",
57 VkFilter filter = VK_FILTER_LINEAR,
58 VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
59 bool anisotropic = true, bool mipmap = true, bool load = true);
60
73 explicit ImageCube(const glm::uvec2& extent, VkFormat format = VK_FORMAT_R8G8B8A8_UNORM,
74 VkImageLayout layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
75 VkImageUsageFlags usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT,
76 VkFilter filter = VK_FILTER_LINEAR,
77 VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
78 VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT, bool anisotropic = false,
79 bool mipmap = false);
80
93 explicit ImageCube(std::unique_ptr<Bitmap>&& bitmap, VkFormat format = VK_FORMAT_R8G8B8A8_UNORM,
94 VkImageLayout layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
95 VkImageUsageFlags usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT,
96 VkFilter filter = VK_FILTER_LINEAR,
97 VkSamplerAddressMode addressMode = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
98 VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT, bool anisotropic = false,
99 bool mipmap = false);
100
106 std::unique_ptr<Bitmap> GetBitmap(uint32_t mipLevel = 0) const;
107
114 void SetPixels(const uint8_t* pixels, uint32_t layerCount, uint32_t baseArrayLayer);
115
116 std::type_index GetTypeIndex() const override
117 {
118 return typeid(ImageCube);
119 }
120
121 const VirtualPath& GetAssetPath() const
122 {
123 return m_AssetPath;
124 }
125 const std::string& GetFileSuffix() const
126 {
127 return m_FileSuffix;
128 }
129 const std::vector<std::string>& GetFileSides() const
130 {
131 return m_FileSides;
132 }
133 bool IsAnisotropic() const
134 {
135 return m_Anisotropic;
136 }
137 bool IsMipmap() const
138 {
139 return m_Mipmap;
140 }
141 uint32_t GetComponents() const
142 {
143 return m_Components;
144 }
145
146 private:
147 friend const Node& operator>>(const Node& node, ImageCube& image);
148 friend Node& operator<<(Node& node, const ImageCube& image);
149
150 void Load(std::unique_ptr<Bitmap> loadBitmap = nullptr);
151
152 private:
153 VirtualPath m_AssetPath;
154 std::string m_FileSuffix;
156 std::vector<std::string> m_FileSides = { "Right", "Left", "Top", "Bottom", "Back", "Front" };
157
158 bool m_Anisotropic;
159 bool m_Mipmap;
160 uint32_t m_Components = 0;
161 };
162} // namespace PixelBullet
Resource that represents a cubemap image.
Definition ImageCube.hpp:22
static std::shared_ptr< ImageCube > Create(const Node &node)
Definition ImageCube.cpp:12
std::unique_ptr< Bitmap > GetBitmap(uint32_t mipLevel=0) const
Definition ImageCube.cpp:80
void SetPixels(const uint8_t *pixels, uint32_t layerCount, uint32_t baseArrayLayer)
Definition ImageCube.cpp:98
ImageCube(const VirtualPath &assetPath, std::string fileSuffix=".png", VkFilter filter=VK_FILTER_LINEAR, VkSamplerAddressMode addressMode=VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, bool anisotropic=true, bool mipmap=true, bool load=true)
Definition ImageCube.cpp:36
std::type_index GetTypeIndex() const override
Returns the type index of the resource.
Definition ImageCube.hpp:116
A representation of a Vulkan image, sampler, and view.
Definition Image.hpp:18
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition Node.hpp:51
Base class for managed resources.
Definition Resource.hpp:11
Definition VirtualPath.hpp:11