From b8f67c628553cb9199f51efc9b20eb5991d58e8f Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 11 Jun 2022 23:24:13 +0200 Subject: 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 --- examples/models/models_loading.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'examples/models/models_loading.c') diff --git a/examples/models/models_loading.c b/examples/models/models_loading.c index 7d4543cd..ee3811ee 100644 --- a/examples/models/models_loading.c +++ b/examples/models/models_loading.c @@ -67,35 +67,34 @@ int main(void) // Load new models/textures 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], ".obj") || - IsFileExtension(droppedFiles[0], ".gltf") || - IsFileExtension(droppedFiles[0], ".glb") || - IsFileExtension(droppedFiles[0], ".vox") || - IsFileExtension(droppedFiles[0], ".iqm")) // Model file formats supported + if (IsFileExtension(droppedFiles.paths[0], ".obj") || + IsFileExtension(droppedFiles.paths[0], ".gltf") || + IsFileExtension(droppedFiles.paths[0], ".glb") || + IsFileExtension(droppedFiles.paths[0], ".vox") || + IsFileExtension(droppedFiles.paths[0], ".iqm")) // Model file formats supported { - UnloadModel(model); // Unload previous model - model = LoadModel(droppedFiles[0]); // Load new model + UnloadModel(model); // Unload previous model + model = LoadModel(droppedFiles.paths[0]); // Load new model model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set current map diffuse texture bounds = GetMeshBoundingBox(model.meshes[0]); // TODO: Move camera position from target enough distance to visualize model properly } - else if (IsFileExtension(droppedFiles[0], ".png")) // Texture file formats supported + else if (IsFileExtension(droppedFiles.paths[0], ".png")) // Texture file formats supported { // Unload current model texture and load new one UnloadTexture(texture); - texture = LoadTexture(droppedFiles[0]); + texture = LoadTexture(droppedFiles.paths[0]); model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; } } - UnloadDroppedFiles(); // Clear internal buffers + UnloadDroppedFiles(droppedFiles); // Unload filepaths from memory } // Select model on mouse click -- cgit v1.2.3