Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue with texture files with extensions specified in material defintion files not loading. #23

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions RT/RTmaterials.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,17 @@ static int RT_LoadMaterialTexturesFromPaths(uint16_t bm_index, RT_Material *mate
RT_TextureFormat format = g_rt_material_texture_slot_formats[i];
bool is_srgb = (format == RT_TextureFormat_RGBA8_SRGB);

char* dds_file = RT_ArenaPrintF(&g_thread_arena, "assets/textures/%s.dds", paths->textures[i]);
char* dds_file = NULL;

// check for dds extension to already be part of texture path.
if (strstr(paths->textures[i], ".dds"))
{
dds_file = RT_ArenaPrintF(&g_thread_arena, "assets/textures/%s", paths->textures[i]);
}
else
{
dds_file = RT_ArenaPrintF(&g_thread_arena, "assets/textures/%s.dds", paths->textures[i]);
}

// TODO(daniel): It's dumb that RT_ArenaPrintF doesn't return an RT_String
RT_Image image = RT_LoadDDSFromDisk(&g_thread_arena, RT_StringFromCString(dds_file));
Expand All @@ -195,7 +205,17 @@ static int RT_LoadMaterialTexturesFromPaths(uint16_t bm_index, RT_Material *mate
{
RT_ArenaMemoryScope(&g_thread_arena)
{
char* file = RT_ArenaPrintF(&g_thread_arena, "assets/textures/%s.png", paths->textures[i]);
char* file = NULL;

// check for png extension to already be part of texture path.
if (strstr(paths->textures[i], ".png"))
{
file = RT_ArenaPrintF(&g_thread_arena, "assets/textures/%s", paths->textures[i]);
}
else
{
file = RT_ArenaPrintF(&g_thread_arena, "assets/textures/%s.png", paths->textures[i]);
}

RT_TextureFormat format = g_rt_material_texture_slot_formats[i];

Expand Down