vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
Texture.hpp
Go to the documentation of this file.
1///
2/// @file Texture.hpp
3/// @brief This file contains the Texture class
4/// @namespace ven
5///
6
7#pragma once
8
9#include <memory>
10
12
13namespace ven {
14
15 ///
16 /// @class Texture
17 /// @brief Class for texture
18 /// @namespace ven
19 ///
20 class Texture {
21
22 public:
23
24 Texture(Device &device, const std::string &textureFilepath);
25 Texture(Device &device, VkFormat format, VkExtent3D extent, VkImageUsageFlags usage, VkSampleCountFlagBits sampleCount);
26 ~Texture();
27
28 Texture(const Texture &) = delete;
29 Texture &operator=(const Texture &) = delete;
30 Texture(Texture &&) = delete;
31 Texture &operator=(Texture &&) = delete;
32
33 void updateDescriptor();
34 void transitionLayout(VkCommandBuffer commandBuffer, VkImageLayout oldLayout, VkImageLayout newLayout) const;
35
36 [[nodiscard]] VkImageView imageView() const { return m_textureImageView; }
37 [[nodiscard]] VkSampler sampler() const { return m_textureSampler; }
38 [[nodiscard]] VkImage getImage() const { return m_textureImage; }
39 [[nodiscard]] VkImageView getImageView() const { return m_textureImageView; }
40 [[nodiscard]] VkDescriptorImageInfo getImageInfo() const { return m_descriptor; }
41 [[nodiscard]] VkImageLayout getImageLayout() const { return m_textureLayout; }
42 [[nodiscard]] VkExtent3D getExtent() const { return m_extent; }
43 [[nodiscard]] VkFormat getFormat() const { return m_format; }
44
45 private:
46
47 void createTextureImage(const std::string &filepath);
48 void createTextureImageView(VkImageViewType viewType);
50
51 VkDescriptorImageInfo m_descriptor{};
53 VkImage m_textureImage = nullptr;
54 VkDeviceMemory m_textureImageMemory = nullptr;
55 VkImageView m_textureImageView = nullptr;
56 VkSampler m_textureSampler = nullptr;
57 VkFormat m_format;
58 VkImageLayout m_textureLayout{};
59 uint32_t m_mipLevels{1};
60 uint32_t m_layerCount{1};
61 VkExtent3D m_extent{};
62
63 }; // class Texture
64
65} // namespace ven
This file contains the Device class.
Class for device.
Definition Device.hpp:35
Class for texture.
Definition Texture.hpp:20
void transitionLayout(VkCommandBuffer commandBuffer, VkImageLayout oldLayout, VkImageLayout newLayout) const
Definition texture.cpp:239
Device & m_device
Definition Texture.hpp:52
VkSampler m_textureSampler
Definition Texture.hpp:56
VkDeviceMemory m_textureImageMemory
Definition Texture.hpp:54
VkDescriptorImageInfo getImageInfo() const
Definition Texture.hpp:40
VkImage m_textureImage
Definition Texture.hpp:53
VkImageView imageView() const
Definition Texture.hpp:36
uint32_t m_layerCount
Definition Texture.hpp:60
VkImageView getImageView() const
Definition Texture.hpp:39
VkFormat getFormat() const
Definition Texture.hpp:43
Texture & operator=(const Texture &)=delete
void createTextureImageView(VkImageViewType viewType)
Definition texture.cpp:191
VkImageLayout getImageLayout() const
Definition Texture.hpp:41
VkExtent3D getExtent() const
Definition Texture.hpp:42
VkExtent3D m_extent
Definition Texture.hpp:61
void updateDescriptor()
Definition texture.cpp:97
VkDescriptorImageInfo m_descriptor
Definition Texture.hpp:51
void createTextureImage(const std::string &filepath)
Definition texture.cpp:104
VkImageView m_textureImageView
Definition Texture.hpp:55
Texture & operator=(Texture &&)=delete
Texture(Texture &&)=delete
uint32_t m_mipLevels
Definition Texture.hpp:59
void createTextureSampler()
Definition texture.cpp:209
VkSampler sampler() const
Definition Texture.hpp:37
VkFormat m_format
Definition Texture.hpp:57
VkImage getImage() const
Definition Texture.hpp:38
Texture(Device &device, const std::string &textureFilepath)
Definition texture.cpp:7
Texture(const Texture &)=delete
VkImageLayout m_textureLayout
Definition Texture.hpp:58