SpiecsEngine
 
Loading...
Searching...
No Matches

◆ Load() [1/2]

void Spices::TextureLoader::Load ( const std::string & fileName,
Texture2D * outTexture )
static

Load image to a Texture2D object.

Parameters
[in]fileNameImage path.
[in,out]outTextureTexture2D pointer, only pass this to it. Feel free for using row pointer here, it's very safe, for this API only called during Material.

Temp texture for create ktxtexture.

Temp texture for create ktxtexture.

Definition at line 28 of file TextureLoader.cpp.

29 {
31
32 std::filesystem::path path(fileName);
33 if (path.is_absolute())
34 {
35 if (path.extension().string() == "ktx")
36 {
37 LoadBin(fileName, "", outTexture);
38 }
39 else
40 {
41 LoadSrc(fileName, "", outTexture, false);
42 }
43
44 return;
45 }
46
48 fileName,
49 [&](const std::string& it) {
50 LoadBin(fileName, it, outTexture);
51 },
52 [&](const std::string& it) {
53
57 std::unique_ptr<Texture2D> texture = std::make_unique<Texture2D>();
58 LoadSrc(fileName, it, texture.get());
59 LoadBin(fileName, it, outTexture);
60 }
61 );
62 }
#define SPICES_PROFILE_ZONE
static bool LoadSrc(const std::string &fileName, const std::string &it, Texture2D *outTexture, bool isCreateCompressTexture=true)
Function of load a src file.
static bool SearchFile(const std::string &fileName, std::function< void(const std::string &)> binF, std::function< void(const std::string &)> srcF)
Search texture file and load.
static bool LoadBin(const std::string &fileName, const std::string &it, Texture2D *outTexture)
Function of load a ktx file.

References LoadBin(), and LoadSrc().

Referenced by Spices::Texture2D::Texture2D().