Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
Image.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 {
11  class Image : public Resource
12  {
13  public:
14  explicit Image(Guid t_ID, void* t_Data = nullptr);
15  virtual ~Image();
16 
17  FORCEINLINE UINT32 GetWidth() const { return m_Width; }
18  FORCEINLINE UINT32 GetHeight() const { return m_Height; }
19  FORCEINLINE INT32 GetChannels() const { return m_Channels; }
20 
21  FORCEINLINE const VkImage& GetVkImage() const { return m_vVkImage; }
22  FORCEINLINE const VkImageView& GetVkImageView() const { return m_ImageView; }
23  FORCEINLINE const VkSampler& GetSampler() const { return m_TextureSampler; }
24 
30  UINT64 GetImageSize() const { return m_Width * m_Height * 4; }
31 
35  void Release();
36 
37  private:
38 
42  void LoadVulkanImage();
43 
47  void CreateImageView();
48 
49  void CreateTextureSampler();
50 
51  void CopyBufferToImage(VkBuffer t_Buffer);
52 
55 
58 
61 
63  VkImage m_vVkImage;
64 
66  VkImageView m_ImageView;
67 
68  VkSampler m_TextureSampler;
69 
71  VkDeviceMemory m_VkMemory;
72  };
73 } // namespace Fling
An image represents a 2D file that has data about each pixel in the image.
Definition: Image.h:11
void CopyBufferToImage(VkBuffer t_Buffer)
Definition: Image.cpp:80
UINT32 m_Width
Width of this image.
Definition: Image.h:54
VkSampler m_TextureSampler
Definition: Image.h:68
uint64_t UINT64
Definition: FlingTypes.h:11
Base class that represents a loaded resource in the engine.
Definition: Resource.h:11
void CreateTextureSampler()
Definition: Image.cpp:123
virtual ~Image()
Definition: Image.cpp:189
VkDeviceMemory m_VkMemory
The Vulkan memory resource for this image.
Definition: Image.h:71
FORCEINLINE const VkImage & GetVkImage() const
Definition: Image.h:21
UINT64 GetImageSize() const
Get the Image Size object (width * height * 4) Multiply by 4 because the pixel is laid out row by row...
Definition: Image.h:30
INT32 m_Channels
The color channels of this image.
Definition: Image.h:60
VkImage m_vVkImage
The Vulkan image data.
Definition: Image.h:63
FORCEINLINE INT32 GetChannels() const
Definition: Image.h:19
int32_t INT32
Definition: FlingTypes.h:15
void Release()
Release the Vulkan resources of this image.
Definition: Image.cpp:155
FORCEINLINE UINT32 GetHeight() const
Definition: Image.h:18
FORCEINLINE const VkSampler & GetSampler() const
Definition: Image.h:23
entt::hashed_string Guid
Definition: FlingTypes.h:21
VkImageView m_ImageView
The view of this image for the swap chain.
Definition: Image.h:66
void CreateImageView()
Create a Image View object that is needed to sample this image from the swap chain.
Definition: Image.cpp:113
FORCEINLINE const VkImageView & GetVkImageView() const
Definition: Image.h:22
UINT32 m_Height
Height of this image.
Definition: Image.h:57
void LoadVulkanImage()
Loads the Vulkan resources needed for this image.
Definition: Image.cpp:27
uint32_t UINT32
Definition: FlingTypes.h:10
Image(Guid t_ID, void *t_Data=nullptr)
Definition: Image.cpp:16
Definition: Engine.h:13
FORCEINLINE UINT32 GetWidth() const
Definition: Image.h:17