Skip to content

Commit

Permalink
Replace TraceLog() function by TRACELOG macro
Browse files Browse the repository at this point in the history
Added SUPPORT_TRACELOG_DEBUG config
  • Loading branch information
raysan5 committed Feb 3, 2020
1 parent 40b73a8 commit cde26c7
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 389 deletions.
5 changes: 3 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@
//------------------------------------------------------------------------------------
// Module: utils - Configuration Flags
//------------------------------------------------------------------------------------
// Show TraceLog() output messages
// Show TRACELOG() output messages
// NOTE: By default LOG_DEBUG traces not shown
#define SUPPORT_TRACELOG 1
#define SUPPORT_TRACELOG 1
//#define SUPPORT_TRACELOG_DEBUG 1


#endif //defined(RAYLIB_CMAKE)
178 changes: 89 additions & 89 deletions src/core.c

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions src/models.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,10 @@ Model LoadModel(const char *fileName)
model.meshCount = 1;
model.meshes = (Mesh *)RL_CALLOC(model.meshCount, sizeof(Mesh));
#if defined(SUPPORT_MESH_GENERATION)
TraceLog(LOG_WARNING, "[%s] No meshes can be loaded, default to cube mesh", fileName);
TRACELOG(LOG_WARNING, "[%s] No meshes can be loaded, default to cube mesh", fileName);
model.meshes[0] = GenMeshCube(1.0f, 1.0f, 1.0f);
#else
TraceLog(LOG_WARNING, "[%s] No meshes can be loaded, and can't create a default mesh. The raylib mesh generation is not supported (SUPPORT_MESH_GENERATION).", fileName);
TRACELOG(LOG_WARNING, "[%s] No meshes can be loaded, and can't create a default mesh. The raylib mesh generation is not supported (SUPPORT_MESH_GENERATION).", fileName);
#endif
}
else
Expand All @@ -681,7 +681,7 @@ Model LoadModel(const char *fileName)

if (model.materialCount == 0)
{
TraceLog(LOG_WARNING, "[%s] No materials can be loaded, default to white material", fileName);
TRACELOG(LOG_WARNING, "[%s] No materials can be loaded, default to white material", fileName);

model.materialCount = 1;
model.materials = (Material *)RL_CALLOC(model.materialCount, sizeof(Material));
Expand Down Expand Up @@ -735,7 +735,7 @@ void UnloadModel(Model model)
RL_FREE(model.bones);
RL_FREE(model.bindPose);

TraceLog(LOG_INFO, "Unloaded model data from RAM and VRAM");
TRACELOG(LOG_INFO, "Unloaded model data from RAM and VRAM");
}

// Load meshes from model file
Expand Down Expand Up @@ -809,8 +809,8 @@ void ExportMesh(Mesh mesh, const char *fileName)
}
else if (IsFileExtension(fileName, ".raw")) { } // TODO: Support additional file formats to export mesh vertex data

if (success) TraceLog(LOG_INFO, "Mesh exported successfully: %s", fileName);
else TraceLog(LOG_WARNING, "Mesh could not be exported.");
if (success) TRACELOG(LOG_INFO, "Mesh exported successfully: %s", fileName);
else TRACELOG(LOG_WARNING, "Mesh could not be exported.");
}

// Load materials from model file
Expand All @@ -828,15 +828,15 @@ Material *LoadMaterials(const char *fileName, int *materialCount)

int result = tinyobj_parse_mtl_file(&mats, &count, fileName);
if (result != TINYOBJ_SUCCESS) {
TraceLog(LOG_WARNING, "[%s] Could not parse Materials file", fileName);
TRACELOG(LOG_WARNING, "[%s] Could not parse Materials file", fileName);
}

// TODO: Process materials to return

tinyobj_materials_free(mats, count);
}
#else
TraceLog(LOG_WARNING, "[%s] Materials file not supported", fileName);
TRACELOG(LOG_WARNING, "[%s] Materials file not supported", fileName);
#endif

// Set materials shader to default (DIFFUSE, SPECULAR, NORMAL)
Expand Down Expand Up @@ -888,8 +888,8 @@ void SetMaterialTexture(Material *material, int mapType, Texture2D texture)
// Set the material for a mesh
void SetModelMeshMaterial(Model *model, int meshId, int materialId)
{
if (meshId >= model->meshCount) TraceLog(LOG_WARNING, "Mesh id greater than mesh count");
else if (materialId >= model->materialCount) TraceLog(LOG_WARNING,"Material id greater than material count");
if (meshId >= model->meshCount) TRACELOG(LOG_WARNING, "Mesh id greater than mesh count");
else if (materialId >= model->materialCount) TRACELOG(LOG_WARNING,"Material id greater than material count");
else model->meshMaterial[meshId] = materialId;
}

