-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrxTexture.hpp
More file actions
71 lines (55 loc) · 2.16 KB
/
PrxTexture.hpp
File metadata and controls
71 lines (55 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include "PrxDevice.hpp"
#include <string>
#include <memory>
#define TEXTURE_ARRAY_SIZE 8
namespace prx {
class PrxTexture
{
public:
// next available texture id
// note: this ID system is incredibly rudamentary, and will likely be replaced
// another potential way is to hash the id, likely based on the
// texture's filepath and a few other variables
// Do that later, though.
static unsigned int next_id;
PrxTexture(PrxDevice& device, const std::string& filepath);
PrxTexture(PrxDevice& device, VkFormat format, VkExtent3D extent,
VkImageUsageFlags usage, VkSampleCountFlagBits);
~PrxTexture();
// delete the copy constructors
PrxTexture(const PrxTexture&) = delete;
PrxTexture& operator=(const PrxTexture&) = delete;
PrxTexture(PrxTexture&&) = delete;
PrxTexture& operator=(PrxTexture&&) = delete;
VkSampler getSampler() const { return texSampler; };
VkImage getImage() const { return texImage; };
VkImageView getImageView() const { return texImageView; };
VkImageLayout getImageLayout() const { return texImageLayout; };
VkDescriptorImageInfo getImageInfo() const { return texImageDescriptor; };
VkFormat getFormat() const{ return texFormat; };
VkExtent3D getExtent() const { return texExtent; };
unsigned int getTextureID() { return id; };
void updateDescriptor();
void transitionLayout(VkCommandBuffer commandBuffer, VkImageLayout oldLayout, VkImageLayout newLayout);
static std::unique_ptr<PrxTexture> makeTextureFromFile(
PrxDevice& device, const std::string& filepath);
private:
void createTextureImage(const std::string& filepath);
void createTextureImageView(VkImageViewType viewType);
void createTextureSampler();
void assignID();
void generateMipmaps();
unsigned int id;
uint32_t mipLevels{ 1 }, layerCount{ 1 };
PrxDevice& prxDevice;
VkSampler texSampler = nullptr;
VkImage texImage = nullptr;
VkDeviceMemory texImageMemory = nullptr;
VkImageView texImageView = nullptr; // image views provide metadata for an image, as Vulkan does not access images direction
VkDescriptorImageInfo texImageDescriptor;
VkImageLayout texImageLayout;
VkFormat texFormat;
VkExtent3D texExtent;
};
}