Browse Source

Remove all trail spaces

pull/1092/head
Ray 5 years ago
parent
commit
c3f06b7470
11 changed files with 100 additions and 100 deletions
  1. +2
    -2
      src/camera.h
  2. +35
    -35
      src/core.c
  3. +13
    -13
      src/models.c
  4. +2
    -2
      src/physac.h
  5. +7
    -7
      src/raudio.c
  6. +5
    -5
      src/rlgl.h
  7. +5
    -5
      src/rmem.h
  8. +1
    -1
      src/shapes.c
  9. +23
    -23
      src/text.c
  10. +6
    -6
      src/textures.c
  11. +1
    -1
      src/utils.h

+ 2
- 2
src/camera.h View File

@ -212,7 +212,7 @@ typedef struct {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static CameraData CAMERA = {
static CameraData CAMERA = {
.mode = 0, .mode = 0,
.targetDistance = 0, .targetDistance = 0,
.playerEyesPosition = 1.85f, .playerEyesPosition = 1.85f,
@ -444,7 +444,7 @@ void UpdateCamera(Camera *camera)
Matrix translation = MatrixTranslate(0, 0, (CAMERA.targetDistance/CAMERA_FREE_PANNING_DIVIDER)); Matrix translation = MatrixTranslate(0, 0, (CAMERA.targetDistance/CAMERA_FREE_PANNING_DIVIDER));
Matrix rotation = MatrixRotateXYZ((Vector3){ PI*2 - CAMERA.angle.y, PI*2 - CAMERA.angle.x, 0 }); Matrix rotation = MatrixRotateXYZ((Vector3){ PI*2 - CAMERA.angle.y, PI*2 - CAMERA.angle.x, 0 });
Matrix transform = MatrixMultiply(translation, rotation); Matrix transform = MatrixMultiply(translation, rotation);
camera->target.x = camera->position.x - transform.m12; camera->target.x = camera->position.x - transform.m12;
camera->target.y = camera->position.y - transform.m13; camera->target.y = camera->position.y - transform.m13;
camera->target.z = camera->position.z - transform.m14; camera->target.z = camera->position.z - transform.m14;

+ 35
- 35
src/core.c View File

@ -356,7 +356,7 @@ typedef struct CoreData {
Size render; // Framebuffer width and height (render area, including black bars if required) Size render; // Framebuffer width and height (render area, including black bars if required)
Point renderOffset; // Offset from render area (must be divided by 2) Point renderOffset; // Offset from render area (must be divided by 2)
Matrix screenScale; // Matrix to scale screen (framebuffer rendering) Matrix screenScale; // Matrix to scale screen (framebuffer rendering)
char **dropFilesPath; // Store dropped files paths as strings char **dropFilesPath; // Store dropped files paths as strings
int dropFilesCount; // Count dropped files strings int dropFilesCount; // Count dropped files strings
@ -608,12 +608,12 @@ void InitWindow(int width, int height, const char *title)
TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION); TRACELOG(LOG_INFO, "Initializing raylib %s", RAYLIB_VERSION);
CORE.Window.title = title; CORE.Window.title = title;
// Initialize required global values different than 0 // Initialize required global values different than 0
CORE.Input.Keyboard.exitKey = KEY_ESCAPE; CORE.Input.Keyboard.exitKey = KEY_ESCAPE;
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f }; CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
CORE.Input.Gamepad.lastButtonPressed = -1; CORE.Input.Gamepad.lastButtonPressed = -1;
#if defined(PLATFORM_ANDROID) #if defined(PLATFORM_ANDROID)
CORE.Window.screen.width = width; CORE.Window.screen.width = width;
CORE.Window.screen.height = height; CORE.Window.screen.height = height;
@ -824,7 +824,7 @@ bool WindowShouldClose(void)
while (!CORE.Window.alwaysRun && CORE.Window.minimized) glfwWaitEvents(); while (!CORE.Window.alwaysRun && CORE.Window.minimized) glfwWaitEvents();
CORE.Window.shouldClose = glfwWindowShouldClose(CORE.Window.handle); CORE.Window.shouldClose = glfwWindowShouldClose(CORE.Window.handle);
return CORE.Window.shouldClose; return CORE.Window.shouldClose;
} }
else return true; else return true;
@ -872,7 +872,7 @@ void ToggleFullscreen(void)
CORE.Window.fullscreen = !CORE.Window.fullscreen; // Toggle fullscreen flag CORE.Window.fullscreen = !CORE.Window.fullscreen; // Toggle fullscreen flag
// NOTE: glfwSetWindowMonitor() doesn't work properly (bugs) // NOTE: glfwSetWindowMonitor() doesn't work properly (bugs)
if (CORE.Window.fullscreen)
if (CORE.Window.fullscreen)
{ {
// Store previous window position (in case we exit fullscreen) // Store previous window position (in case we exit fullscreen)
glfwGetWindowPos(CORE.Window.handle, &CORE.Window.position.x, &CORE.Window.position.y); glfwGetWindowPos(CORE.Window.handle, &CORE.Window.position.x, &CORE.Window.position.y);
@ -887,7 +887,7 @@ void ToggleFullscreen(void)
const GLFWvidmode *mode = glfwGetVideoMode(monitor); const GLFWvidmode *mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate); glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate);
// Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS) // Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)
// NOTE: V-Sync can be enabled by graphic driver configuration // NOTE: V-Sync can be enabled by graphic driver configuration
if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1); if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1);
@ -1281,14 +1281,14 @@ void EndDrawing(void)
SwapBuffers(); // Copy back buffer to front buffer SwapBuffers(); // Copy back buffer to front buffer
PollInputEvents(); // Poll user events PollInputEvents(); // Poll user events
// Frame time control system // Frame time control system
CORE.Time.current = GetTime(); CORE.Time.current = GetTime();
CORE.Time.draw = CORE.Time.current - CORE.Time.previous; CORE.Time.draw = CORE.Time.current - CORE.Time.previous;
CORE.Time.previous = CORE.Time.current; CORE.Time.previous = CORE.Time.current;
CORE.Time.frame = CORE.Time.update + CORE.Time.draw; CORE.Time.frame = CORE.Time.update + CORE.Time.draw;
// Wait for some milliseconds... // Wait for some milliseconds...
if (CORE.Time.frame < CORE.Time.target) if (CORE.Time.frame < CORE.Time.target)
{ {
@ -1299,9 +1299,9 @@ void EndDrawing(void)
CORE.Time.previous = CORE.Time.current; CORE.Time.previous = CORE.Time.current;
CORE.Time.frame += waitTime; // Total frame time: update + draw + wait CORE.Time.frame += waitTime; // Total frame time: update + draw + wait
//SetWindowTitle(FormatText("Update: %f, Draw: %f, Req.Wait: %f, Real.Wait: %f, Total: %f, Target: %f\n",
// (float)CORE.Time.update, (float)CORE.Time.draw, (float)(CORE.Time.target - (CORE.Time.update + CORE.Time.draw)),
//SetWindowTitle(FormatText("Update: %f, Draw: %f, Req.Wait: %f, Real.Wait: %f, Total: %f, Target: %f\n",
// (float)CORE.Time.update, (float)CORE.Time.draw, (float)(CORE.Time.target - (CORE.Time.update + CORE.Time.draw)),
// (float)waitTime, (float)CORE.Time.frame, (float)CORE.Time.target)); // (float)waitTime, (float)CORE.Time.frame, (float)CORE.Time.target));
} }
} }
@ -1315,7 +1315,7 @@ void BeginMode2D(Camera2D camera)
// Apply 2d camera transformation to modelview // Apply 2d camera transformation to modelview
rlMultMatrixf(MatrixToFloat(GetCameraMatrix2D(camera))); rlMultMatrixf(MatrixToFloat(GetCameraMatrix2D(camera)));
// Apply screen scaling if required // Apply screen scaling if required
rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale)); rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale));
} }
@ -1551,7 +1551,7 @@ Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int heigh
if (camera.type == CAMERA_PERSPECTIVE) if (camera.type == CAMERA_PERSPECTIVE)
{ {
// Calculate projection matrix from perspective // Calculate projection matrix from perspective
matProj = MatrixPerspective(camera.fovy * DEG2RAD, ((double)width/(double)height), DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
matProj = MatrixPerspective(camera.fovy * DEG2RAD, ((double)width/(double)height), DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
} }
else if (camera.type == CAMERA_ORTHOGRAPHIC) else if (camera.type == CAMERA_ORTHOGRAPHIC)
{ {
@ -1560,7 +1560,7 @@ Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int heigh
double right = top*aspect; double right = top*aspect;
// Calculate projection matrix from orthographic // Calculate projection matrix from orthographic
matProj = MatrixOrtho(-right, right, -top, top, DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
matProj = MatrixOrtho(-right, right, -top, top, DEFAULT_NEAR_CULL_DISTANCE, DEFAULT_FAR_CULL_DISTANCE);
} }
// Calculate view matrix from camera look at (and transpose it) // Calculate view matrix from camera look at (and transpose it)
@ -1579,7 +1579,7 @@ Vector2 GetWorldToScreenEx(Vector3 position, Camera camera, int width, int heigh
Vector3 ndcPos = { worldPos.x/worldPos.w, -worldPos.y/worldPos.w, worldPos.z/worldPos.w }; Vector3 ndcPos = { worldPos.x/worldPos.w, -worldPos.y/worldPos.w, worldPos.z/worldPos.w };
// Calculate 2d screen position vector // Calculate 2d screen position vector
Vector2 screenPosition = { (ndcPos.x + 1.0f)/2.0f*(float)width, (ndcPos.y + 1.0f)/2.0f*(float)height };
Vector2 screenPosition = { (ndcPos.x + 1.0f)/2.0f*(float)width, (ndcPos.y + 1.0f)/2.0f*(float)height };
return screenPosition; return screenPosition;
} }
@ -1865,7 +1865,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
{ {
int extCount = 0; int extCount = 0;
const char **checkExts = TextSplit(ext, ';', &extCount); const char **checkExts = TextSplit(ext, ';', &extCount);
char fileExtLower[16] = { 0 }; char fileExtLower[16] = { 0 };
strcpy(fileExtLower, TextToLower(fileExt)); strcpy(fileExtLower, TextToLower(fileExt));
@ -1966,8 +1966,8 @@ const char *GetDirectoryPath(const char *filePath)
const char *lastSlash = NULL; const char *lastSlash = NULL;
static char dirPath[MAX_FILEPATH_LENGTH]; static char dirPath[MAX_FILEPATH_LENGTH];
memset(dirPath, 0, MAX_FILEPATH_LENGTH); memset(dirPath, 0, MAX_FILEPATH_LENGTH);
// For security, we set starting path to current directory,
// For security, we set starting path to current directory,
// obtained path will be concated to this // obtained path will be concated to this
//dirPath[0] = '.'; //dirPath[0] = '.';
//dirPath[1] = '/'; //dirPath[1] = '/';
@ -2063,7 +2063,7 @@ void ClearDirectoryFiles(void)
RL_FREE(dirFilesPath); RL_FREE(dirFilesPath);
} }
dirFilesCount = 0; dirFilesCount = 0;
} }
@ -2454,8 +2454,8 @@ bool IsMouseButtonPressed(int button)
if (IsGestureDetected(GESTURE_TAP)) pressed = true; if (IsGestureDetected(GESTURE_TAP)) pressed = true;
#else #else
// NOTE: On PLATFORM_DESKTOP and PLATFORM_WEB IsMouseButtonPressed() is equivalent to GESTURE_TAP // NOTE: On PLATFORM_DESKTOP and PLATFORM_WEB IsMouseButtonPressed() is equivalent to GESTURE_TAP
if (((CORE.Input.Mouse.currentButtonState[button] != CORE.Input.Mouse.previousButtonState[button]) &&
(CORE.Input.Mouse.currentButtonState[button] == 1)) || IsGestureDetected(GESTURE_TAP)) pressed = true;
if (((CORE.Input.Mouse.currentButtonState[button] != CORE.Input.Mouse.previousButtonState[button]) &&
(CORE.Input.Mouse.currentButtonState[button] == 1)) || IsGestureDetected(GESTURE_TAP)) pressed = true;
#endif #endif
return pressed; return pressed;
@ -2482,7 +2482,7 @@ bool IsMouseButtonReleased(int button)
bool released = false; bool released = false;
#if !defined(PLATFORM_ANDROID) #if !defined(PLATFORM_ANDROID)
if ((CORE.Input.Mouse.currentButtonState[button] != CORE.Input.Mouse.previousButtonState[button]) &&
if ((CORE.Input.Mouse.currentButtonState[button] != CORE.Input.Mouse.previousButtonState[button]) &&
(CORE.Input.Mouse.currentButtonState[button] == 0)) released = true; (CORE.Input.Mouse.currentButtonState[button] == 0)) released = true;
#endif #endif
@ -2701,7 +2701,7 @@ static bool InitGraphicsDevice(int width, int height)
//glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers //glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers
#if defined(PLATFORM_DESKTOP) && defined(SUPPORT_HIGH_DPI) #if defined(PLATFORM_DESKTOP) && defined(SUPPORT_HIGH_DPI)
// Resize window content area based on the monitor content scale. // Resize window content area based on the monitor content scale.
// NOTE: This hint only has an effect on platforms where screen coordinates and pixels always map 1:1 such as Windows and X11.
// NOTE: This hint only has an effect on platforms where screen coordinates and pixels always map 1:1 such as Windows and X11.
// On platforms like macOS the resolution of the framebuffer is changed independently of the window size. // On platforms like macOS the resolution of the framebuffer is changed independently of the window size.
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); // Scale content area based on the monitor content scale where window is placed on
#endif #endif
@ -3224,7 +3224,7 @@ static bool InitGraphicsDevice(int width, int height)
CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f); CORE.Window.screenScale = MatrixScale((float)fbWidth/CORE.Window.screen.width, (float)fbHeight/CORE.Window.screen.height, 1.0f);
#if !defined(__APPLE__) #if !defined(__APPLE__)
SetMouseScale((float)CORE.Window.screen.width/fbWidth, (float)CORE.Window.screen.height/fbHeight); SetMouseScale((float)CORE.Window.screen.width/fbWidth, (float)CORE.Window.screen.height/fbHeight);
#endif
#endif
#endif // PLATFORM_DESKTOP && SUPPORT_HIGH_DPI #endif // PLATFORM_DESKTOP && SUPPORT_HIGH_DPI
// Setup default viewport // Setup default viewport
@ -3391,7 +3391,7 @@ static void Wait(float ms)
#elif defined(__APPLE__) #elif defined(__APPLE__)
usleep(ms*1000.0f); usleep(ms*1000.0f);
#endif #endif
#if defined(SUPPORT_HALFBUSY_WAIT_LOOP) #if defined(SUPPORT_HALFBUSY_WAIT_LOOP)
while (GetTime() < destTime) { } while (GetTime() < destTime) { }
#endif #endif
@ -3548,7 +3548,7 @@ static void PollInputEvents(void)
{ {
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = CORE.Input.Keyboard.lastKeyPressed.Contents[CORE.Input.Keyboard.lastKeyPressed.Tail]; // Read the key from the buffer CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = CORE.Input.Keyboard.lastKeyPressed.Contents[CORE.Input.Keyboard.lastKeyPressed.Tail]; // Read the key from the buffer
CORE.Input.Keyboard.keyPressedQueueCount++; CORE.Input.Keyboard.keyPressedQueueCount++;
CORE.Input.Keyboard.lastKeyPressed.Tail = (CORE.Input.Keyboard.lastKeyPressed.Tail + 1) & 0x07; // Increment the tail pointer forwards and binary wraparound after 7 (fifo is 8 elements long) CORE.Input.Keyboard.lastKeyPressed.Tail = (CORE.Input.Keyboard.lastKeyPressed.Tail + 1) & 0x07; // Increment the tail pointer forwards and binary wraparound after 7 (fifo is 8 elements long)
} }
@ -3852,7 +3852,7 @@ static void PollInputEvents(void)
// Android ALooper_pollAll() variables // Android ALooper_pollAll() variables
int pollResult = 0; int pollResult = 0;
int pollEvents = 0; int pollEvents = 0;
// Poll Events (registered events) // Poll Events (registered events)
// NOTE: Activity is paused if not enabled (CORE.Android.appEnabled) // NOTE: Activity is paused if not enabled (CORE.Android.appEnabled)
while ((pollResult = ALooper_pollAll(CORE.Android.appEnabled? 0 : -1, NULL, &pollEvents, (void**)&CORE.Android.source)) >= 0) while ((pollResult = ALooper_pollAll(CORE.Android.appEnabled? 0 : -1, NULL, &pollEvents, (void**)&CORE.Android.source)) >= 0)
@ -4223,7 +4223,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN) if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN)
{ {
CORE.Input.Keyboard.currentKeyState[keycode] = 1; // Key down CORE.Input.Keyboard.currentKeyState[keycode] = 1; // Key down
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode; CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode;
CORE.Input.Keyboard.keyPressedQueueCount++; CORE.Input.Keyboard.keyPressedQueueCount++;
} }
@ -4240,7 +4240,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN) if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN)
{ {
CORE.Input.Keyboard.currentKeyState[keycode] = 1; // Key down CORE.Input.Keyboard.currentKeyState[keycode] = 1; // Key down
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode; CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode;
CORE.Input.Keyboard.keyPressedQueueCount++; CORE.Input.Keyboard.keyPressedQueueCount++;
} }
@ -4589,15 +4589,15 @@ static void ProcessKeyboard(void)
} }
else if (keysBuffer[i] == 0x0a) // raylib KEY_ENTER (don't mix with <linux/input.h> KEY_*) else if (keysBuffer[i] == 0x0a) // raylib KEY_ENTER (don't mix with <linux/input.h> KEY_*)
{ {
CORE.Input.Keyboard.currentKeyState[257] = 1;
CORE.Input.Keyboard.currentKeyState[257] = 1;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 257; // Add keys pressed into queue CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 257; // Add keys pressed into queue
CORE.Input.Keyboard.keyPressedQueueCount++; CORE.Input.Keyboard.keyPressedQueueCount++;
} }
else if (keysBuffer[i] == 0x7f) // raylib KEY_BACKSPACE else if (keysBuffer[i] == 0x7f) // raylib KEY_BACKSPACE
{
CORE.Input.Keyboard.currentKeyState[259] = 1;
{
CORE.Input.Keyboard.currentKeyState[259] = 1;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 257; // Add keys pressed into queue CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 257; // Add keys pressed into queue
CORE.Input.Keyboard.keyPressedQueueCount++; CORE.Input.Keyboard.keyPressedQueueCount++;
} }
@ -5026,7 +5026,7 @@ static void *EventThread(void *arg)
*/ */
CORE.Input.Keyboard.currentKeyState[keycode] = event.value; CORE.Input.Keyboard.currentKeyState[keycode] = event.value;
if (event.value == 1)
if (event.value == 1)
{ {
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode; // Register last key pressed CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode; // Register last key pressed
CORE.Input.Keyboard.keyPressedQueueCount++; CORE.Input.Keyboard.keyPressedQueueCount++;

+ 13
- 13
src/models.c View File

@ -114,7 +114,7 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
void DrawPoint3D(Vector3 position, Color color) void DrawPoint3D(Vector3 position, Color color)
{ {
if (rlCheckBufferLimit(8)) rlglDraw(); if (rlCheckBufferLimit(8)) rlglDraw();
rlPushMatrix(); rlPushMatrix();
rlTranslatef(position.x, position.y, position.z); rlTranslatef(position.x, position.y, position.z);
rlBegin(RL_LINES); rlBegin(RL_LINES);
@ -955,7 +955,7 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount)
{ {
TRACELOG(LOG_ERROR, "IQM version %i is incorrect.", iqm.version); TRACELOG(LOG_ERROR, "IQM version %i is incorrect.", iqm.version);
fclose(iqmFile); fclose(iqmFile);
return NULL; return NULL;
} }
@ -2376,7 +2376,7 @@ void MeshBinormals(Mesh *mesh)
//Vector3 normal = { mesh->normals[i*3 + 0], mesh->normals[i*3 + 1], mesh->normals[i*3 + 2] }; //Vector3 normal = { mesh->normals[i*3 + 0], mesh->normals[i*3 + 1], mesh->normals[i*3 + 2] };
//Vector3 tangent = { mesh->tangents[i*4 + 0], mesh->tangents[i*4 + 1], mesh->tangents[i*4 + 2] }; //Vector3 tangent = { mesh->tangents[i*4 + 0], mesh->tangents[i*4 + 1], mesh->tangents[i*4 + 2] };
//Vector3 binormal = Vector3Scale(Vector3CrossProduct(normal, tangent), mesh->tangents[i*4 + 3]); //Vector3 binormal = Vector3Scale(Vector3CrossProduct(normal, tangent), mesh->tangents[i*4 + 3]);
// TODO: Register computed binormal in mesh->binormal? // TODO: Register computed binormal in mesh->binormal?
} }
} }
@ -2408,13 +2408,13 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
{ {
// TODO: Review color + tint premultiplication mechanism // TODO: Review color + tint premultiplication mechanism
Color color = model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color; Color color = model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color;
Color colorTint = WHITE; Color colorTint = WHITE;
colorTint.r = (((float)color.r/255.0)*((float)tint.r/255.0))*255; colorTint.r = (((float)color.r/255.0)*((float)tint.r/255.0))*255;
colorTint.g = (((float)color.g/255.0)*((float)tint.g/255.0))*255; colorTint.g = (((float)color.g/255.0)*((float)tint.g/255.0))*255;
colorTint.b = (((float)color.b/255.0)*((float)tint.b/255.0))*255; colorTint.b = (((float)color.b/255.0)*((float)tint.b/255.0))*255;
colorTint.a = (((float)color.a/255.0)*((float)tint.a/255.0))*255; colorTint.a = (((float)color.a/255.0)*((float)tint.a/255.0))*255;
model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = colorTint; model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = colorTint;
rlDrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform); rlDrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform);
model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = color; model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = color;
@ -3406,7 +3406,7 @@ static Texture LoadTextureFromCgltfImage(cgltf_image *image, const char *texPath
unsigned char *raw = stbi_load_from_memory(data, size, &w, &h, NULL, 4); unsigned char *raw = stbi_load_from_memory(data, size, &w, &h, NULL, 4);
Image rimage = LoadImagePro(raw, w, h, UNCOMPRESSED_R8G8B8A8); Image rimage = LoadImagePro(raw, w, h, UNCOMPRESSED_R8G8B8A8);
// TODO: Tint shouldn't be applied here! // TODO: Tint shouldn't be applied here!
ImageColorTint(&rimage, tint); ImageColorTint(&rimage, tint);
texture = LoadTextureFromImage(rimage); texture = LoadTextureFromImage(rimage);
@ -3416,7 +3416,7 @@ static Texture LoadTextureFromCgltfImage(cgltf_image *image, const char *texPath
else else
{ {
Image rimage = LoadImage(TextFormat("%s/%s", texPath, image->uri)); Image rimage = LoadImage(TextFormat("%s/%s", texPath, image->uri));
// TODO: Tint shouldn't be applied here! // TODO: Tint shouldn't be applied here!
ImageColorTint(&rimage, tint); ImageColorTint(&rimage, tint);
texture = LoadTextureFromImage(rimage); texture = LoadTextureFromImage(rimage);
@ -3544,7 +3544,7 @@ static Model LoadGLTF(const char *fileName)
const char *texPath = GetDirectoryPath(fileName); const char *texPath = GetDirectoryPath(fileName);
//Ensure material follows raylib support for PBR (metallic/roughness flow) //Ensure material follows raylib support for PBR (metallic/roughness flow)
if (data->materials[i].has_pbr_metallic_roughness)
if (data->materials[i].has_pbr_metallic_roughness)
{ {
float roughness = data->materials[i].pbr_metallic_roughness.roughness_factor; float roughness = data->materials[i].pbr_metallic_roughness.roughness_factor;
float metallic = data->materials[i].pbr_metallic_roughness.metallic_factor; float metallic = data->materials[i].pbr_metallic_roughness.metallic_factor;
@ -3560,12 +3560,12 @@ static Model LoadGLTF(const char *fileName)
model.materials[i].maps[MAP_ROUGHNESS].color = tint; model.materials[i].maps[MAP_ROUGHNESS].color = tint;
if (data->materials[i].pbr_metallic_roughness.base_color_texture.texture)
if (data->materials[i].pbr_metallic_roughness.base_color_texture.texture)
{ {
model.materials[i].maps[MAP_ALBEDO].texture = LoadTextureFromCgltfImage(data->materials[i].pbr_metallic_roughness.base_color_texture.texture->image, texPath, tint); model.materials[i].maps[MAP_ALBEDO].texture = LoadTextureFromCgltfImage(data->materials[i].pbr_metallic_roughness.base_color_texture.texture->image, texPath, tint);
} }
// NOTE: Tint isn't need for other textures.. pass null or clear?
// NOTE: Tint isn't need for other textures.. pass null or clear?
// Just set as white, multiplying by white has no effect // Just set as white, multiplying by white has no effect
tint = WHITE; tint = WHITE;
@ -3576,12 +3576,12 @@ static Model LoadGLTF(const char *fileName)
model.materials[i].maps[MAP_ROUGHNESS].value = roughness; model.materials[i].maps[MAP_ROUGHNESS].value = roughness;
model.materials[i].maps[MAP_METALNESS].value = metallic; model.materials[i].maps[MAP_METALNESS].value = metallic;
if (data->materials[i].normal_texture.texture)
if (data->materials[i].normal_texture.texture)
{ {
model.materials[i].maps[MAP_NORMAL].texture = LoadTextureFromCgltfImage(data->materials[i].normal_texture.texture->image, texPath, tint); model.materials[i].maps[MAP_NORMAL].texture = LoadTextureFromCgltfImage(data->materials[i].normal_texture.texture->image, texPath, tint);
} }
if (data->materials[i].occlusion_texture.texture)
if (data->materials[i].occlusion_texture.texture)
{ {
model.materials[i].maps[MAP_OCCLUSION].texture = LoadTextureFromCgltfImage(data->materials[i].occlusion_texture.texture->image, texPath, tint); model.materials[i].maps[MAP_OCCLUSION].texture = LoadTextureFromCgltfImage(data->materials[i].occlusion_texture.texture->image, texPath, tint);
} }

+ 2
- 2
src/physac.h View File

@ -112,7 +112,7 @@
#elif !defined(__cplusplus) && !defined(bool) #elif !defined(__cplusplus) && !defined(bool)
typedef enum { false, true } bool; typedef enum { false, true } bool;
#endif #endif
// Vector2 type // Vector2 type
typedef struct Vector2 { typedef struct Vector2 {
float x; float x;
@ -1257,7 +1257,7 @@ static void DestroyPhysicsManifold(PhysicsManifold manifold)
printf("[PHYSAC] Not possible to manifold id %i in pointers array\n", id); printf("[PHYSAC] Not possible to manifold id %i in pointers array\n", id);
#endif #endif
return; // Prevent access to index -1 return; // Prevent access to index -1
}
}
// Free manifold allocated memory // Free manifold allocated memory
PHYSAC_FREE(manifold); PHYSAC_FREE(manifold);

+ 7
- 7
src/raudio.c View File

@ -163,10 +163,10 @@ typedef enum {
} TraceLogType; } TraceLogType;
#endif #endif
// NOTE: Different logic is used when feeding data to the playback device
// NOTE: Different logic is used when feeding data to the playback device
// depending on whether or not data is streamed (Music vs Sound) // depending on whether or not data is streamed (Music vs Sound)
typedef enum {
AUDIO_BUFFER_USAGE_STATIC = 0,
typedef enum {
AUDIO_BUFFER_USAGE_STATIC = 0,
AUDIO_BUFFER_USAGE_STREAM AUDIO_BUFFER_USAGE_STREAM
} AudioBufferUsage; } AudioBufferUsage;
@ -274,7 +274,7 @@ void InitAudioDevice(void)
{ {
// TODO: Load AUDIO context memory dynamically? // TODO: Load AUDIO context memory dynamically?
AUDIO.System.masterVolume = 1.0f; AUDIO.System.masterVolume = 1.0f;
// Init audio context // Init audio context
ma_context_config ctxConfig = ma_context_config_init(); ma_context_config ctxConfig = ma_context_config_init();
ctxConfig.logCallback = OnLog; ctxConfig.logCallback = OnLog;
@ -386,7 +386,7 @@ AudioBuffer *InitAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sam
TRACELOG(LOG_ERROR, "InitAudioBuffer() : Failed to allocate memory for audio buffer"); TRACELOG(LOG_ERROR, "InitAudioBuffer() : Failed to allocate memory for audio buffer");
return NULL; return NULL;
} }
audioBuffer->data = RL_CALLOC(sizeInFrames*channels*ma_get_bytes_per_sample(format), 1); audioBuffer->data = RL_CALLOC(sizeInFrames*channels*ma_get_bytes_per_sample(format), 1);
// Audio data runs through a format converter // Audio data runs through a format converter
@ -1541,7 +1541,7 @@ static void OnSendAudioDataToDevice(ma_device *pDevice, void *pFramesOut, const
framesToRead -= framesJustRead; framesToRead -= framesJustRead;
framesRead += framesJustRead; framesRead += framesJustRead;
} }
if (!audioBuffer->playing) if (!audioBuffer->playing)
{ {
framesRead = frameCount; framesRead = frameCount;
@ -1697,7 +1697,7 @@ static void InitAudioBufferPool(void)
// Close the audio buffers pool // Close the audio buffers pool
static void CloseAudioBufferPool(void) static void CloseAudioBufferPool(void)
{ {
for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++)
for (int i = 0; i < MAX_AUDIO_BUFFER_POOL_CHANNELS; i++)
{ {
RL_FREE(AUDIO.MultiChannel.pool[i]->data); RL_FREE(AUDIO.MultiChannel.pool[i]->data);
RL_FREE(AUDIO.MultiChannel.pool[i]); RL_FREE(AUDIO.MultiChannel.pool[i]);

+ 5
- 5
src/rlgl.h View File

@ -64,7 +64,7 @@
#if defined(RLGL_STANDALONE) #if defined(RLGL_STANDALONE)
#define RAYMATH_STANDALONE #define RAYMATH_STANDALONE
#define RAYMATH_HEADER_ONLY #define RAYMATH_HEADER_ONLY
#define RLAPI // We are building or using rlgl as a static library (or Linux shared library) #define RLAPI // We are building or using rlgl as a static library (or Linux shared library)
#if defined(_WIN32) #if defined(_WIN32)
@ -74,11 +74,11 @@
#define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll) #define RLAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
#endif #endif
#endif #endif
// Support TRACELOG macros // Support TRACELOG macros
#if defined(SUPPORT_TRACELOG) #if defined(SUPPORT_TRACELOG)
#define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__) #define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__)
#if defined(SUPPORT_TRACELOG_DEBUG) #if defined(SUPPORT_TRACELOG_DEBUG)
#define TRACELOGD(...) TraceLog(LOG_DEBUG, __VA_ARGS__) #define TRACELOGD(...) TraceLog(LOG_DEBUG, __VA_ARGS__)
#else #else
@ -212,7 +212,7 @@ typedef unsigned char byte;
unsigned char b; unsigned char b;
unsigned char a; unsigned char a;
} Color; } Color;
// Rectangle type // Rectangle type
typedef struct Rectangle { typedef struct Rectangle {
float x; float x;
@ -816,7 +816,7 @@ typedef struct rlglData {
int currentBuffer; // Current buffer tracking, multi-buffering system is supported int currentBuffer; // Current buffer tracking, multi-buffering system is supported
DrawCall *draws; // Draw calls array DrawCall *draws; // Draw calls array
int drawsCounter; // Draw calls counter int drawsCounter; // Draw calls counter
Texture2D shapesTexture; // Texture used on shapes drawing (usually a white) Texture2D shapesTexture; // Texture used on shapes drawing (usually a white)
Rectangle shapesTextureRec; // Texture source rectangle used on shapes drawing Rectangle shapesTextureRec; // Texture source rectangle used on shapes drawing
unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader) unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader)

+ 5
- 5
src/rmem.h View File

@ -694,7 +694,7 @@ BiStack CreateBiStack(const size_t len)
{ {
BiStack destack = { 0 }; BiStack destack = { 0 };
if (len == 0UL) return destack; if (len == 0UL) return destack;
destack.size = len; destack.size = len;
destack.mem = malloc(len*sizeof *destack.mem); destack.mem = malloc(len*sizeof *destack.mem);
if (destack.mem==NULL) destack.size = 0UL; if (destack.mem==NULL) destack.size = 0UL;
@ -726,11 +726,11 @@ void DestroyBiStack(BiStack *const destack)
void *BiStackAllocFront(BiStack *const destack, const size_t len) void *BiStackAllocFront(BiStack *const destack, const size_t len)
{ {
if ((destack == NULL) || (destack->mem == NULL)) return NULL; if ((destack == NULL) || (destack->mem == NULL)) return NULL;
const size_t ALIGNED_LEN = __AlignSize(len, sizeof(uintptr_t)); const size_t ALIGNED_LEN = __AlignSize(len, sizeof(uintptr_t));
// front end stack is too high! // front end stack is too high!
if (destack->front + ALIGNED_LEN >= destack->back) return NULL; if (destack->front + ALIGNED_LEN >= destack->back) return NULL;
uint8_t *ptr = destack->front; uint8_t *ptr = destack->front;
destack->front += ALIGNED_LEN; destack->front += ALIGNED_LEN;
return ptr; return ptr;
@ -739,11 +739,11 @@ void *BiStackAllocFront(BiStack *const destack, const size_t len)
void *BiStackAllocBack(BiStack *const destack, const size_t len) void *BiStackAllocBack(BiStack *const destack, const size_t len)
{ {
if ((destack == NULL) || (destack->mem == NULL)) return NULL; if ((destack == NULL) || (destack->mem == NULL)) return NULL;
const size_t ALIGNED_LEN = __AlignSize(len, sizeof(uintptr_t)); const size_t ALIGNED_LEN = __AlignSize(len, sizeof(uintptr_t));
// back end stack is too low // back end stack is too low
if (destack->back - ALIGNED_LEN <= destack->front) return NULL; if (destack->back - ALIGNED_LEN <= destack->front) return NULL;
destack->back -= ALIGNED_LEN; destack->back -= ALIGNED_LEN;
return destack->back; return destack->back;
} }

+ 1
- 1
src/shapes.c View File

@ -1386,7 +1386,7 @@ void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Colo
rlPushMatrix(); rlPushMatrix();
rlTranslatef(center.x, center.y, 0.0f); rlTranslatef(center.x, center.y, 0.0f);
rlRotatef(rotation, 0.0f, 0.0f, 1.0f); rlRotatef(rotation, 0.0f, 0.0f, 1.0f);
rlBegin(RL_LINES); rlBegin(RL_LINES);
for (int i = 0; i < sides; i++) for (int i = 0; i < sides; i++)
{ {

+ 23
- 23
src/text.c View File

@ -555,7 +555,7 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
if (type != FONT_SDF) chars[i].image.data = stbtt_GetCodepointBitmap(&fontInfo, scaleFactor, scaleFactor, ch, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY); if (type != FONT_SDF) chars[i].image.data = stbtt_GetCodepointBitmap(&fontInfo, scaleFactor, scaleFactor, ch, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY);
else if (ch != 32) chars[i].image.data = stbtt_GetCodepointSDF(&fontInfo, scaleFactor, ch, SDF_CHAR_PADDING, SDF_ON_EDGE_VALUE, SDF_PIXEL_DIST_SCALE, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY); else if (ch != 32) chars[i].image.data = stbtt_GetCodepointSDF(&fontInfo, scaleFactor, ch, SDF_CHAR_PADDING, SDF_ON_EDGE_VALUE, SDF_PIXEL_DIST_SCALE, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY);
else chars[i].image.data = NULL; else chars[i].image.data = NULL;
stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL); stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL);
chars[i].advanceX = (int)((float)chars[i].advanceX*scaleFactor); chars[i].advanceX = (int)((float)chars[i].advanceX*scaleFactor);
@ -816,7 +816,7 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float scale,
// Character rectangle on screen // Character rectangle on screen
// NOTE: Quad is scaled proportionally to base character width-height // NOTE: Quad is scaled proportionally to base character width-height
Rectangle rec = { position.x, position.y, font.recs[index].width*scale, font.recs[index].height*scale }; Rectangle rec = { position.x, position.y, font.recs[index].width*scale, font.recs[index].height*scale };
DrawTexturePro(font.texture, font.recs[index], rec, (Vector2){ 0, 0 }, 0.0f, tint); DrawTexturePro(font.texture, font.recs[index], rec, (Vector2){ 0, 0 }, 0.0f, tint);
} }
@ -828,7 +828,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
int textOffsetY = 0; // Offset between lines (on line break '\n') int textOffsetY = 0; // Offset between lines (on line break '\n')
float textOffsetX = 0.0f; // Offset X to next character to draw float textOffsetX = 0.0f; // Offset X to next character to draw
float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor float scaleFactor = fontSize/font.baseSize; // Character quad scaling factor
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
@ -851,20 +851,20 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
} }
else else
{ {
if ((codepoint != ' ') && (codepoint != '\t'))
if ((codepoint != ' ') && (codepoint != '\t'))
{ {
Rectangle rec = { position.x + textOffsetX + font.chars[index].offsetX*scaleFactor, Rectangle rec = { position.x + textOffsetX + font.chars[index].offsetX*scaleFactor,
position.y + textOffsetY + font.chars[index].offsetY*scaleFactor,
font.recs[index].width*scaleFactor,
position.y + textOffsetY + font.chars[index].offsetY*scaleFactor,
font.recs[index].width*scaleFactor,
font.recs[index].height*scaleFactor }; font.recs[index].height*scaleFactor };
DrawTexturePro(font.texture, font.recs[index], rec, (Vector2){ 0, 0 }, 0.0f, tint); DrawTexturePro(font.texture, font.recs[index], rec, (Vector2){ 0, 0 }, 0.0f, tint);
} }
if (font.chars[index].advanceX == 0) textOffsetX += ((float)font.recs[index].width*scaleFactor + spacing); if (font.chars[index].advanceX == 0) textOffsetX += ((float)font.recs[index].width*scaleFactor + spacing);
else textOffsetX += ((float)font.chars[index].advanceX*scaleFactor + spacing); else textOffsetX += ((float)font.chars[index].advanceX*scaleFactor + spacing);
} }
i += (codepointByteCount - 1); // Move text bytes counter to next codepoint i += (codepointByteCount - 1); // Move text bytes counter to next codepoint
} }
} }
@ -888,7 +888,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
// Word/character wrapping mechanism variables // Word/character wrapping mechanism variables
enum { MEASURE_STATE = 0, DRAW_STATE = 1 }; enum { MEASURE_STATE = 0, DRAW_STATE = 1 };
int state = wordWrap? MEASURE_STATE : DRAW_STATE; int state = wordWrap? MEASURE_STATE : DRAW_STATE;
int startLine = -1; // Index where to begin drawing (where a line begins) int startLine = -1; // Index where to begin drawing (where a line begins)
int endLine = -1; // Index where to stop drawing (where a line ends) int endLine = -1; // Index where to stop drawing (where a line ends)
int lastk = -1; // Holds last value of the character position int lastk = -1; // Holds last value of the character position
@ -929,13 +929,13 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
endLine = (endLine < 1)? i : endLine; endLine = (endLine < 1)? i : endLine;
if (i == endLine) endLine -= codepointByteCount; if (i == endLine) endLine -= codepointByteCount;
if ((startLine + codepointByteCount) == endLine) endLine = (i - codepointByteCount); if ((startLine + codepointByteCount) == endLine) endLine = (i - codepointByteCount);
state = !state; state = !state;
} }
else if ((i + 1) == length) else if ((i + 1) == length)
{ {
endLine = i; endLine = i;
state = !state; state = !state;
} }
else if (codepoint == '\n') state = !state; else if (codepoint == '\n') state = !state;
@ -987,7 +987,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
DrawTexturePro(font.texture, font.recs[index], DrawTexturePro(font.texture, font.recs[index],
(Rectangle){ rec.x + textOffsetX + font.chars[index].offsetX*scaleFactor, (Rectangle){ rec.x + textOffsetX + font.chars[index].offsetX*scaleFactor,
rec.y + textOffsetY + font.chars[index].offsetY*scaleFactor, rec.y + textOffsetY + font.chars[index].offsetY*scaleFactor,
font.recs[index].width*scaleFactor, font.recs[index].height*scaleFactor },
font.recs[index].width*scaleFactor, font.recs[index].height*scaleFactor },
(Vector2){ 0, 0 }, 0.0f, (!isGlyphSelected)? tint : selectTint); (Vector2){ 0, 0 }, 0.0f, (!isGlyphSelected)? tint : selectTint);
} }
} }
@ -1000,7 +1000,7 @@ void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, f
endLine = -1; endLine = -1;
glyphWidth = 0; glyphWidth = 0;
k = lastk; k = lastk;
state = !state; state = !state;
} }
} }
@ -1085,7 +1085,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
int GetGlyphIndex(Font font, int codepoint) int GetGlyphIndex(Font font, int codepoint)
{ {
#define TEXT_CHARACTER_NOTFOUND 63 // Character: '?' #define TEXT_CHARACTER_NOTFOUND 63 // Character: '?'
#define UNORDERED_CHARSET #define UNORDERED_CHARSET
#if defined(UNORDERED_CHARSET) #if defined(UNORDERED_CHARSET)
int index = TEXT_CHARACTER_NOTFOUND; int index = TEXT_CHARACTER_NOTFOUND;
@ -1113,7 +1113,7 @@ int GetGlyphIndex(Font font, int codepoint)
int TextCopy(char *dst, const char *src) int TextCopy(char *dst, const char *src)
{ {
int bytes = 0; int bytes = 0;
if (dst != NULL) if (dst != NULL)
{ {
while (*src != '\0') while (*src != '\0')
@ -1121,7 +1121,7 @@ int TextCopy(char *dst, const char *src)
*dst = *src; *dst = *src;
dst++; dst++;
src++; src++;
bytes++; bytes++;
} }
@ -1161,14 +1161,14 @@ const char *TextFormat(const char *text, ...)
// We create an array of buffers so strings don't expire until MAX_TEXTFORMAT_BUFFERS invocations // We create an array of buffers so strings don't expire until MAX_TEXTFORMAT_BUFFERS invocations
static char buffers[MAX_TEXTFORMAT_BUFFERS][MAX_TEXT_BUFFER_LENGTH] = { 0 }; static char buffers[MAX_TEXTFORMAT_BUFFERS][MAX_TEXT_BUFFER_LENGTH] = { 0 };
static int index = 0; static int index = 0;
char *currentBuffer = buffers[index]; char *currentBuffer = buffers[index];
va_list args; va_list args;
va_start(args, text); va_start(args, text);
vsprintf(currentBuffer, text, args); vsprintf(currentBuffer, text, args);
va_end(args); va_end(args);
index += 1; // Move to next buffer for next function call index += 1; // Move to next buffer for next function call
if (index >= MAX_TEXTFORMAT_BUFFERS) index = 0; if (index >= MAX_TEXTFORMAT_BUFFERS) index = 0;
@ -1431,10 +1431,10 @@ int TextToInteger(const char *text)
if (text[0] == '-') sign = -1; if (text[0] == '-') sign = -1;
text++; text++;
} }
for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10 + (int)(text[i] - '0'); for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10 + (int)(text[i] - '0');
return value*sign;
return value*sign;
} }
// Encode text codepoint into utf8 text (memory must be freed!) // Encode text codepoint into utf8 text (memory must be freed!)
@ -1445,17 +1445,17 @@ char *TextToUtf8(int *codepoints, int length)
char *text = (char *)calloc(length*5, 1); char *text = (char *)calloc(length*5, 1);
const char *utf8 = NULL; const char *utf8 = NULL;
int size = 0; int size = 0;
for (int i = 0, bytes = 0; i < length; i++) for (int i = 0, bytes = 0; i < length; i++)
{ {
utf8 = CodepointToUtf8(codepoints[i], &bytes); utf8 = CodepointToUtf8(codepoints[i], &bytes);
strncpy(text + size, utf8, bytes); strncpy(text + size, utf8, bytes);
size += bytes; size += bytes;
} }
// Resize memory to text length + string NULL terminator // Resize memory to text length + string NULL terminator
text = RL_REALLOC(text, size + 1); text = RL_REALLOC(text, size + 1);
return text; return text;
} }