Expand Down Expand Up @@ -937,23 +937,23 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount)

if (!iqmFile)
{
TraceLog(LOG_ERROR, "[%s] Unable to open file", filename);
TRACELOG(LOG_ERROR, "[%s] Unable to open file", filename);
}

// Read IQM header
fread(&iqm, sizeof(IQMHeader), 1, iqmFile);

if (strncmp(iqm.magic, IQM_MAGIC, sizeof(IQM_MAGIC)))
{
TraceLog(LOG_ERROR, "Magic Number \"%s\"does not match.", iqm.magic);
TRACELOG(LOG_ERROR, "Magic Number \"%s\"does not match.", iqm.magic);
fclose(iqmFile);

return NULL;
}

if (iqm.version != IQM_VERSION)
{
TraceLog(LOG_ERROR, "IQM version %i is incorrect.", iqm.version);
TRACELOG(LOG_ERROR, "IQM version %i is incorrect.", iqm.version);
fclose(iqmFile);

return NULL;
Expand Down Expand Up @@ -2292,7 +2292,7 @@ BoundingBox MeshBoundingBox(Mesh mesh)
void MeshTangents(Mesh *mesh)
{
if (mesh->tangents == NULL) mesh->tangents = (float *)RL_MALLOC(mesh->vertexCount*4*sizeof(float));
else TraceLog(LOG_WARNING, "Mesh tangents already exist");
else TRACELOG(LOG_WARNING, "Mesh tangents already exist");

Vector3 *tan1 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3));
Vector3 *tan2 = (Vector3 *)RL_MALLOC(mesh->vertexCount*sizeof(Vector3));
Expand Down Expand Up @@ -2365,7 +2365,7 @@ void MeshTangents(Mesh *mesh)
// Load a new tangent attributes buffer
mesh->vboId[LOC_VERTEX_TANGENT] = rlLoadAttribBuffer(mesh->vaoId, LOC_VERTEX_TANGENT, mesh->tangents, mesh->vertexCount*4*sizeof(float), false);

TraceLog(LOG_INFO, "Tangents computed for mesh");
TRACELOG(LOG_INFO, "Tangents computed for mesh");
}

// Compute mesh binormals (aka bitangent)
Expand Down Expand Up @@ -2817,8 +2817,8 @@ static Model LoadOBJ(const char *fileName)
unsigned int flags = TINYOBJ_FLAG_TRIANGULATE;
int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, data, dataLength, flags);

if (ret != TINYOBJ_SUCCESS) TraceLog(LOG_WARNING, "[%s] Model data could not be loaded", fileName);
else TraceLog(LOG_INFO, "[%s] Model data loaded successfully: %i meshes / %i materials", fileName, meshCount, materialCount);
if (ret != TINYOBJ_SUCCESS) TRACELOG(LOG_WARNING, "[%s] Model data could not be loaded", fileName);
else TRACELOG(LOG_INFO, "[%s] Model data loaded successfully: %i meshes / %i materials", fileName, meshCount, materialCount);

// Init model meshes array
// TODO: Support multiple meshes... in the meantime, only one mesh is returned
Expand Down Expand Up @@ -2868,7 +2868,7 @@ static Model LoadOBJ(const char *fileName)
tinyobj_vertex_index_t idx1 = attrib.faces[3*f + 1];
tinyobj_vertex_index_t idx2 = attrib.faces[3*f + 2];

// TraceLog(LOG_DEBUG, "Face %i index: v %i/%i/%i . vt %i/%i/%i . vn %i/%i/%i\n", f, idx0.v_idx, idx1.v_idx, idx2.v_idx, idx0.vt_idx, idx1.vt_idx, idx2.vt_idx, idx0.vn_idx, idx1.vn_idx, idx2.vn_idx);
// TRACELOGD("Face %i index: v %i/%i/%i . vt %i/%i/%i . vn %i/%i/%i\n", f, idx0.v_idx, idx1.v_idx, idx2.v_idx, idx0.vt_idx, idx1.vt_idx, idx2.vt_idx, idx0.vn_idx, idx1.vn_idx, idx2.vn_idx);

// Fill vertices buffer (float) using vertex index of the face
for (int v = 0; v < 3; v++) { mesh.vertices[vCount + v] = attrib.vertices[idx0.v_idx*3 + v]; } vCount +=3;
Expand Down Expand Up @@ -2960,7 +2960,7 @@ static Model LoadOBJ(const char *fileName)
}

