WARNING: BREAKING: REDESIGNED: Filepath loading API

REDESIGNED: `LoadDirectoryFiles()`
ADDED: `LoadDirectoryFilesEx()`
REDESIGNED: `LoadDroppedFiles()`
ADDED: `IsPathFile()`

This BIG BREAKING change simplifies the functions and gives more control to the user:
 - A new `struct FilePathList` has been added to avoid exposing complex pointers.
 - User is responsible of memory loading/unloading
 - Filepaths loading support recursive directories and file extension filters
This commit is contained in:
Ray
2022-06-11 23:24:13 +02:00
parent f7744404d6
commit b8f67c6285
7 changed files with 247 additions and 100 deletions

View File

@@ -97,18 +97,17 @@ int main(void)
// Load new cubemap texture on drag&drop
if (IsFileDropped())
{
int count = 0;
char **droppedFiles = LoadDroppedFiles(&count);
FilePathList droppedFiles = LoadDroppedFiles();
if (count == 1) // Only support one file dropped
if (droppedFiles.count == 1) // Only support one file dropped
{
if (IsFileExtension(droppedFiles[0], ".png;.jpg;.hdr;.bmp;.tga"))
if (IsFileExtension(droppedFiles.paths[0], ".png;.jpg;.hdr;.bmp;.tga"))
{
// Unload current cubemap texture and load new one
UnloadTexture(skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture);
if (useHDR)
{
Texture2D panorama = LoadTexture(droppedFiles[0]);
Texture2D panorama = LoadTexture(droppedFiles.paths[0]);
// Generate cubemap from panorama texture
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
@@ -116,7 +115,7 @@ int main(void)
}
else
{
Image img = LoadImage(droppedFiles[0]);
Image img = LoadImage(droppedFiles.paths[0]);
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = LoadTextureCubemap(img, CUBEMAP_LAYOUT_AUTO_DETECT);
UnloadImage(img);
}
@@ -125,7 +124,7 @@ int main(void)
}
}
UnloadDroppedFiles(); // Clear internal buffers
UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory
}
//----------------------------------------------------------------------------------