Some code tweaks for consistency
This commit is contained in:
parent
cb698dd37d
commit
03710c9d8e
6 changed files with 24 additions and 24 deletions
12
src/core.c
12
src/core.c
|
@ -2179,8 +2179,8 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName)
|
||||||
|
|
||||||
shader.id = rlLoadShaderCode(vShaderStr, fShaderStr);
|
shader.id = rlLoadShaderCode(vShaderStr, fShaderStr);
|
||||||
|
|
||||||
if (vShaderStr != NULL) RL_FREE(vShaderStr);
|
if (vShaderStr != NULL) UnloadFileText(vShaderStr);
|
||||||
if (fShaderStr != NULL) RL_FREE(fShaderStr);
|
if (fShaderStr != NULL) UnloadFileText(fShaderStr);
|
||||||
|
|
||||||
// After shader loading, we TRY to set default location names
|
// After shader loading, we TRY to set default location names
|
||||||
if (shader.id > 0)
|
if (shader.id > 0)
|
||||||
|
@ -2801,8 +2801,8 @@ char **GetDirectoryFiles(const char *dirPath, int *fileCount)
|
||||||
ClearDirectoryFiles();
|
ClearDirectoryFiles();
|
||||||
|
|
||||||
// Memory allocation for MAX_DIRECTORY_FILES
|
// Memory allocation for MAX_DIRECTORY_FILES
|
||||||
dirFilesPath = (char **)RL_MALLOC(sizeof(char *)*MAX_DIRECTORY_FILES);
|
dirFilesPath = (char **)RL_MALLOC(MAX_DIRECTORY_FILES*sizeof(char *));
|
||||||
for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesPath[i] = (char *)RL_MALLOC(sizeof(char)*MAX_FILEPATH_LENGTH);
|
for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesPath[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char));
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
struct dirent *entity;
|
struct dirent *entity;
|
||||||
|
@ -5151,11 +5151,11 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
|
||||||
{
|
{
|
||||||
ClearDroppedFiles();
|
ClearDroppedFiles();
|
||||||
|
|
||||||
CORE.Window.dropFilesPath = (char **)RL_MALLOC(sizeof(char *)*count);
|
CORE.Window.dropFilesPath = (char **)RL_MALLOC(count*sizeof(char *));
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
CORE.Window.dropFilesPath[i] = (char *)RL_MALLOC(sizeof(char)*MAX_FILEPATH_LENGTH);
|
CORE.Window.dropFilesPath[i] = (char *)RL_MALLOC(MAX_FILEPATH_LENGTH*sizeof(char));
|
||||||
strcpy(CORE.Window.dropFilesPath[i], paths[i]);
|
strcpy(CORE.Window.dropFilesPath[i], paths[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
src/models.c
22
src/models.c
|
@ -3205,11 +3205,11 @@ static Model LoadOBJ(const char *fileName)
|
||||||
tinyobj_material_t *materials = NULL;
|
tinyobj_material_t *materials = NULL;
|
||||||
unsigned int materialCount = 0;
|
unsigned int materialCount = 0;
|
||||||
|
|
||||||
char *fileData = LoadFileText(fileName);
|
char *fileText = LoadFileText(fileName);
|
||||||
|
|
||||||
if (fileData != NULL)
|
if (fileText != NULL)
|
||||||
{
|
{
|
||||||
unsigned int dataSize = (unsigned int)strlen(fileData);
|
unsigned int dataSize = (unsigned int)strlen(fileText);
|
||||||
char currentDir[1024] = { 0 };
|
char currentDir[1024] = { 0 };
|
||||||
strcpy(currentDir, GetWorkingDirectory());
|
strcpy(currentDir, GetWorkingDirectory());
|
||||||
const char *workingDir = GetDirectoryPath(fileName);
|
const char *workingDir = GetDirectoryPath(fileName);
|
||||||
|
@ -3219,7 +3219,7 @@ static Model LoadOBJ(const char *fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int flags = TINYOBJ_FLAG_TRIANGULATE;
|
unsigned int flags = TINYOBJ_FLAG_TRIANGULATE;
|
||||||
int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, fileData, dataSize, flags);
|
int ret = tinyobj_parse_obj(&attrib, &meshes, &meshCount, &materials, &materialCount, fileText, dataSize, flags);
|
||||||
|
|
||||||
if (ret != TINYOBJ_SUCCESS) TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load OBJ data", fileName);
|
if (ret != TINYOBJ_SUCCESS) TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load OBJ data", fileName);
|
||||||
else TRACELOG(LOG_INFO, "MODEL: [%s] OBJ data loaded successfully: %i meshes / %i materials", fileName, meshCount, materialCount);
|
else TRACELOG(LOG_INFO, "MODEL: [%s] OBJ data loaded successfully: %i meshes / %i materials", fileName, meshCount, materialCount);
|
||||||
|
@ -3346,9 +3346,9 @@ static Model LoadOBJ(const char *fileName)
|
||||||
tinyobj_shapes_free(meshes, meshCount);
|
tinyobj_shapes_free(meshes, meshCount);
|
||||||
tinyobj_materials_free(materials, materialCount);
|
tinyobj_materials_free(materials, materialCount);
|
||||||
|
|
||||||
RL_FREE(fileData);
|
UnloadFileText(fileText);
|
||||||
RL_FREE(matFaces);
|
|
||||||
|
|
||||||
|
RL_FREE(matFaces);
|
||||||
RL_FREE(vCount);
|
RL_FREE(vCount);
|
||||||
RL_FREE(vtCount);
|
RL_FREE(vtCount);
|
||||||
RL_FREE(vnCount);
|
RL_FREE(vnCount);
|
||||||
|
@ -3496,7 +3496,7 @@ static Model LoadIQM(const char *fileName)
|
||||||
//fileDataPtr += sizeof(IQMHeader); // Move file data pointer
|
//fileDataPtr += sizeof(IQMHeader); // Move file data pointer
|
||||||
|
|
||||||
// Meshes data processing
|
// Meshes data processing
|
||||||
imesh = RL_MALLOC(sizeof(IQMMesh)*iqmHeader->num_meshes);
|
imesh = RL_MALLOC(iqmHeader->num_meshes*sizeof(IQMMesh));
|
||||||
//fseek(iqmFile, iqmHeader->ofs_meshes, SEEK_SET);
|
//fseek(iqmFile, iqmHeader->ofs_meshes, SEEK_SET);
|
||||||
//fread(imesh, sizeof(IQMMesh)*iqmHeader->num_meshes, 1, iqmFile);
|
//fread(imesh, sizeof(IQMMesh)*iqmHeader->num_meshes, 1, iqmFile);
|
||||||
memcpy(imesh, fileDataPtr + iqmHeader->ofs_meshes, iqmHeader->num_meshes*sizeof(IQMMesh));
|
memcpy(imesh, fileDataPtr + iqmHeader->ofs_meshes, iqmHeader->num_meshes*sizeof(IQMMesh));
|
||||||
|
@ -4466,8 +4466,8 @@ static void LoadGLTFBoneAttribute(Model* model, cgltf_accessor* jointsAccessor,
|
||||||
{
|
{
|
||||||
if (jointsAccessor->component_type == cgltf_component_type_r_16u)
|
if (jointsAccessor->component_type == cgltf_component_type_r_16u)
|
||||||
{
|
{
|
||||||
model->meshes[primitiveIndex].boneIds = RL_MALLOC(sizeof(int)*jointsAccessor->count*4);
|
model->meshes[primitiveIndex].boneIds = RL_MALLOC(jointsAccessor->count*4*sizeof(int));
|
||||||
short* bones = RL_MALLOC(sizeof(short)*jointsAccessor->count*4);
|
short* bones = RL_MALLOC(jointsAccessor->count*4*sizeof(short));
|
||||||
|
|
||||||
for (unsigned int a = 0; a < jointsAccessor->count; a++)
|
for (unsigned int a = 0; a < jointsAccessor->count; a++)
|
||||||
{
|
{
|
||||||
|
@ -4491,8 +4491,8 @@ static void LoadGLTFBoneAttribute(Model* model, cgltf_accessor* jointsAccessor,
|
||||||
}
|
}
|
||||||
else if (jointsAccessor->component_type == cgltf_component_type_r_8u)
|
else if (jointsAccessor->component_type == cgltf_component_type_r_8u)
|
||||||
{
|
{
|
||||||
model->meshes[primitiveIndex].boneIds = RL_MALLOC(sizeof(int)*jointsAccessor->count*4);
|
model->meshes[primitiveIndex].boneIds = RL_MALLOC(jointsAccessor->count*4*sizeof(int));
|
||||||
unsigned char* bones = RL_MALLOC(sizeof(unsigned char)*jointsAccessor->count*4);
|
unsigned char* bones = RL_MALLOC(jointsAccessor->count*4*sizeof(unsigned char));
|
||||||
|
|
||||||
for (unsigned int a = 0; a < jointsAccessor->count; a++)
|
for (unsigned int a = 0; a < jointsAccessor->count; a++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -898,9 +898,9 @@ typedef enum {
|
||||||
// Callbacks to hook some internal functions
|
// Callbacks to hook some internal functions
|
||||||
// WARNING: This callbacks are intended for advance users
|
// WARNING: This callbacks are intended for advance users
|
||||||
typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages
|
typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages
|
||||||
typedef unsigned char* (*LoadFileDataCallback)(const char* fileName, unsigned int* bytesRead); // FileIO: Load binary data
|
typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data
|
||||||
typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data
|
typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data
|
||||||
typedef char *(*LoadFileTextCallback)(const char* fileName); // FileIO: Load text data
|
typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data
|
||||||
typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data
|
typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data
|
||||||
|
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ RLAPI unsigned char *LoadFileData(const char *fileName, unsigned int *bytesRead)
|
||||||
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
|
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
|
||||||
RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success
|
RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite); // Save data to file from byte array (write), returns true on success
|
||||||
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
|
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
|
||||||
RLAPI void UnloadFileText(unsigned char *text); // Unload file text data allocated by LoadFileText()
|
RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()
|
||||||
RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
|
RLAPI bool SaveFileText(const char *fileName, char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
|
||||||
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
||||||
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
|
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
|
||||||
|
|
|
@ -1685,7 +1685,7 @@ void rlLoadExtensions(void *loader)
|
||||||
#if defined(SUPPORT_GL_DETAILS_INFO)
|
#if defined(SUPPORT_GL_DETAILS_INFO)
|
||||||
// Get supported extensions list
|
// Get supported extensions list
|
||||||
// WARNING: glGetStringi() not available on OpenGL 2.1
|
// WARNING: glGetStringi() not available on OpenGL 2.1
|
||||||
char **extList = RL_MALLOC(sizeof(char *)*numExt);
|
char **extList = RL_MALLOC(numExt*sizeof(char *));
|
||||||
TRACELOG(LOG_INFO, "GL: OpenGL extensions:");
|
TRACELOG(LOG_INFO, "GL: OpenGL extensions:");
|
||||||
for (int i = 0; i < numExt; i++)
|
for (int i = 0; i < numExt; i++)
|
||||||
{
|
{
|
||||||
|
@ -1966,7 +1966,7 @@ RenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements)
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
// Initialize CPU (RAM) vertex buffers (position, texcoord, color data and indexes)
|
// Initialize CPU (RAM) vertex buffers (position, texcoord, color data and indexes)
|
||||||
//--------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------
|
||||||
batch.vertexBuffer = (VertexBuffer *)RL_MALLOC(sizeof(VertexBuffer)*numBuffers);
|
batch.vertexBuffer = (VertexBuffer *)RL_MALLOC(numBuffers*sizeof(VertexBuffer));
|
||||||
|
|
||||||
for (int i = 0; i < numBuffers; i++)
|
for (int i = 0; i < numBuffers; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1865,7 +1865,7 @@ static Font LoadBMFont(const char *fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
UnloadImage(imFont);
|
UnloadImage(imFont);
|
||||||
RL_FREE(fileText);
|
UnloadFileText(fileText);
|
||||||
|
|
||||||
if (font.texture.id == 0)
|
if (font.texture.id == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -325,7 +325,7 @@ char *LoadFileText(const char *fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload file text data allocated by LoadFileText()
|
// Unload file text data allocated by LoadFileText()
|
||||||
void UnloadFileText(unsigned char *text)
|
void UnloadFileText(char *text)
|
||||||
{
|
{
|
||||||
RL_FREE(text);
|
RL_FREE(text);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue