Now properly loads internal textures(jpg) in 3D models

This commit is contained in:
Antoine Pilote
2023-09-17 20:15:23 -04:00
parent aa899f044f
commit 6c4dea0ddb
3 changed files with 23 additions and 17 deletions

View File

@@ -522,9 +522,19 @@ namespace Nuake
uint32_t textureIndex = std::atoi(String::Split(path, '*')[1].c_str());
const aiTexture* aitexture = scene->GetEmbeddedTexture(path.c_str());
Vector2 textureSize = Vector2(aitexture->mWidth, aitexture->mHeight);
auto texture = CreateRef<Texture>(textureSize, (unsigned char*)aitexture->pcData, textureSize.x);
return texture;
Ref<Texture> nuakeTexture;
if (aitexture->mHeight == 0)
{
// We are using a compression like jpeg, where width is the size of the buffer in bytes.
nuakeTexture = CreateRef<Texture>((unsigned char*)aitexture->pcData, aitexture->mWidth);
}
else
{
Vector2 textureSize = Vector2(aitexture->mWidth, aitexture->mHeight);
nuakeTexture = CreateRef<Texture>((unsigned char*)aitexture->pcData, textureSize.x);
}
return nuakeTexture;
}
std::string texturePath = modelDir + path;