diff --git a/examples/audio_music_stream.c b/examples/audio_music_stream.c index e61d4839..8c668cce 100644 --- a/examples/audio_music_stream.c +++ b/examples/audio_music_stream.c @@ -27,7 +27,7 @@ int main() PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream int framesCounter = 0; - float timePlayed = 0; + float timePlayed = 0.0f; //float volume = 1.0; SetTargetFPS(60); // Set our game to run at 60 frames-per-second diff --git a/examples/audio_sound_loading.c b/examples/audio_sound_loading.c index 1376a27d..8819aad1 100644 --- a/examples/audio_sound_loading.c +++ b/examples/audio_sound_loading.c @@ -26,6 +26,8 @@ int main() Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/core_3d_camera_first_person.c b/examples/core_3d_camera_first_person.c index aa947c3c..8a092275 100644 --- a/examples/core_3d_camera_first_person.c +++ b/examples/core_3d_camera_first_person.c @@ -23,7 +23,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); // Define the camera to look into our 3d world - Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; // Generates some random columns float heights[MAX_COLUMNS]; @@ -37,7 +37,7 @@ int main() colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; } - Vector3 playerPosition = { 4, 2, 4 }; // Define player position + Vector3 playerPosition = { 4.0f, 2.0f, 4.0f }; // Define player position SetCameraMode(CAMERA_FIRST_PERSON); // Set a first person camera mode @@ -60,16 +60,16 @@ int main() Begin3dMode(camera); - DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 32, 32 }, LIGHTGRAY); // Draw ground - DrawCube((Vector3){ -16, 2.5, 0 }, 1, 5, 32, BLUE); // Draw a blue wall - DrawCube((Vector3){ 16, 2.5, 0 }, 1, 5, 32, LIME); // Draw a green wall - DrawCube((Vector3){ 0, 2.5, 16 }, 32, 5, 1, GOLD); // Draw a yellow wall + DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground + DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall + DrawCube((Vector3){ 16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, LIME); // Draw a green wall + DrawCube((Vector3){ 0.0f, 2.5f, 16.0f }, 32.0f, 5.0f, 1.0f, GOLD); // Draw a yellow wall // Draw some cubes around for (int i = 0; i < MAX_COLUMNS; i++) { - DrawCube(positions[i], 2, heights[i], 2, colors[i]); - DrawCubeWires(positions[i], 2, heights[i], 2, MAROON); + DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]); + DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON); } End3dMode(); diff --git a/examples/core_3d_camera_free.c b/examples/core_3d_camera_free.c index be44ed2a..df1b480c 100644 --- a/examples/core_3d_camera_free.c +++ b/examples/core_3d_camera_free.c @@ -21,9 +21,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); // Define the camera to look into our 3d world - Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera; + camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; + camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - Vector3 cubePosition = { 0.0, 0.0, 0.0 }; + Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; SetCameraMode(CAMERA_FREE); // Set a free camera mode SetCameraPosition(camera.position); // Set internal camera position to match our camera position @@ -48,10 +51,10 @@ int main() Begin3dMode(camera); - DrawCube(cubePosition, 2, 2, 2, RED); - DrawCubeWires(cubePosition, 2, 2, 2, MAROON); + DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); + DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - DrawGrid(10.0, 1.0); + DrawGrid(10, 1.0f); End3dMode(); diff --git a/examples/core_3d_mode.c b/examples/core_3d_mode.c index 3a5fae13..40415fea 100644 --- a/examples/core_3d_mode.c +++ b/examples/core_3d_mode.c @@ -22,11 +22,11 @@ int main() // Define the camera to look into our 3d world Camera camera; - camera.position = (Vector3){ 0.0, 10.0, 10.0 }; - camera.target = (Vector3){ 0.0, 0.0, 0.0 }; - camera.up = (Vector3){ 0.0, 1.0, 0.0 }; + camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; + camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - Vector3 cubePosition = { 0.0, 0.0, 0.0 }; + Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -47,10 +47,10 @@ int main() Begin3dMode(camera); - DrawCube(cubePosition, 2.0, 2.0, 2.0, RED); - DrawCubeWires(cubePosition, 2.0, 2.0, 2.0, MAROON); + DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); + DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - DrawGrid(10.0, 1.0); + DrawGrid(10, 1.0f); End3dMode(); diff --git a/examples/core_3d_picking.c b/examples/core_3d_picking.c index 0d6f4ac7..9a6cc138 100644 --- a/examples/core_3d_picking.c +++ b/examples/core_3d_picking.c @@ -21,10 +21,10 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking"); // Define the camera to look into our 3d world - Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; - Vector3 cubePosition = { 0.0, 1.0, 0.0 }; - Vector3 cubeSize = { 2.0, 2.0, 2.0 }; + Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; + Vector3 cubeSize = { 2.0f, 2.0f, 2.0f }; Ray ray; // Picking line ray @@ -50,8 +50,8 @@ int main() // Check collision between ray and box collision = CheckCollisionRayBox(ray, - (Vector3){cubePosition.x - cubeSize.x / 2,cubePosition.y - cubeSize.y / 2,cubePosition.z - cubeSize.z / 2}, - (Vector3){cubePosition.x + cubeSize.x / 2,cubePosition.y + cubeSize.y / 2,cubePosition.z + cubeSize.z / 2}); + (Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 }, + (Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }); } //---------------------------------------------------------------------------------- @@ -65,10 +65,10 @@ int main() DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY); DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY); - - DrawGrid(10.0, 1.0); DrawRay(ray, MAROON); + + DrawGrid(10, 1.0f); End3dMode(); diff --git a/examples/core_basic_window.c b/examples/core_basic_window.c index b039e53f..fb83400a 100644 --- a/examples/core_basic_window.c +++ b/examples/core_basic_window.c @@ -29,6 +29,8 @@ int main() int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/core_input_gamepad.c b/examples/core_input_gamepad.c index 64be4cd8..1de2d424 100644 --- a/examples/core_input_gamepad.c +++ b/examples/core_input_gamepad.c @@ -23,8 +23,8 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input"); - Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; - Vector2 gamepadMovement = { 0, 0 }; + Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 }; + Vector2 gamepadMovement = { 0.0f, 0.0f }; SetTargetFPS(60); // Set target frames-per-second //-------------------------------------------------------------------------------------- @@ -43,8 +43,8 @@ int main() if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A)) { - ballPosition.x = screenWidth/2; - ballPosition.y = screenHeight/2; + ballPosition.x = (float)screenWidth/2; + ballPosition.y = (float)screenHeight/2; } } //---------------------------------------------------------------------------------- diff --git a/examples/core_input_keys.c b/examples/core_input_keys.c index 99d5e516..b2305246 100644 --- a/examples/core_input_keys.c +++ b/examples/core_input_keys.c @@ -20,7 +20,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input"); - Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; + Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 }; SetTargetFPS(60); // Set target frames-per-second //-------------------------------------------------------------------------------------- @@ -30,10 +30,10 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8; - if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8; - if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8; - if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8; + if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8f; + if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8f; + if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8f; + if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8f; //---------------------------------------------------------------------------------- // Draw diff --git a/examples/core_input_mouse.c b/examples/core_input_mouse.c index c64b421e..358b5fd6 100644 --- a/examples/core_input_mouse.c +++ b/examples/core_input_mouse.c @@ -20,8 +20,9 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input"); - int mouseX, mouseY; - Vector2 ballPosition = { -100.0, -100.0 }; + Vector2 ballPosition = { -100.0f, -100.0f }; + + SetTargetFPS(60); //--------------------------------------------------------------------------------------- // Main game loop @@ -31,11 +32,7 @@ int main() //---------------------------------------------------------------------------------- if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { - mouseX = GetMouseX(); - mouseY = GetMouseY(); - - ballPosition.x = (float)mouseX; - ballPosition.y = (float)mouseY; + ballPosition = GetMousePosition(); } //---------------------------------------------------------------------------------- diff --git a/examples/core_random_values.c b/examples/core_random_values.c index 98e0e91e..06e550dd 100644 --- a/examples/core_random_values.c +++ b/examples/core_random_values.c @@ -22,7 +22,7 @@ int main() int framesCounter = 0; // Variable used to count frames - int randValue = GetRandomValue(-8,5); // Get a random integer number between -8 and 5 (both included) + int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included) SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -37,7 +37,7 @@ int main() // Every two seconds (120 frames) a new random value is generated if (((framesCounter/120)%2) == 1) { - randValue = GetRandomValue(-8,5); + randValue = GetRandomValue(-8, 5); framesCounter = 0; } //---------------------------------------------------------------------------------- diff --git a/examples/core_world_screen.c b/examples/core_world_screen.c index eac5fbdc..b70b40dd 100644 --- a/examples/core_world_screen.c +++ b/examples/core_world_screen.c @@ -21,9 +21,9 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); // Define the camera to look into our 3d world - Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; - Vector3 cubePosition = { 0.0, 0.0, 0.0 }; + Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; Vector2 cubeScreenPosition; @@ -53,10 +53,10 @@ int main() Begin3dMode(camera); - DrawCube(cubePosition, 2, 2, 2, RED); - DrawCubeWires(cubePosition, 2, 2, 2, MAROON); + DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); + DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - DrawGrid(10.0, 1.0); + DrawGrid(10, 1.0f); End3dMode(); diff --git a/examples/lighting_blinn_phong.c b/examples/lighting_blinn_phong.c index 65dbb4f2..d7683648 100644 --- a/examples/lighting_blinn_phong.c +++ b/examples/lighting_blinn_phong.c @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raylib [lighting] example - Basic Phong lighting +* raylib [shaders] example - Blinn-Phong lighting * * This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) @@ -22,14 +22,14 @@ int main() const int screenHeight = 450; SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "raylib [lighting] example - blinn phong lighting"); + InitWindow(screenWidth, screenHeight, "raylib [shaders] example - blinn-phong lighting"); SetTargetFPS(60); // Camera initialization - Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 8.0f, 8.0f, 8.0f }, { 0.0f, 3.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; // Model initialization - Vector3 position = { 0.0, 0.0, 0.0 }; + Vector3 position = { 0.0f, 0.0f, 0.0f }; Model model = LoadModel("resources/model/dwarf.obj"); Shader shader = LoadShader("resources/shaders/phong.vs", "resources/shaders/phong.fs"); SetModelShader(&model, shader); @@ -54,7 +54,7 @@ int main() Material matBlinn; // Light initialization - light.position = (Vector3){ 5.0f, 1.0f, 1.0f }; + light.position = (Vector3){ 4.0f, 2.0f, 0.0f }; light.direction = (Vector3){ 5.0f, 1.0f, 1.0f }; light.intensity = 1.0f; light.diffuse = WHITE; @@ -129,7 +129,9 @@ int main() Begin3dMode(camera); DrawModel(model, position, 4.0f, matBlinn.diffuse); - DrawSphere(light.position, 1.0f, YELLOW); + DrawSphere(light.position, 0.5f, GOLD); + + DrawGrid(20, 1.0f); End3dMode(); diff --git a/examples/models_billboard.c b/examples/models_billboard.c index e5f6489f..bac42d35 100644 --- a/examples/models_billboard.c +++ b/examples/models_billboard.c @@ -21,10 +21,10 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards"); // Define the camera to look into our 3d world - Camera camera = {{ 5.0, 4.0, 5.0 }, { 0.0, 2.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 5.0f, 4.0f, 5.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard - Vector3 billPosition = { 0.0, 2.0, 0.0 }; // Position where draw billboard + Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode SetCameraPosition(camera.position); // Set internal camera position to match our camera position @@ -49,9 +49,9 @@ int main() Begin3dMode(camera); - DrawGrid(10.0, 1.0); // Draw a grid - DrawBillboard(camera, bill, billPosition, 2.0f, WHITE); + + DrawGrid(10, 1.0f); // Draw a grid End3dMode(); diff --git a/examples/models_box_collisions.c b/examples/models_box_collisions.c index 18fca091..3751041f 100644 --- a/examples/models_box_collisions.c +++ b/examples/models_box_collisions.c @@ -21,16 +21,16 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions"); // Define the camera to look into our 3d world - Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; - Vector3 playerPosition = { 0, 1, 2 }; - Vector3 playerSize = { 1, 2, 1 }; + Vector3 playerPosition = { 0.0f, 1.0f, 2.0f }; + Vector3 playerSize = { 1.0f, 2.0f, 1.0f }; Color playerColor = GREEN; - Vector3 enemyBoxPos = { -4, 1, 0 }; - Vector3 enemyBoxSize = { 2, 2, 2 }; + Vector3 enemyBoxPos = { -4.0f, 1.0f, 0.0f }; + Vector3 enemyBoxSize = { 2.0f, 2.0f, 2.0f }; - Vector3 enemySpherePos = { 4, 0, 0 }; + Vector3 enemySpherePos = { 4.0f, 0.0f, 0.0f }; float enemySphereSize = 1.5f; bool collision = false; @@ -98,7 +98,7 @@ int main() // Draw player DrawCubeV(playerPosition, playerSize, playerColor); - DrawGrid(10.0, 1.0); // Draw a grid + DrawGrid(10, 1.0f); // Draw a grid End3dMode(); diff --git a/examples/models_cubicmap.c b/examples/models_cubicmap.c index 98fc54af..e2a902ef 100644 --- a/examples/models_cubicmap.c +++ b/examples/models_cubicmap.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing"); // Define the camera to look into our 3d world - Camera camera = {{ 16.0, 14.0, 16.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM) @@ -31,7 +31,7 @@ int main() Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture SetModelTexture(&map, texture); // Bind texture to map model - Vector3 mapPosition = { -16, 0.0, -8 }; // Set model position + Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM diff --git a/examples/models_geometric_shapes.c b/examples/models_geometric_shapes.c index e2d41dcd..9ea5b423 100644 --- a/examples/models_geometric_shapes.c +++ b/examples/models_geometric_shapes.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); // Define the camera to look into our 3d world - Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -42,21 +42,21 @@ int main() Begin3dMode(camera); - DrawCube((Vector3){-4, 0, 2}, 2, 5, 2, RED); - DrawCubeWires((Vector3){-4, 0, 2}, 2, 5, 2, GOLD); - DrawCubeWires((Vector3){-4, 0, -2}, 3, 6, 2, MAROON); + DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); + DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); + DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON); - DrawSphere((Vector3){-1, 0, -2}, 1, GREEN); - DrawSphereWires((Vector3){1, 0, 2}, 2, 16, 16, LIME); + DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN); + DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME); - DrawCylinder((Vector3){4, 0, -2}, 1, 2, 3, 4, SKYBLUE); - DrawCylinderWires((Vector3){4, 0, -2}, 1, 2, 3, 4, DARKBLUE); - DrawCylinderWires((Vector3){4.5, -1, 2}, 1, 1, 2, 6, BROWN); + DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE); + DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE); + DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN); - DrawCylinder((Vector3){1, 0, -4}, 0, 1.5, 3, 8, GOLD); - DrawCylinderWires((Vector3){1, 0, -4}, 0, 1.5, 3, 8, PINK); + DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD); + DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK); - DrawGrid(10.0, 1.0); // Draw a grid + DrawGrid(10, 1.0f); // Draw a grid End3dMode(); diff --git a/examples/models_heightmap.c b/examples/models_heightmap.c index fec3f5e6..ac578c61 100644 --- a/examples/models_heightmap.c +++ b/examples/models_heightmap.c @@ -21,13 +21,13 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing"); // Define our custom camera to look into our 3d world - Camera camera = {{ 24.0, 18.0, 24.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 24.0f, 18.0f, 24.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) Model map = LoadHeightmap(image, 32); // Load heightmap model SetModelTexture(&map, texture); // Bind texture to model - Vector3 mapPosition = { -16, 0.0, -16 }; // Set model position (depends on model scaling!) + Vector3 mapPosition = { -16.0f, 0.0f, -16.0f }; // Set model position (depends on model scaling!) UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM diff --git a/examples/models_obj_loading.c b/examples/models_obj_loading.c index dc302f99..41f4569a 100644 --- a/examples/models_obj_loading.c +++ b/examples/models_obj_loading.c @@ -21,12 +21,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture - SetModelTexture(&dwarf, texture); // Bind texture to model - Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position + SetModelTexture(&dwarf, texture); // Bind texture to model + Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -49,7 +49,7 @@ int main() DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture - DrawGrid(10.0, 1.0); // Draw a grid + DrawGrid(10, 1.0f); // Draw a grid DrawGizmo(position); // Draw gizmo diff --git a/examples/resources/shaders/phong.fs b/examples/resources/shaders/phong.fs index 75b7e6d7..f79413d9 100644 --- a/examples/resources/shaders/phong.fs +++ b/examples/resources/shaders/phong.fs @@ -9,16 +9,16 @@ uniform sampler2D texture0; uniform vec4 fragTintColor; // Light attributes -uniform vec3 light_ambientColor = vec3(0.6, 0.3, 0); -uniform vec3 light_diffuseColor = vec3(1, 0.5, 0); -uniform vec3 light_specularColor = vec3(0, 1, 0); -uniform float light_intensity = 1; -uniform float light_specIntensity = 1; +uniform vec3 light_ambientColor = vec3(0.6, 0.3, 0.0); +uniform vec3 light_diffuseColor = vec3(1.0, 0.5, 0.0); +uniform vec3 light_specularColor = vec3(0.0, 1.0, 0.0); +uniform float light_intensity = 1.0; +uniform float light_specIntensity = 1.0; // Material attributes -uniform vec3 mat_ambientColor = vec3(1, 1, 1); -uniform vec3 mat_specularColor = vec3(1, 1, 1); -uniform float mat_glossiness = 50; +uniform vec3 mat_ambientColor = vec3(1.0, 1.0, 1.0); +uniform vec3 mat_specularColor = vec3(1.0, 1.0, 1.0); +uniform float mat_glossiness = 50.0; // World attributes uniform vec3 lightPos; @@ -29,7 +29,7 @@ out vec4 fragColor; vec3 AmbientLighting() { - return mat_ambientColor * light_ambientColor; + return (mat_ambientColor*light_ambientColor); } vec3 DiffuseLighting(in vec3 N, in vec3 L) @@ -37,15 +37,15 @@ vec3 DiffuseLighting(in vec3 N, in vec3 L) // Lambertian reflection calculation float diffuse = clamp(dot(N, L), 0, 1); - return tintColor.xyz * light_diffuseColor * light_intensity * diffuse; + return (fragTintColor.xyz*light_diffuseColor*light_intensity*diffuse); } vec3 SpecularLighting(in vec3 N, in vec3 L, in vec3 V) { - float specular = 0; + float specular = 0.0; // Calculate specular reflection only if the surface is oriented to the light source - if(dot(N, L) > 0) + if (dot(N, L) > 0) { // Calculate half vector vec3 H = normalize(L + V); @@ -54,7 +54,7 @@ vec3 SpecularLighting(in vec3 N, in vec3 L, in vec3 V) specular = pow(dot(N, H), 3 + mat_glossiness); } - return mat_specularColor * light_specularColor * light_specIntensity * specular; + return (mat_specularColor*light_specularColor*light_specIntensity*specular); } void main() diff --git a/examples/resources/shaders/phong.vs b/examples/resources/shaders/phong.vs index c6ef77de..ee6d34bf 100644 --- a/examples/resources/shaders/phong.vs +++ b/examples/resources/shaders/phong.vs @@ -7,7 +7,6 @@ in vec3 vertexNormal; // Projection and model data uniform mat4 mvpMatrix; - uniform mat4 modelMatrix; // Attributes to fragment shader @@ -21,8 +20,8 @@ void main() // Calculate view vector normal from model mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); - fragNormal = normalize(normalMatrix * vertexNormal); + fragNormal = normalize(normalMatrix*vertexNormal); // Calculate final vertex position - gl_Position = projectionMatrix * modelviewMatrix * vec4(vertexPosition, 1.0); + gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); } \ No newline at end of file diff --git a/examples/resources/shaders/swirl.fs b/examples/resources/shaders/swirl.fs index ace6e79d..f89ef406 100644 --- a/examples/resources/shaders/swirl.fs +++ b/examples/resources/shaders/swirl.fs @@ -9,13 +9,13 @@ uniform vec4 fragTintColor; // NOTE: Add here your custom variables -const float renderWidth = 800; // HARDCODED for example! -const float renderHeight = 480; // Use uniforms instead... +const float renderWidth = 800.0; // HARDCODED for example! +const float renderHeight = 480.0; // Use uniforms instead... float radius = 250.0; float angle = 0.8; -uniform vec2 center = vec2(200, 200); +uniform vec2 center = vec2(200.0, 200.0); void main (void) { diff --git a/examples/shaders_custom_uniform.c b/examples/shaders_custom_uniform.c index 59350d35..0377cfff 100644 --- a/examples/shaders_custom_uniform.c +++ b/examples/shaders_custom_uniform.c @@ -30,13 +30,13 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture SetModelTexture(&dwarf, texture); // Bind texture to model - Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position + Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Shader shader = LoadShader("resources/shaders/base.vs", "resources/shaders/swirl.fs"); // Load postpro shader @@ -45,7 +45,7 @@ int main() // NOTE: If uniform variable could not be found in the shader, function returns -1 int swirlCenterLoc = GetShaderLocation(shader, "center"); - float swirlCenter[2] = { screenWidth/2, screenHeight/2 }; + float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 }; SetPostproShader(shader); // Set fullscreen postprocessing shader @@ -83,7 +83,7 @@ int main() DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture - DrawGrid(10.0, 1.0); // Draw a grid + DrawGrid(10, 1.0f); // Draw a grid End3dMode(); diff --git a/examples/shaders_model_shader.c b/examples/shaders_model_shader.c index 8ea390e5..5d8c3711 100644 --- a/examples/shaders_model_shader.c +++ b/examples/shaders_model_shader.c @@ -30,7 +30,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture @@ -40,7 +40,7 @@ int main() SetModelShader(&dwarf, shader); // Set shader effect to 3d model SetModelTexture(&dwarf, texture); // Bind texture to model - Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position + Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position // Setup orbital camera SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode @@ -68,7 +68,7 @@ int main() DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture - DrawGrid(10.0, 1.0); // Draw a grid + DrawGrid(10, 1.0f); // Draw a grid End3dMode(); diff --git a/examples/shaders_postprocessing.c b/examples/shaders_postprocessing.c index 5d7c1f61..0f851658 100644 --- a/examples/shaders_postprocessing.c +++ b/examples/shaders_postprocessing.c @@ -30,13 +30,13 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0, 3.0, 3.0 }, { 0.0, 1.5, 0.0 }, { 0.0, 1.0, 0.0 }}; + Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture SetModelTexture(&dwarf, texture); // Bind texture to model - Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position + Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Shader shader = LoadShader("resources/shaders/base.vs", "resources/shaders/bloom.fs"); // Load postpro shader @@ -69,7 +69,7 @@ int main() DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture - DrawGrid(10.0, 1.0); // Draw a grid + DrawGrid(10, 1.0f); // Draw a grid End3dMode(); diff --git a/examples/shapes_basic_shapes.c b/examples/shapes_basic_shapes.c index 4b14af89..6b2719fc 100644 --- a/examples/shapes_basic_shapes.c +++ b/examples/shapes_basic_shapes.c @@ -19,6 +19,8 @@ int main() int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing"); + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/shapes_colors_palette.c b/examples/shapes_colors_palette.c index 3e161114..dcab862e 100644 --- a/examples/shapes_colors_palette.c +++ b/examples/shapes_colors_palette.c @@ -19,6 +19,8 @@ int main() int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib color palette"); + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/shapes_logo_raylib.c b/examples/shapes_logo_raylib.c index 3dd8fbf3..be94988c 100644 --- a/examples/shapes_logo_raylib.c +++ b/examples/shapes_logo_raylib.c @@ -19,6 +19,8 @@ int main() int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes"); + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop diff --git a/examples/shapes_logo_raylib_anim.c b/examples/shapes_logo_raylib_anim.c index d0831378..b1bdc3a8 100644 --- a/examples/shapes_logo_raylib_anim.c +++ b/examples/shapes_logo_raylib_anim.c @@ -35,9 +35,7 @@ int main() char raylib[8] = " \0"; // raylib text array, max 8 letters int state = 0; // Tracking animation states (State Machine) - - float alpha = 1.0; // Useful for fading - + float alpha = 1.0f; // Useful for fading SetTargetFPS(60); //-------------------------------------------------------------------------------------- diff --git a/examples/textures_logo_raylib.c b/examples/textures_logo_raylib.c index 2ebf0867..f2f93128 100644 --- a/examples/textures_logo_raylib.c +++ b/examples/textures_logo_raylib.c @@ -38,8 +38,7 @@ int main() ClearBackground(RAYWHITE); - DrawTexture(texture, screenWidth/2 - texture.width/2, - screenHeight/2 - texture.height/2, WHITE); + DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); DrawText("this IS a texture!", 360, 370, 10, GRAY); diff --git a/examples/textures_particles_trail_blending.c b/examples/textures_particles_trail_blending.c index da01f863..76cd0423 100644 --- a/examples/textures_particles_trail_blending.c +++ b/examples/textures_particles_trail_blending.c @@ -41,12 +41,12 @@ int main() mouseTail[i].position = (Vector2){ 0, 0 }; mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; mouseTail[i].alpha = 1.0f; - mouseTail[i].size = (float)GetRandomValue(1, 30)/20; + mouseTail[i].size = (float)GetRandomValue(1, 30)/20.0f; mouseTail[i].rotation = GetRandomValue(0, 360); mouseTail[i].active = false; } - float gravity = 3; + float gravity = 3.0f; Texture2D smoke = LoadTexture("resources/smoke.png"); @@ -85,7 +85,7 @@ int main() if (mouseTail[i].alpha <= 0.0f) mouseTail[i].active = false; - mouseTail[i].rotation += 5; + mouseTail[i].rotation += 5.0f; } }