mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-15 15:58:14 +00:00
Added security check if file not found
This commit is contained in:
13
src/models.c
13
src/models.c
@@ -559,13 +559,23 @@ Model LoadModel(const char *fileName)
|
||||
{
|
||||
VertexData vData;
|
||||
|
||||
Model model;
|
||||
|
||||
// TODO: Initialize default data for model in case loading fails, maybe a cube?
|
||||
|
||||
if (strcmp(GetExtension(fileName),"obj") == 0) vData = LoadOBJ(fileName);
|
||||
else TraceLog(WARNING, "[%s] Model extension not recognized, it can't be loaded", fileName);
|
||||
|
||||
// NOTE: At this point we have all vertex, texcoord, normal data for the model in vData struct
|
||||
|
||||
if (vData.vertexCount == 0)
|
||||
{
|
||||
TraceLog(WARNING, "Model could not be loaded");
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: model properties (transform, texture, shader) are initialized inside rlglLoadModel()
|
||||
Model model = rlglLoadModel(vData); // Upload vertex data to GPU
|
||||
model = rlglLoadModel(vData); // Upload vertex data to GPU
|
||||
|
||||
// Now that vertex data is uploaded to GPU, we can free arrays
|
||||
// NOTE: We don't need CPU vertex data on OpenGL 3.3 or ES2
|
||||
@@ -575,6 +585,7 @@ Model LoadModel(const char *fileName)
|
||||
free(vData.texcoords);
|
||||
free(vData.normals);
|
||||
}
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
Reference in New Issue
Block a user