diff --git a/src/core.c b/src/core.c index df6b642a0..77a8d47e7 100644 --- a/src/core.c +++ b/src/core.c @@ -547,27 +547,27 @@ typedef enum { static const char *autoEventTypeName[] = { "EVENT_NONE", - "INPUT_KEY_UP", - "INPUT_KEY_DOWN", - "INPUT_KEY_PRESSED", - "INPUT_KEY_RELEASED", - "INPUT_MOUSE_BUTTON_UP", - "INPUT_MOUSE_BUTTON_DOWN", - "INPUT_MOUSE_POSITION", - "INPUT_MOUSE_WHEEL_MOTION", - "INPUT_GAMEPAD_CONNECT", - "INPUT_GAMEPAD_DISCONNECT", - "INPUT_GAMEPAD_BUTTON_UP", + "INPUT_KEY_UP", + "INPUT_KEY_DOWN", + "INPUT_KEY_PRESSED", + "INPUT_KEY_RELEASED", + "INPUT_MOUSE_BUTTON_UP", + "INPUT_MOUSE_BUTTON_DOWN", + "INPUT_MOUSE_POSITION", + "INPUT_MOUSE_WHEEL_MOTION", + "INPUT_GAMEPAD_CONNECT", + "INPUT_GAMEPAD_DISCONNECT", + "INPUT_GAMEPAD_BUTTON_UP", "INPUT_GAMEPAD_BUTTON_DOWN", "INPUT_GAMEPAD_AXIS_MOTION", - "INPUT_TOUCH_UP", - "INPUT_TOUCH_DOWN", - "INPUT_TOUCH_POSITION", - "INPUT_GESTURE", - "WINDOW_CLOSE", - "WINDOW_MAXIMIZE", - "WINDOW_MINIMIZE", - "WINDOW_RESIZE", + "INPUT_TOUCH_UP", + "INPUT_TOUCH_DOWN", + "INPUT_TOUCH_POSITION", + "INPUT_GESTURE", + "WINDOW_CLOSE", + "WINDOW_MAXIMIZE", + "WINDOW_MINIMIZE", + "WINDOW_RESIZE", "ACTION_TAKE_SCREENSHOT", "ACTION_SETTARGETFPS" }; @@ -835,7 +835,7 @@ void InitWindow(int width, int height, const char *title) CORE.Window.ready = InitGraphicsDevice(width, height); // If graphic device is no properly initialized, we end program - if (!CORE.Window.ready) + if (!CORE.Window.ready) { TRACELOG(LOG_FATAL, "Failed to initialize Graphic Device"); return; @@ -896,12 +896,12 @@ void InitWindow(int width, int height, const char *title) CORE.Input.Mouse.currentPosition.x = (float)CORE.Window.screen.width/2.0f; CORE.Input.Mouse.currentPosition.y = (float)CORE.Window.screen.height/2.0f; - + #if defined(SUPPORT_EVENTS_AUTOMATION) events = (AutomationEvent *)malloc(MAX_CODE_AUTOMATION_EVENTS*sizeof(AutomationEvent)); CORE.Time.frameCounter = 0; #endif - + #endif // PLATFORM_DESKTOP || PLATFORM_WEB || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP } @@ -2040,12 +2040,12 @@ void EndDrawing(void) } PollInputEvents(); // Poll user events - + #if defined(SUPPORT_EVENTS_AUTOMATION) if (eventsRecording) RecordAutomationEvent(CORE.Time.frameCounter); // TODO: When should we play? After/before/replace PollInputEvents()? - if (eventsPlaying) + if (eventsPlaying) { if (CORE.Time.frameCounter >= eventCount) eventsPlaying = false; PlayAutomationEvent(CORE.Time.frameCounter); @@ -4813,7 +4813,7 @@ static void PollInputEvents(void) // Register previous mouse wheel state CORE.Input.Mouse.previousWheelMove = CORE.Input.Mouse.currentWheelMove; CORE.Input.Mouse.currentWheelMove = 0.0f; - + // Register previous mouse position CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; #endif @@ -5070,7 +5070,7 @@ static void SwapBuffers(void) { gbm_surface_release_buffer(CORE.Window.gbmSurface, CORE.Window.prevBO); } - + CORE.Window.prevBO = bo; #endif // PLATFORM_DRM #endif // PLATFORM_ANDROID || PLATFORM_RPI || PLATFORM_DRM || PLATFORM_UWP @@ -5190,7 +5190,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i else if (key == GLFW_KEY_F11 && action == GLFW_PRESS) { eventsRecording = !eventsRecording; - + // On finish recording, we export events into a file if (!eventsRecording) ExportAutomationEvents("eventsrec.rep"); } @@ -5198,7 +5198,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i { LoadAutomationEvents("eventsrec.rep"); eventsPlaying = true; - + TRACELOG(LOG_WARNING, "eventsPlaying enabled!"); } #endif @@ -6796,22 +6796,22 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt static void LoadAutomationEvents(const char *fileName) { //unsigned char fileId[4] = { 0 }; - + // Load binary /* FILE *repFile = fopen(fileName, "rb"); fread(fileId, 4, 1, repFile); - + if ((fileId[0] == 'r') && (fileId[1] == 'E') && (fileId[2] == 'P') && (fileId[1] == ' ')) { fread(&eventCount, sizeof(int), 1, repFile); TraceLog(LOG_WARNING, "Events loaded: %i\n", eventCount); fread(events, sizeof(AutomationEvent), eventCount, repFile); } - + fclose(repFile); */ - + // Load events (text file) FILE *repFile = fopen(fileName, "rt"); @@ -6827,20 +6827,20 @@ static void LoadAutomationEvents(const char *fileName) if (buffer[0] == 'c') sscanf(buffer, "c %i", &eventCount); else if (buffer[0] == 'e') { - sscanf(buffer, "e %d %d %d %d %d", &events[count].frame, &events[count].type, + sscanf(buffer, "e %d %d %d %d %d", &events[count].frame, &events[count].type, &events[count].params[0], &events[count].params[1], &events[count].params[2]); - + count++; } fgets(buffer, 256, repFile); } - + if (count != eventCount) TRACELOG(LOG_WARNING, "Events count provided is different than count"); fclose(repFile); } - + TRACELOG(LOG_WARNING, "Events loaded: %i", eventCount); } @@ -6858,23 +6858,23 @@ static void ExportAutomationEvents(const char *fileName) fwrite(events, sizeof(AutomationEvent), eventCount, repFile); fclose(repFile); */ - + // Export events as text FILE *repFile = fopen(fileName, "wt"); - + if (repFile != NULL) { fprintf(repFile, "# Automation events list\n"); fprintf(repFile, "# c \n"); fprintf(repFile, "# e // \n"); - + fprintf(repFile, "c %i\n", eventCount); for (int i = 0; i < eventCount; i++) { - fprintf(repFile, "e %i %i %i %i %i // %s\n", events[i].frame, events[i].type, + fprintf(repFile, "e %i %i %i %i %i // %s\n", events[i].frame, events[i].type, events[i].params[0], events[i].params[1], events[i].params[2], autoEventTypeName[events[i].type]); } - + fclose(repFile); } } @@ -6893,11 +6893,11 @@ static void RecordAutomationEvent(unsigned int frame) events[eventCount].params[0] = key; events[eventCount].params[1] = 0; events[eventCount].params[2] = 0; - + TRACELOG(LOG_INFO, "[%i] INPUT_KEY_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); eventCount++; } - + // INPUT_KEY_DOWN if (CORE.Input.Keyboard.currentKeyState[key]) { @@ -6922,11 +6922,11 @@ static void RecordAutomationEvent(unsigned int frame) events[eventCount].params[0] = button; events[eventCount].params[1] = 0; events[eventCount].params[2] = 0; - + TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_BUTTON_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); eventCount++; } - + // INPUT_MOUSE_BUTTON_DOWN if (CORE.Input.Mouse.currentButtonState[button]) { @@ -6940,7 +6940,7 @@ static void RecordAutomationEvent(unsigned int frame) eventCount++; } } - + // INPUT_MOUSE_POSITION (only saved if changed) if (((int)CORE.Input.Mouse.currentPosition.x != (int)CORE.Input.Mouse.previousPosition.x) || ((int)CORE.Input.Mouse.currentPosition.y != (int)CORE.Input.Mouse.previousPosition.y)) @@ -6954,7 +6954,7 @@ static void RecordAutomationEvent(unsigned int frame) TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_POSITION: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); eventCount++; } - + // INPUT_MOUSE_WHEEL_MOTION if ((int)CORE.Input.Mouse.currentWheelMove != (int)CORE.Input.Mouse.previousWheelMove) { @@ -6967,7 +6967,7 @@ static void RecordAutomationEvent(unsigned int frame) TRACELOG(LOG_INFO, "[%i] INPUT_MOUSE_WHEEL_MOTION: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); eventCount++; } - + for (int id = 0; id < MAX_TOUCH_POINTS; id++) { // INPUT_TOUCH_UP @@ -6982,7 +6982,7 @@ static void RecordAutomationEvent(unsigned int frame) TRACELOG(LOG_INFO, "[%i] INPUT_TOUCH_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); eventCount++; } - + // INPUT_TOUCH_DOWN if (CORE.Input.Touch.currentTouchState[id]) { @@ -6991,11 +6991,11 @@ static void RecordAutomationEvent(unsigned int frame) events[eventCount].params[0] = id; events[eventCount].params[1] = 0; events[eventCount].params[2] = 0; - + TRACELOG(LOG_INFO, "[%i] INPUT_TOUCH_DOWN: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); eventCount++; } - + // INPUT_TOUCH_POSITION // TODO: It requires the id! /* @@ -7013,7 +7013,7 @@ static void RecordAutomationEvent(unsigned int frame) } */ } - + for (int gamepad = 0; gamepad < MAX_GAMEPADS; gamepad++) { // INPUT_GAMEPAD_CONNECT @@ -7024,7 +7024,7 @@ static void RecordAutomationEvent(unsigned int frame) // TODO: Save gamepad connect event } */ - + // INPUT_GAMEPAD_DISCONNECT /* if ((CORE.Input.Gamepad.currentState[gamepad] != CORE.Input.Gamepad.previousState[gamepad]) && @@ -7033,7 +7033,7 @@ static void RecordAutomationEvent(unsigned int frame) // TODO: Save gamepad disconnect event } */ - + for (int button = 0; button < MAX_GAMEPAD_BUTTONS; button++) { // INPUT_GAMEPAD_BUTTON_UP @@ -7044,11 +7044,11 @@ static void RecordAutomationEvent(unsigned int frame) events[eventCount].params[0] = gamepad; events[eventCount].params[1] = button; events[eventCount].params[2] = 0; - + TRACELOG(LOG_INFO, "[%i] INPUT_GAMEPAD_BUTTON_UP: %i, %i, %i", events[eventCount].frame, events[eventCount].params[0], events[eventCount].params[1], events[eventCount].params[2]); eventCount++; } - + // INPUT_GAMEPAD_BUTTON_DOWN if (CORE.Input.Gamepad.currentButtonState[gamepad][button]) { @@ -7062,7 +7062,7 @@ static void RecordAutomationEvent(unsigned int frame) eventCount++; } } - + for (int axis = 0; axis < MAX_GAMEPAD_AXIS; axis++) { // INPUT_GAMEPAD_AXIS_MOTION @@ -7079,7 +7079,7 @@ static void RecordAutomationEvent(unsigned int frame) } } } - + // INPUT_GESTURE if (GESTURES.current != GESTURE_NONE) { @@ -7128,19 +7128,19 @@ static void PlayAutomationEvent(unsigned int frame) case INPUT_GAMEPAD_AXIS_MOTION: // param[0]: gamepad, param[1]: axis, param[2]: delta { CORE.Input.Gamepad.axisState[events[i].params[0]][events[i].params[1]] = ((float)events[i].params[2]/32768.0f); - } break; + } break; case INPUT_GESTURE: GESTURES.current = events[i].params[0]; break; // param[0]: gesture (enum Gesture) -> gestures.h: GESTURES.current - + // Window events case WINDOW_CLOSE: CORE.Window.shouldClose = true; break; case WINDOW_MAXIMIZE: MaximizeWindow(); break; case WINDOW_MINIMIZE: MinimizeWindow(); break; case WINDOW_RESIZE: SetWindowSize(events[i].params[0], events[i].params[1]); break; - + // Custom events - case ACTION_TAKE_SCREENSHOT: + case ACTION_TAKE_SCREENSHOT: { - TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter)); + TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter)); screenshotCounter++; } break; case ACTION_SETTARGETFPS: SetTargetFPS(events[i].params[0]); break; diff --git a/src/models.c b/src/models.c index e927fa56a..09cd431ce 100644 --- a/src/models.c +++ b/src/models.c @@ -2815,7 +2815,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector { // NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width Vector2 sizeRatio = { size.y, size.x*(float)source.height/source.width }; - + Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up); Vector3 right = { matView.m0, matView.m4, matView.m8 }; @@ -2826,7 +2826,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector Vector3 rightScaled = Vector3Scale(right, sizeRatio.x/2); Vector3 upScaled = Vector3Scale(up, sizeRatio.y/2); - + Vector3 p1 = Vector3Add(rightScaled, upScaled); Vector3 p2 = Vector3Subtract(rightScaled, upScaled); @@ -2834,25 +2834,25 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector Vector3 topRight = p1; Vector3 bottomRight = p2; Vector3 bottomLeft = Vector3Scale(p1, -1); - + if (rotation != 0.0f) - { + { float sinRotation = sinf(rotation*DEG2RAD); float cosRotation = cosf(rotation*DEG2RAD); - + // NOTE: (-1, 1) is the range where origin.x, origin.y is inside the texture float rotateAboutX = sizeRatio.x*origin.x/2; float rotateAboutY = sizeRatio.y*origin.y/2; - + float xtvalue, ytvalue; float rotatedX, rotatedY; - + xtvalue = Vector3DotProduct(right, topLeft) - rotateAboutX; // Project points to x and y coordinates on the billboard plane ytvalue = Vector3DotProduct(up, topLeft) - rotateAboutY; - rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; // Rotate about the point origin + rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; // Rotate about the point origin rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; topLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); // Translate back to cartesian coordinates - + xtvalue = Vector3DotProduct(right, topRight) - rotateAboutX; ytvalue = Vector3DotProduct(up, topRight) - rotateAboutY; rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; @@ -2864,20 +2864,20 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; bottomRight = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); - + xtvalue = Vector3DotProduct(right, bottomLeft)-rotateAboutX; ytvalue = Vector3DotProduct(up, bottomLeft)-rotateAboutY; rotatedX = xtvalue*cosRotation - ytvalue*sinRotation + rotateAboutX; rotatedY = xtvalue*sinRotation + ytvalue*cosRotation + rotateAboutY; bottomLeft = Vector3Add(Vector3Scale(up, rotatedY), Vector3Scale(right, rotatedX)); } - + // Translate points to the draw center (position) topLeft = Vector3Add(topLeft, position); topRight = Vector3Add(topRight, position); bottomRight = Vector3Add(bottomRight, position); bottomLeft = Vector3Add(bottomLeft, position); - + rlCheckRenderBatchLimit(4); rlSetTexture(texture.id); @@ -2902,7 +2902,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector rlVertex3f(topRight.x, topRight.y, topRight.z); rlEnd(); - rlSetTexture(0); + rlSetTexture(0); } // Draw a bounding box with wires @@ -2992,7 +2992,7 @@ RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius) collision.hit = d >= 0.0f; // Check if ray origin is inside the sphere to calculate the correct collision point - if (distance < radius) + if (distance < radius) { collision.distance = vector + sqrtf(d); @@ -3001,8 +3001,8 @@ RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius) // Calculate collision normal (pointing outwards) collision.normal = Vector3Negate(Vector3Normalize(Vector3Subtract(collision.point, center))); - } - else + } + else { collision.distance = vector - sqrtf(d); @@ -3012,7 +3012,7 @@ RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius) // Calculate collision normal (pointing inwards) collision.normal = Vector3Normalize(Vector3Subtract(collision.point, center)); } - + return collision; } @@ -3119,7 +3119,7 @@ RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform) } } } - + return collision; } @@ -3374,7 +3374,7 @@ static Model LoadOBJ(const char *fileName) tinyobj_materials_free(materials, materialCount); UnloadFileText(fileText); - + RL_FREE(matFaces); RL_FREE(vCount); RL_FREE(vtCount); @@ -3696,11 +3696,11 @@ static Model LoadIQM(const char *fileName) //fseek(iqmFile, va[i].offset, SEEK_SET); //fread(blendw, iqmHeader->num_vertexes*4*sizeof(unsigned char), 1, iqmFile); memcpy(color, fileDataPtr + va[i].offset, iqmHeader->num_vertexes*4*sizeof(unsigned char)); - + for (unsigned int m = 0; m < iqmHeader->num_meshes; m++) { model.meshes[m].colors = RL_CALLOC(model.meshes[m].vertexCount*4, sizeof(unsigned char)); - + int vCounter = 0; for (unsigned int i = imesh[m].first_vertex*4; i < (imesh[m].first_vertex + imesh[m].num_vertexes)*4; i++) { diff --git a/src/raudio.c b/src/raudio.c index abc9579ff..eebd4ce83 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1784,7 +1784,7 @@ AudioStream LoadAudioStream(unsigned int sampleRate, unsigned int sampleSize, un // The size of a streaming buffer must be at least double the size of a period unsigned int periodSize = AUDIO.System.device.playback.internalPeriodSizeInFrames; - + // If the buffer is not set, compute one that would give us a buffer good enough for a decent frame rate unsigned int subBufferSize = (AUDIO.Buffer.defaultSize == 0)? AUDIO.System.device.sampleRate/30 : AUDIO.Buffer.defaultSize; @@ -2352,7 +2352,7 @@ static bool TextIsEqual(const char *text1, const char *text2) static const char *TextToLower(const char *text) { #define MAX_TEXT_BUFFER_LENGTH 1024 - + static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) diff --git a/src/raymath.h b/src/raymath.h index 4be5739c4..6ab666e51 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -1389,7 +1389,7 @@ RMDEF Quaternion QuaternionFromMatrix(Matrix mat) RMDEF Matrix QuaternionToMatrix(Quaternion q) { Matrix result = MatrixIdentity(); - + float a2 = q.x*q.x; float b2 = q.y*q.y; float c2 = q.z*q.z; diff --git a/src/shapes.c b/src/shapes.c index 5acd9810d..788c3c830 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -130,9 +130,9 @@ void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color) float scale = thick/(2*length); Vector2 radius = { -scale*delta.y, scale*delta.x }; Vector2 strip[4] = { - { startPos.x - radius.x, startPos.y - radius.y }, + { startPos.x - radius.x, startPos.y - radius.y }, { startPos.x + radius.x, startPos.y + radius.y }, - { endPos.x - radius.x, endPos.y - radius.y }, + { endPos.x - radius.x, endPos.y - radius.y }, { endPos.x + radius.x, endPos.y + radius.y } }; diff --git a/src/text.c b/src/text.c index 9a42796e4..e18afe41e 100644 --- a/src/text.c +++ b/src/text.c @@ -849,7 +849,7 @@ void DrawText(const char *text, int posX, int posY, int fontSize, Color color) void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint) { if (font.texture.id == 0) font = GetFontDefault(); // Security check in case of not valid font - + int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop int textOffsetY = 0; // Offset between lines (on line break '\n') diff --git a/src/textures.c b/src/textures.c index af0985969..7017660ba 100644 --- a/src/textures.c +++ b/src/textures.c @@ -503,7 +503,7 @@ bool ExportImageAsCode(Image image, const char *fileName) success = SaveFileText(fileName, txtData); RL_FREE(txtData); - + #endif // SUPPORT_IMAGE_EXPORT if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image exported successfully", fileName);