SpiecsEngine
 
Loading...
Searching...
No Matches
Transcoder.h
Go to the documentation of this file.
1/**
2* @file Transcoder.h.
3* @brief The Transcoder Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include <ktxvulkan.h>
10
11namespace Spices {
12
13 /**
14 * @brief Transcoder of Texture Container format and Transform format and GPU compress format.
15 */
17 {
18 public:
19
20 /**
21 * @brief Constructor Function.
22 */
23 Transcoder() = default;
24
25 /**
26 * @brief Destructor Function.
27 */
28 virtual ~Transcoder() = default;
29
30 /**
31 * @brief Init basisu.
32 */
33 static void Init();
34
35 /**
36 * @brief Create a ktx2 Texture.
37 * @param[in] width .
38 * @param[in] height .
39 * @return Returns ktxTexture2* .
40 */
41 static ktxTexture2* CreateKTX2Texture(int& width, int& height);
42
43 /**
44 * @brief Write Data to ktxtexture.
45 * @param[in] texture ktxtexture.
46 * @param[in] mipLevel .
47 * @param[in] data .
48 * @param[in] size data size.
49 * @return Returns true if succeed.
50 */
51 static bool WriteData(ktxTexture2* texture, uint32_t mipLevel, const unsigned char* data, uint32_t size);
52
53 /**
54 * @brief Save a src image data to a ktx file.
55 * @param[in] texture ktxtexture.
56 * @param[in] filePath saved ktx file path.
57 * @return Returns true if finish all task.
58 */
59 static bool SaveToDisk(ktxTexture2* texture, const std::string& filePath);
60
61 /**
62 * @brief Load a ktx file.
63 * @param[in] filePath ktx file path.
64 * @param[in,out] texture ktx file.
65 * @return Returns true if finish all task.
66 */
67 static bool LoadFromKTX(const std::string& filePath, ktxTexture2*& texture);
68
69 /**
70 * @brief Destroy a ktx file.
71 * @param[in] texture ktx file.
72 * @return Returns true if succeed.
73 */
74 static bool DestroyktxTexture2(ktxTexture2* texture);
75
76 /**
77 * @brief Get Mipmap data offset.
78 * @param[in] texture ktx file.
79 * @param[in] mipLevel .
80 * @return Returns Mipmap data offset.
81 */
83
84 private:
85
86 /**
87 * @brief Check if the device supports sampling and transfers for the selected image.
88 * @param[in] format .
89 * @return Returns true if succeed.
90 */
91 static bool FormatSupported(VkFormat format);
92
93 /**
94 * @brief Get available gpu compress format.
95 * @return Returns available gpu compress format.
96 */
98 };
99
100}
#define SPICES_PROFILE_ZONE
Texture2DCube Class. This class defines the basic behaves of Texture2DCube.
Texture2D Class. This class defines the basic behaves of texture2D.
Definition Texture2D.h:20
static void Load(const std::string &fileName, Texture2DCube *outTexture)
Load image to a Texture2DCube object.
static void Load(const std::string &fileName, Texture2D *outTexture)
Load image to a Texture2D object.
static bool LoadSrc(const std::string &fileName, const std::string &it, Texture2D *outTexture, bool isCreateCompressTexture=true)
Function of load a src file.
static bool LoadBin(const std::string &fileName, const std::string &it, Texture2D *outTexture)
Function of load a ktx file.
TextureLoader Class. This class only defines static function for load data from image file.
static ktx_transcode_fmt_e GetAvailableTargetFormats()
Get available gpu compress format.
static ktx_size_t GetMipmapOffset(ktxTexture2 *texture, uint32_t mipLevel)
Get Mipmap data offset.
static bool FormatSupported(VkFormat format)
Check if the device supports sampling and transfers for the selected image.
Transcoder()=default
Constructor Function.
static bool SaveToDisk(ktxTexture2 *texture, const std::string &filePath)
Save a src image data to a ktx file.
static void Init()
Init basisu.
virtual ~Transcoder()=default
Destructor Function.
static bool WriteData(ktxTexture2 *texture, uint32_t mipLevel, const unsigned char *data, uint32_t size)
Write Data to ktxtexture.
static ktxTexture2 * CreateKTX2Texture(int &width, int &height)
Create a ktx2 Texture.
static bool DestroyktxTexture2(ktxTexture2 *texture)
Destroy a ktx file.
static bool LoadFromKTX(const std::string &filePath, ktxTexture2 *&texture)
Load a ktx file.
Transcoder of Texture Container format and Transform format and GPU compress format.
Definition Transcoder.h:17
This Class is a Wrapper of VulkanBuffer.
static VulkanState & GetState()
Get VulkanState in use.
This class defines the render backend behaves of Vulkan.
const std::string binTexturePath
const std::string defaultTexturePath
Const variable: Original Image File Path.