+ 6
- 6
src/textures.c View File

@ -458,9 +458,9 @@ void UnloadRenderTexture(RenderTexture2D target)
Color *GetImageData(Image image) Color *GetImageData(Image image)
{ {
if ((image.width == 0) || (image.height == 0)) return NULL; if ((image.width == 0) || (image.height == 0)) return NULL;
Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color)); Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color));
if (image.format >= COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats"); if (image.format >= COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats");
else else
{ {
@ -686,9 +686,9 @@ Vector4 *GetImageDataNormalized(Image image)
Rectangle GetImageAlphaBorder(Image image, float threshold) Rectangle GetImageAlphaBorder(Image image, float threshold)
{ {
Rectangle crop = { 0 }; Rectangle crop = { 0 };
Color *pixels = GetImageData(image); Color *pixels = GetImageData(image);
if (pixels != NULL) if (pixels != NULL)
{ {
int xMin = 65536; // Define a big enough number int xMin = 65536; // Define a big enough number
@ -2992,9 +2992,9 @@ static Image LoadAnimatedGIF(const char *fileName, int *frames, int **delays)
{ {
fseek(gifFile, 0L, SEEK_END); fseek(gifFile, 0L, SEEK_END);
int size = ftell(gifFile); int size = ftell(gifFile);
fseek(gifFile, 0L, SEEK_SET);
fseek(gifFile, 0L, SEEK_SET);
unsigned char *buffer = (unsigned char *)RL_CALLOC(size, sizeof(char));
unsigned char *buffer = (unsigned char *)RL_CALLOC(size, sizeof(char));
fread(buffer, sizeof(char), size, gifFile); fread(buffer, sizeof(char), size, gifFile);
fclose(gifFile); // Close file pointer fclose(gifFile); // Close file pointer

+ 1
- 1
src/utils.h View File

@ -34,7 +34,7 @@
#if defined(SUPPORT_TRACELOG) #if defined(SUPPORT_TRACELOG)
#define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__) #define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__)
#if defined(SUPPORT_TRACELOG_DEBUG) #if defined(SUPPORT_TRACELOG_DEBUG)
#define TRACELOGD(...) TraceLog(LOG_DEBUG, __VA_ARGS__) #define TRACELOGD(...) TraceLog(LOG_DEBUG, __VA_ARGS__)
#else #else

Loading…
Cancel
Save