| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

HDRImage.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "Resource.h"
4 #include "stb_image.h"
5
6 namespace Fling
7 {
8 class LogicalDevice;
13 class HDRImage : public Resource
14 {
15 public:
16 static std::shared_ptr<Fling::HDRImage> Create(Guid t_ID, LogicalDevice* t_dev, void* t_Data = nullptr);
17
18 explicit HDRImage(Guid t_ID, LogicalDevice* t_dev, void* t_Data = nullptr);
19 virtual ~HDRImage();
20
21 FORCEINLINE UINT32 GetWidth() const { return m_Width; }
22 FORCEINLINE UINT32 GetHeight() const { return m_Height; }
23 FORCEINLINE INT32 GetChannels() const { return m_Channels; }
24 FORCEINLINE UINT32 GetMipLevels() const { return m_MipLevels; }
25
26 FORCEINLINE const VkImage& GetVkImage() const { return m_Image; }
27 FORCEINLINE const VkImageView& GetVkImageView() const { return m_ImageView; }
28 FORCEINLINE const VkSampler& GetSampler() const { return m_TextureSampler; }
29 FORCEINLINE VkDescriptorImageInfo* GetDescriptorInfo() { return &m_ImageInfo; }
30 FORCEINLINE const VkFormat& GetVkImageFormat() const { return m_Format; }
31
38 UINT64 GetImageSize() const { return m_Width * m_Height * 6; }
44 const float* GetPixelData() const { return m_PixelData; }
45
46 void Release();
47
48 private:
49 void LoadVulkanImage();
50
51 void CreateImageView();
52
53 void CreateTextureSampler();
54
55 void CopyBufferToImage(VkBuffer t_Buffer);
56
57 void GenerateMipMaps(VkFormat t_ImageFormat);
58 const LogicalDevice* m_Device;
59 VkImage m_Image;
60
61 VkImageView m_ImageView;
62
63 VkSampler m_TextureSampler;
64
65 VkDeviceMemory m_Memory;
66
67 VkDescriptorImageInfo m_ImageInfo = {};
68
69 float* m_PixelData;
70
71 VkFormat m_Format = VK_FORMAT_R16G16B16_SFLOAT;
72
73 UINT32 m_Width = 0;
74
75 UINT32 m_Height = 0;
76
77 UINT32 m_MipLevels = 0;
78
79 INT32 m_Channels = 0;
80 };
81 }
Fling::HDRImage::GetWidth
FORCEINLINE UINT32 GetWidth() const
Definition: HDRImage.h:21
Fling::HDRImage::m_Width
UINT32 m_Width
Definition: HDRImage.h:73
Fling::HDRImage::GetChannels
FORCEINLINE INT32 GetChannels() const
Definition: HDRImage.h:23
UINT64
uint64_t UINT64
Definition: FlingTypes.h:14
Fling::HDRImage::GetPixelData
const float * GetPixelData() const
Get the Pixel Data as signed floats.
Definition: HDRImage.h:44
Fling::HDRImage::GenerateMipMaps
void GenerateMipMaps(VkFormat t_ImageFormat)
Definition: HDRImage.cpp:156
Fling::HDRImage::m_ImageInfo
VkDescriptorImageInfo m_ImageInfo
Definition: HDRImage.h:67
Fling::HDRImage::GetVkImageView
FORCEINLINE const VkImageView & GetVkImageView() const
Definition: HDRImage.h:27
Fling::HDRImage::GetVkImage
FORCEINLINE const VkImage & GetVkImage() const
Definition: HDRImage.h:26
Fling::Resource
Base class that represents a loaded resource in the engine.
Definition: Resource.h:11
Fling::HDRImage::CreateImageView
void CreateImageView()
Definition: HDRImage.cpp:99
Fling::HDRImage::m_ImageView
VkImageView m_ImageView
Definition: HDRImage.h:61
Fling::HDRImage::CreateTextureSampler
void CreateTextureSampler()
Definition: HDRImage.cpp:110
Fling::LogicalDevice
A logical device represents the application view of the device.
Definition: LogicalDevice.h:13
Fling::HDRImage::LoadVulkanImage
void LoadVulkanImage()
Definition: HDRImage.cpp:37
Fling::HDRImage::GetHeight
FORCEINLINE UINT32 GetHeight() const
Definition: HDRImage.h:22
Fling::HDRImage::~HDRImage
virtual ~HDRImage()
Definition: HDRImage.cpp:32
Fling::HDRImage::GetDescriptorInfo
FORCEINLINE VkDescriptorImageInfo * GetDescriptorInfo()
Definition: HDRImage.h:29
Resource.h
Fling::HDRImage::GetVkImageFormat
FORCEINLINE const VkFormat & GetVkImageFormat() const
Definition: HDRImage.h:30
Fling::HDRImage::GetImageSize
UINT64 GetImageSize() const
Get the Image Size object Multiply by 2 * 3 because there are 3 channels that are 2 bytes each Each c...
Definition: HDRImage.h:38
INT32
int32_t INT32
Definition: FlingTypes.h:18
Fling::HDRImage::m_Device
const LogicalDevice * m_Device
Definition: HDRImage.h:58
Fling::HDRImage::m_Image
VkImage m_Image
Definition: HDRImage.h:59
Fling::Guid
entt::hashed_string Guid
Definition: FlingTypes.h:26
Fling::HDRImage::Create
static std::shared_ptr< Fling::HDRImage > Create(Guid t_ID, LogicalDevice *t_dev, void *t_Data=nullptr)
Definition: HDRImage.cpp:12
Fling::HDRImage::m_Format
VkFormat m_Format
Definition: HDRImage.h:71
Fling::HDRImage::HDRImage
HDRImage(Guid t_ID, LogicalDevice *t_dev, void *t_Data=nullptr)
Definition: HDRImage.cpp:17
Fling::HDRImage::GetSampler
FORCEINLINE const VkSampler & GetSampler() const
Definition: HDRImage.h:28
Fling::HDRImage::m_Height
UINT32 m_Height
Definition: HDRImage.h:75
Fling::HDRImage
Loads image R16G16B16_SFLOAT file formats exmplae file format : .hdr.
Definition: HDRImage.h:13
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Fling
Definition: Engine.h:29
Fling::HDRImage::m_PixelData
float * m_PixelData
Definition: HDRImage.h:69
Fling::HDRImage::m_Memory
VkDeviceMemory m_Memory
Definition: HDRImage.h:65
Fling::HDRImage::m_Channels
INT32 m_Channels
Definition: HDRImage.h:79
Fling::HDRImage::m_TextureSampler
VkSampler m_TextureSampler
Definition: HDRImage.h:63
Fling::HDRImage::GetMipLevels
FORCEINLINE UINT32 GetMipLevels() const
Definition: HDRImage.h:24
Fling::HDRImage::m_MipLevels
UINT32 m_MipLevels
Definition: HDRImage.h:77
Fling::HDRImage::CopyBufferToImage
void CopyBufferToImage(VkBuffer t_Buffer)
Definition: HDRImage.cpp:123
Fling::HDRImage::Release
void Release()
Definition: HDRImage.cpp:254