From 8cb324b2da063fb4dac29b4d2a5495fdbe78351a Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Sun, 4 Mar 2018 16:26:49 +0100 Subject: Fix result of operation is garbage or undefined --- examples/others/audio_standalone.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'examples') diff --git a/examples/others/audio_standalone.c b/examples/others/audio_standalone.c index 97c3fd0d..38fe9935 100644 --- a/examples/others/audio_standalone.c +++ b/examples/others/audio_standalone.c @@ -76,13 +76,13 @@ int main() { // Initialization //-------------------------------------------------------------------------------------- - unsigned char key; - + static unsigned char key; + InitAudioDevice(); - + Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file - + Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg"); PlayMusicStream(music); @@ -99,23 +99,23 @@ int main() PlaySound(fxWav); key = 0; } - + if (key == 'd') { PlaySound(fxOgg); key = 0; } - + UpdateMusicStream(music); } - + // De-Initialization //-------------------------------------------------------------------------------------- UnloadSound(fxWav); // Unload sound data UnloadSound(fxOgg); // Unload sound data - + UnloadMusicStream(music); // Unload music stream data - + CloseAudioDevice(); //-------------------------------------------------------------------------------------- -- cgit v1.2.3 From df7460747926e3330886af2698994fa05b2595a9 Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Tue, 13 Mar 2018 17:04:49 +0100 Subject: Fix warning: illegal character encoding in string literal --- examples/models/models_yaw_pitch_roll.c | 66 ++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'examples') diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c index 625fc554..4fdbd4d7 100644 --- a/examples/models/models_yaw_pitch_roll.c +++ b/examples/models/models_yaw_pitch_roll.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.8 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Example based on Berni work on Raspberry Pi: +* Example based on Berni work on Raspberry Pi: * http://forum.raylib.com/index.php?p=/discussion/124/line-versus-triangle-drawing-order * * Copyright (c) 2017 Ramon Santamaria (@raysan5) @@ -30,25 +30,25 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - plane rotations (yaw, pitch, roll)"); - Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png"); + Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png"); Texture2D texBackground = LoadTexture("resources/background.png"); - Texture2D texPitch = LoadTexture("resources/pitch.png"); + Texture2D texPitch = LoadTexture("resources/pitch.png"); Texture2D texPlane = LoadTexture("resources/plane.png"); RenderTexture2D framebuffer = LoadRenderTexture(192, 192); - + // Model loading Model model = LoadModel("resources/plane.obj"); // Load OBJ model model.material.maps[MAP_DIFFUSE].texture = LoadTexture("resources/plane_diffuse.png"); // Set map diffuse texture - + GenTextureMipmaps(&model.material.maps[MAP_DIFFUSE].texture); - + Camera camera = { 0 }; camera.position = (Vector3){ 0.0f, 60.0f, -120.0f };// Camera position perspective camera.target = (Vector3){ 0.0f, 12.0f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 30.0f; // Camera field-of-view Y - + float pitch = 0.0f; float roll = 0.0f; float yaw = 0.0f; @@ -61,7 +61,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - + // Plane roll (x-axis) controls if (IsKeyDown(KEY_LEFT)) roll += 1.0f; else if (IsKeyDown(KEY_RIGHT)) roll -= 1.0f; @@ -70,7 +70,7 @@ int main() if (roll > 0.0f) roll -= 0.5f; else if (roll < 0.0f) roll += 0.5f; } - + // Plane yaw (y-axis) controls if (IsKeyDown(KEY_S)) yaw += 1.0f; else if (IsKeyDown(KEY_A)) yaw -= 1.0f; @@ -79,7 +79,7 @@ int main() if (yaw > 0.0f) yaw -= 0.5f; else if (yaw < 0.0f) yaw += 0.5f; } - + // Plane pitch (z-axis) controls if (IsKeyDown(KEY_DOWN)) pitch += 0.6f; else if (IsKeyDown(KEY_UP)) pitch -= 0.6f; @@ -88,7 +88,7 @@ int main() if (pitch > 0.3f) pitch -= 0.3f; else if (pitch < -0.3f) pitch += 0.3f; } - + // Wraps the phase of an angle to fit between -180 and +180 degrees int pitchOffset = pitch; while (pitchOffset > 180) pitchOffset -= 360; @@ -96,20 +96,20 @@ int main() pitchOffset *= 10; Matrix transform = MatrixIdentity(); - + transform = MatrixMultiply(transform, MatrixRotateZ(DEG2RAD*roll)); transform = MatrixMultiply(transform, MatrixRotateX(DEG2RAD*pitch)); transform = MatrixMultiply(transform, MatrixRotateY(DEG2RAD*yaw)); - + model.transform = transform; //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); - + ClearBackground(RAYWHITE); - + // Draw framebuffer texture (Ahrs Display) int centerX = framebuffer.texture.width/2; int centerY = framebuffer.texture.height/2; @@ -126,11 +126,11 @@ int main() DrawTexturePro(texPitch, (Rectangle){ 0, 0, texPitch.width, texPitch.height }, (Rectangle){ centerX, centerY, texPitch.width*scaleFactor, texPitch.height*scaleFactor }, (Vector2){ texPitch.width/2*scaleFactor, texPitch.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE); - + DrawTexturePro(texPlane, (Rectangle){ 0, 0, texPlane.width, texPlane.height }, - (Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor }, + (Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor }, (Vector2){ texPlane.width/2*scaleFactor, texPlane.height/2*scaleFactor }, 0, WHITE); - + EndBlendMode(); EndTextureMode(); @@ -147,7 +147,7 @@ int main() DrawAngleGauge(texAngleGauge, 80, 70, roll, "roll", RED); DrawAngleGauge(texAngleGauge, 190, 70, pitch, "pitch", GREEN); DrawAngleGauge(texAngleGauge, 300, 70, yaw, "yaw", SKYBLUE); - + DrawRectangle(30, 360, 260, 70, Fade(SKYBLUE, 0.5f)); DrawRectangleLines(30, 360, 260, 70, Fade(DARKBLUE, 0.5f)); DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 370, 10, DARKGRAY); @@ -155,31 +155,31 @@ int main() DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 410, 10, DARKGRAY); // Draw framebuffer texture - DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height }, + DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height }, (Vector2){ screenWidth - framebuffer.texture.width - 20, 20 }, Fade(WHITE, 0.8f)); - + DrawRectangleLines(screenWidth - framebuffer.texture.width - 20, 20, framebuffer.texture.width, framebuffer.texture.height, DARKGRAY); - + EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- - + // Unload all loaded data UnloadModel(model); - + UnloadRenderTexture(framebuffer); - - UnloadTexture(texAngleGauge); + + UnloadTexture(texAngleGauge); UnloadTexture(texBackground); - UnloadTexture(texPitch); + UnloadTexture(texPitch); UnloadTexture(texPlane); - + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- - + return 0; } @@ -192,7 +192,7 @@ void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[ int textSize = 20; DrawTexturePro(angleGauge, srcRec, dstRec, origin, angle, color); - - DrawText(FormatText("%5.1f°", angle), x - MeasureText(FormatText("%5.1f°", angle), textSize) / 2, y + 10, textSize, DARKGRAY); - DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY); -} \ No newline at end of file + + DrawText(FormatText("%5.1f", angle), x - MeasureText(FormatText("%5.1f", angle), textSize) / 2, y + 10, textSize, DARKGRAY); + DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY); +} -- cgit v1.2.3 From 9459186125f2e5f7dca7606acd8b2871c6cde35f Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Tue, 13 Mar 2018 17:13:46 +0100 Subject: Fix call argument is an uninitialized value --- examples/others/bunnymark.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/others/bunnymark.c b/examples/others/bunnymark.c index 1ada54db..8b524b01 100644 --- a/examples/others/bunnymark.c +++ b/examples/others/bunnymark.c @@ -10,7 +10,6 @@ ********************************************************************************************/ #include "raylib.h" - #include // Required for: malloc(), free() #define MAX_BUNNIES 100000 // 100K bunnies @@ -29,15 +28,16 @@ int main() int screenHeight = 960; InitWindow(screenWidth, screenHeight, "raylib example - Bunnymark"); - + Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png"); - + Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array + int bunniesCount = 0; // Bunnies counter SetTargetFPS(60); //-------------------------------------------------------------------------------------- - + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { @@ -54,7 +54,7 @@ int main() bunniesCount++; } } - + // Update bunnies for (int i = 0; i < bunniesCount; i++) { @@ -65,14 +65,14 @@ int main() if ((bunnies[i].position.y > GetScreenHeight()) || (bunnies[i].position.y < 0)) bunnies[i].speed.y *= -1; } //---------------------------------------------------------------------------------- - + // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); - - for (int i = 0; i <= bunniesCount; i++) + + for (int i = 0; i < bunniesCount; i++) { // NOTE: When internal QUADS batch limit is reached, a draw call is launched and // batching buffer starts being filled again; before launching the draw call, @@ -80,11 +80,10 @@ int main() // a stall and consequently a frame drop, limiting number of bunnies drawn at 60 fps DrawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, RAYWHITE); } - + DrawRectangle(0, 0, screenWidth, 40, LIGHTGRAY); DrawText("raylib bunnymark", 10, 10, 20, DARKGRAY); DrawText(FormatText("bunnies: %i", bunniesCount), 400, 10, 20, RED); - DrawFPS(260, 10); EndDrawing(); @@ -94,9 +93,9 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- free(bunnies); - + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} -- cgit v1.2.3 From 6a3eca3f9295113db96f6442ec5ad8d465302084 Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Thu, 15 Mar 2018 23:51:39 +0100 Subject: Fix value stored to 'body' is never read --- examples/physac/physics_shatter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/physac/physics_shatter.c b/examples/physac/physics_shatter.c index 6b474cd3..07c3c4b3 100644 --- a/examples/physac/physics_shatter.c +++ b/examples/physac/physics_shatter.c @@ -38,8 +38,8 @@ int main() SetPhysicsGravity(0, 0); // Create random polygon physics body to shatter - PhysicsBody body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); - + CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); + SetTargetFPS(60); //-------------------------------------------------------------------------------------- @@ -53,7 +53,7 @@ int main() ResetPhysics(); // Create random polygon physics body to shatter - body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); + CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); } if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input -- cgit v1.2.3 From 551cf506855de9f04a713df8380278ccee15bb22 Mon Sep 17 00:00:00 2001 From: "maficccc@gmail.com" Date: Fri, 16 Mar 2018 10:19:09 +0100 Subject: Fix Uninitialized argument value --- examples/core/core_3d_picking.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c index 7658b393..56e80f2a 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -29,11 +29,11 @@ int main() Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; Vector3 cubeSize = { 2.0f, 2.0f, 2.0f }; - - Ray ray; // Picking line ray - + + Ray ray = {0.0f, 0.0f, 0.0f}; // Picking line ray + bool collision = false; - + SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode SetTargetFPS(60); // Set our game to run at 60 frames-per-second @@ -45,11 +45,11 @@ int main() // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera); // Update camera - + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { ray = GetMouseRay(GetMousePosition(), camera); - + // Check collision between ray and box collision = CheckCollisionRayBox(ray, (BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 }, @@ -65,7 +65,7 @@ int main() Begin3dMode(camera); - if (collision) + if (collision) { DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED); DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON); @@ -77,15 +77,14 @@ int main() DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY); DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY); } - + DrawRay(ray, MAROON); - DrawGrid(10, 1.0f); End3dMode(); - + DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY); - + if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN); DrawFPS(10, 10); @@ -100,4 +99,4 @@ int main() //-------------------------------------------------------------------------------------- return 0; -} \ No newline at end of file +} -- cgit v1.2.3