// NOTE: At this point we have all model data loaded
TraceLog(LOG_INFO, "[%s] Model loaded successfully in RAM (CPU)", fileName);
TRACELOG(LOG_INFO, "[%s] Model loaded successfully in RAM (CPU)", fileName);

return model;
}
Expand Down Expand Up @@ -3079,22 +3079,22 @@ static Model LoadIQM(const char *fileName)

if (iqmFile == NULL)
{
TraceLog(LOG_WARNING, "[%s] IQM file could not be opened", fileName);
TRACELOG(LOG_WARNING, "[%s] IQM file could not be opened", fileName);
return model;
}

fread(&iqm,sizeof(IQMHeader), 1, iqmFile); // Read IQM header

if (strncmp(iqm.magic, IQM_MAGIC, sizeof(IQM_MAGIC)))
{
TraceLog(LOG_WARNING, "[%s] IQM file does not seem to be valid", fileName);
TRACELOG(LOG_WARNING, "[%s] IQM file does not seem to be valid", fileName);
fclose(iqmFile);
return model;
}

if (iqm.version != IQM_VERSION)
{
TraceLog(LOG_WARNING, "[%s] IQM file version is not supported (%i).", fileName, iqm.version);
TRACELOG(LOG_WARNING, "[%s] IQM file version is not supported (%i).", fileName, iqm.version);
fclose(iqmFile);
return model;
}
Expand Down Expand Up @@ -3396,7 +3396,7 @@ static Texture LoadTextureFromCgltfImage(cgltf_image *image, const char *texPath
int i = 0;
while ((image->uri[i] != ',') && (image->uri[i] != 0)) i++;

if (image->uri[i] == 0) TraceLog(LOG_WARNING, "CGLTF Image: Invalid data URI");
if (image->uri[i] == 0) TRACELOG(LOG_WARNING, "CGLTF Image: Invalid data URI");
else
{
int size;
Expand Down Expand Up @@ -3498,7 +3498,7 @@ static Model LoadGLTF(const char *fileName)

if (gltfFile == NULL)
{
TraceLog(LOG_WARNING, "[%s] glTF file could not be opened", fileName);
TRACELOG(LOG_WARNING, "[%s] glTF file could not be opened", fileName);
return model;
}

Expand All @@ -3518,11 +3518,11 @@ static Model LoadGLTF(const char *fileName)

if (result == cgltf_result_success)
{
TraceLog(LOG_INFO, "[%s][%s] Model meshes/materials: %i/%i", fileName, (data->file_type == 2)? "glb" : "gltf", data->meshes_count, data->materials_count);
TRACELOG(LOG_INFO, "[%s][%s] Model meshes/materials: %i/%i", fileName, (data->file_type == 2)? "glb" : "gltf", data->meshes_count, data->materials_count);

// Read data buffers
result = cgltf_load_buffers(&options, data, fileName);
if (result != cgltf_result_success) TraceLog(LOG_INFO, "[%s][%s] Error loading mesh/material buffers", fileName, (data->file_type == 2)? "glb" : "gltf");
if (result != cgltf_result_success) TRACELOG(LOG_INFO, "[%s][%s] Error loading mesh/material buffers", fileName, (data->file_type == 2)? "glb" : "gltf");

int primitivesCount = 0;

Expand Down Expand Up @@ -3625,7 +3625,7 @@ static Model LoadGLTF(const char *fileName)
else
{
// TODO: Support normalized unsigned byte/unsigned short texture coordinates
TraceLog(LOG_WARNING, "[%s] Texture coordinates must be float", fileName);
TRACELOG(LOG_WARNING, "[%s] Texture coordinates must be float", fileName);
}
}
}
Expand All @@ -3643,7 +3643,7 @@ static Model LoadGLTF(const char *fileName)
else
{
// TODO: Support unsigned byte/unsigned int
TraceLog(LOG_WARNING, "[%s] Indices must be unsigned short", fileName);
TRACELOG(LOG_WARNING, "[%s] Indices must be unsigned short", fileName);
}
}
else
Expand All @@ -3668,7 +3668,7 @@ static Model LoadGLTF(const char *fileName)

cgltf_free(data);
}
else TraceLog(LOG_WARNING, "[%s] glTF data could not be loaded", fileName);
else TRACELOG(LOG_WARNING, "[%s] glTF data could not be loaded", fileName);

RL_FREE(buffer);

Expand Down
Loading

0 comments on commit cde26c7

Please sign in to comment.