diff options
| author | Ray <raysan5@gmail.com> | 2019-03-29 20:22:30 +0100 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2019-03-29 20:22:30 +0100 |
| commit | a197f40bb4bd5a644ad54bef756d7f435977df9d (patch) | |
| tree | 0f29212deea83f760b102937ff1630dfff3e17b9 /src | |
| parent | 6f371dab0807ccc81038b3eccfb9c6090ec07d16 (diff) | |
| download | raylib-a197f40bb4bd5a644ad54bef756d7f435977df9d.tar.gz raylib-a197f40bb4bd5a644ad54bef756d7f435977df9d.zip | |
Default to white cube mesh if not loaded
Diffstat (limited to 'src')
| -rw-r--r-- | src/models.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/models.c b/src/models.c index 6f3fa73f..2893fd2f 100644 --- a/src/models.c +++ b/src/models.c @@ -630,8 +630,25 @@ Model LoadModel(const char *fileName) if (IsFileExtension(fileName, ".iqm")) model = LoadIQM(fileName); #endif - if (model.meshCount == 0) TraceLog(LOG_WARNING, "[%s] No meshes can be loaded", fileName); - if (model.materialCount == 0) TraceLog(LOG_WARNING, "[%s] No materials can be loaded", fileName); + if (model.meshCount == 0) + { + TraceLog(LOG_WARNING, "[%s] No meshes can be loaded, default to cube mesh", fileName); + + model.meshCount = 1; + model.meshes = (Mesh *)malloc(model.meshCount*sizeof(Mesh)); + model.meshes[0] = GenMeshCube(1.0f, 1.0f, 1.0f); + } + + if (model.materialCount == 0) + { + TraceLog(LOG_WARNING, "[%s] No materials can be loaded, default to white material", fileName); + + model.materialCount = 1; + model.materials = (Material *)malloc(model.materialCount*sizeof(Material)); + model.materials[0] = LoadMaterialDefault(); + + model.meshMaterial = (int *)calloc(model.meshCount, sizeof(int)); + } return model; } |
