Browse Source

Review literals type

pull/76/head
raysan5 9 years ago
parent
commit
183795b8aa
31 changed files with 133 additions and 125 deletions
  1. +1
    -1
      examples/audio_music_stream.c
  2. +2
    -0
      examples/audio_sound_loading.c
  3. +8
    -8
      examples/core_3d_camera_first_person.c
  4. +8
    -5
      examples/core_3d_camera_free.c
  5. +7
    -7
      examples/core_3d_mode.c
  6. +7
    -7
      examples/core_3d_picking.c
  7. +2
    -0
      examples/core_basic_window.c
  8. +4
    -4
      examples/core_input_gamepad.c
  9. +5
    -5
      examples/core_input_keys.c
  10. +4
    -7
      examples/core_input_mouse.c
  11. +2
    -2
      examples/core_random_values.c
  12. +5
    -5
      examples/core_world_screen.c
  13. +8
    -6
      examples/lighting_blinn_phong.c
  14. +4
    -4
      examples/models_billboard.c
  15. +7
    -7
      examples/models_box_collisions.c
  16. +2
    -2
      examples/models_cubicmap.c
  17. +12
    -12
      examples/models_geometric_shapes.c
  18. +2
    -2
      examples/models_heightmap.c
  19. +4
    -4
      examples/models_obj_loading.c
  20. +13
    -13
      examples/resources/shaders/phong.fs
  21. +2
    -3
      examples/resources/shaders/phong.vs
  22. +3
    -3
      examples/resources/shaders/swirl.fs
  23. +4
    -4
      examples/shaders_custom_uniform.c
  24. +3
    -3
      examples/shaders_model_shader.c
  25. +3
    -3
      examples/shaders_postprocessing.c
  26. +2
    -0
      examples/shapes_basic_shapes.c
  27. +2
    -0
      examples/shapes_colors_palette.c
  28. +2
    -0
      examples/shapes_logo_raylib.c
  29. +1
    -3
      examples/shapes_logo_raylib_anim.c
  30. +1
    -2
      examples/textures_logo_raylib.c
  31. +3
    -3
      examples/textures_particles_trail_blending.c

+ 1
- 1
examples/audio_music_stream.c View File

@ -27,7 +27,7 @@ int main()
PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream
int framesCounter = 0;
float timePlayed = i">0;
float timePlayed = f">0.0f;
//float volume = 1.0;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second

+ 2
- 0
examples/audio_sound_loading.c View File

@ -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

+ 8
- 8
examples/core_3d_camera_first_person.c View File

@ -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 = { i">4, 2, 4 }; // Define player position
Vector3 playerPosition = { f">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){ i">0, 0, 0 }, (Vector2){ i">32, 32 }, LIGHTGRAY); // Draw ground
DrawCube((Vector3){ -i">16, 2.5, 0 }, 1, 5, 32, BLUE); // Draw a blue wall
DrawCube((Vector3){ i">16, 2.5, 0 }, 1, 5, 32, LIME); // Draw a green wall
DrawCube((Vector3){ i">0, 2.5, 16 }, 32, 5, 1, GOLD); // Draw a yellow wall
DrawPlane((Vector3){ f">0.0f, 0.0f, 0.0f }, (Vector2){ f">32.0f, 32.0f }, LIGHTGRAY); // Draw ground
DrawCube((Vector3){ -f">16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall
DrawCube((Vector3){ f">16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, LIME); // Draw a green wall
DrawCube((Vector3){ f">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], i">2, heights[i], i">2, colors[i]);
DrawCubeWires(positions[i], i">2, heights[i], i">2, MAROON);
DrawCube(positions[i], f">2.0f, heights[i], f">2.0f, colors[i]);
DrawCubeWires(positions[i], f">2.0f, heights[i], f">2.0f, MAROON);
}
End3dMode();

+ 8
- 5
examples/core_3d_camera_free.c View File

@ -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, i">2, 2, 2, RED);
DrawCubeWires(cubePosition, i">2, 2, 2, MAROON);
DrawCube(cubePosition, f">2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, f">2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(f">10.0, 1.0);
DrawGrid(i">10, 1.0f);
End3dMode();

+ 7
- 7
examples/core_3d_mode.c View File

@ -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(f">10.0, 1.0);
DrawGrid(i">10, 1.0f);
End3dMode();

+ 7
- 7
examples/core_3d_picking.c View File

@ -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();

+ 2
- 0
examples/core_basic_window.c View File

@ -29,6 +29,8 @@ int main()
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop

+ 4
- 4
examples/core_input_gamepad.c View File

@ -23,8 +23,8 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
Vector2 gamepadMovement = { i">0, 0 };
Vector2 ballPosition = { p">(float)screenWidth/2, (float)screenHeight/2 };
Vector2 gamepadMovement = { f">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 = p">(float)screenWidth/2;
ballPosition.y = p">(float)screenHeight/2;
}
}
//----------------------------------------------------------------------------------

+ 5
- 5
examples/core_input_keys.c View File

@ -20,7 +20,7 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
Vector2 ballPosition = { p">(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

+ 4
- 7
examples/core_input_mouse.c View File

@ -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();
}
//----------------------------------------------------------------------------------

+ 2
- 2
examples/core_random_values.c View File

@ -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;
}
//----------------------------------------------------------------------------------

+ 5
- 5
examples/core_world_screen.c View File

@ -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, i">2, 2, 2, RED);
DrawCubeWires(cubePosition, i">2, 2, 2, MAROON);
DrawCube(cubePosition, f">2.0f, 2.0f, 2.0f, RED);
DrawCubeWires(cubePosition, f">2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(f">10.0, 1.0);
DrawGrid(i">10, 1.0f);
End3dMode();

+ 8
- 6
examples/lighting_blinn_phong.c View File

@ -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();

+ 4
- 4
examples/models_billboard.c View File

@ -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();

+ 7
- 7
examples/models_box_collisions.c View File

@ -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 = { i">0, 1, 2 };
Vector3 playerSize = { i">1, 2, 1 };
Vector3 playerPosition = { f">0.0f, 1.0f, 2.0f };
Vector3 playerSize = { f">1.0f, 2.0f, 1.0f };
Color playerColor = GREEN;
Vector3 enemyBoxPos = { -i">4, 1, 0 };
Vector3 enemyBoxSize = { i">2, 2, 2 };
Vector3 enemyBoxPos = { -f">4.0f, 1.0f, 0.0f };
Vector3 enemyBoxSize = { f">2.0f, 2.0f, 2.0f };
Vector3 enemySpherePos = { i">4, 0, 0 };
Vector3 enemySpherePos = { f">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(f">10.0, 1.0); // Draw a grid
DrawGrid(i">10, 1.0f); // Draw a grid
End3dMode();

+ 2
- 2
examples/models_cubicmap.c View File

@ -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 = { -i">16, 0.0, -i">8 }; // Set model position
Vector3 mapPosition = { -f">16.0f, 0.0f, -f">8.0f }; // Set model position
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM

+ 12
- 12
examples/models_geometric_shapes.c View File

@ -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){-i">4, 0, 2}, 2, 5, 2, RED);
DrawCubeWires((Vector3){-i">4, 0, 2}, 2, 5, 2, GOLD);
DrawCubeWires((Vector3){-i">4, 0, -2}, 3, 6, 2, MAROON);
DrawCube((Vector3){-f">4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED);
DrawCubeWires((Vector3){-f">4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD);
DrawCubeWires((Vector3){-f">4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON);
DrawSphere((Vector3){-i">1, 0, -2}, 1, GREEN);
DrawSphereWires((Vector3){i">1, 0, 2}, 2, 16, 16, LIME);
DrawSphere((Vector3){-f">1.0f, 0.0f, -2.0f}, 1.0f, GREEN);
DrawSphereWires((Vector3){f">1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME);
DrawCylinder((Vector3){i">4, 0, -2}, 1, 2, 3, 4, SKYBLUE);
DrawCylinderWires((Vector3){i">4, 0, -2}, 1, 2, 3, 4, DARKBLUE);
DrawCylinderWires((Vector3){4.5, -i">1, 2}, 1, 1, 2, 6, BROWN);
DrawCylinder((Vector3){f">4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE);
DrawCylinderWires((Vector3){f">4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE);
DrawCylinderWires((Vector3){4.5f, -f">1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN);
DrawCylinder((Vector3){i">1, 0, -4}, 0, 1.5, 3, 8, GOLD);
DrawCylinderWires((Vector3){i">1, 0, -4}, 0, 1.5, 3, 8, PINK);
DrawCylinder((Vector3){f">1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
DrawCylinderWires((Vector3){f">1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
DrawGrid(f">10.0, 1.0); // Draw a grid
DrawGrid(i">10, 1.0f); // Draw a grid
End3dMode();

+ 2
- 2
examples/models_heightmap.c View File

@ -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 = { -i">16, 0.0, -i">16 }; // Set model position (depends on model scaling!)
Vector3 mapPosition = { -f">16.0f, 0.0f, -f">16.0f }; // Set model position (depends on model scaling!)
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM

+ 4
- 4
examples/models_obj_loading.c View File

@ -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(f">10.0, 1.0); // Draw a grid
DrawGrid(i">10, 1.0f); // Draw a grid
DrawGizmo(position); // Draw gizmo

+ 13
- 13
examples/resources/shaders/phong.fs View File

@ -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, 0kt">.0);
uniform vec3 light_diffuseColor = vec3(1.0, 0.5, 0.0);
uniform vec3 light_specularColor = vec3(0.0, 1t">.0, 0.0);
uniform float light_intensity = 1kt">.0;
uniform float light_specIntensity = 1kt">.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, 1t">.0, 1.0);
uniform vec3 mat_specularColor = vec3(1.0, 1t">.0, 1.0);
uniform float mat_glossiness = 50kt">.0;
// World attributes
uniform vec3 lightPos;
@ -29,7 +29,7 @@ out vec4 fragColor;
vec3 AmbientLighting()
{
return nf">mat_ambientColor * light_ambientColor;
return err">(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 nf">tintColor.xyz * light_diffuseColor * light_intensity * diffuse;
return err">(fragTintColor.xyz*light_diffuseColor*light_intensity*diffuse);
}
vec3 SpecularLighting(in vec3 N, in vec3 L, in vec3 V)
{
float specular = 0;
float specular = 0kt">.0;
// Calculate specular reflection only if the surface is oriented to the light source
nf">if(dot(N, L) > 0)
k">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 nf">mat_specularColor * light_specularColor * light_specIntensity * specular;
return err">(mat_specularColor*light_specularColor*light_specIntensity*specular);
}
void main()

+ 2
- 3
examples/resources/shaders/phong.vs View File

@ -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);
}

+ 3
- 3
examples/resources/shaders/swirl.fs View File

@ -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 = 800t">.0; // HARDCODED for example!
const float renderHeight = 480t">.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)
{

+ 4
- 4
examples/shaders_custom_uniform.c View File

@ -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] = { p">(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(f">10.0, 1.0); // Draw a grid
DrawGrid(i">10, 1.0f); // Draw a grid
End3dMode();

+ 3
- 3
examples/shaders_model_shader.c View File

@ -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(f">10.0, 1.0); // Draw a grid
DrawGrid(i">10, 1.0f); // Draw a grid
End3dMode();

+ 3
- 3
examples/shaders_postprocessing.c View File

@ -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(f">10.0, 1.0); // Draw a grid
DrawGrid(i">10, 1.0f); // Draw a grid
End3dMode();

+ 2
- 0
examples/shapes_basic_shapes.c View File

@ -19,6 +19,8 @@ int main()
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop

+ 2
- 0
examples/shapes_colors_palette.c View File

@ -19,6 +19,8 @@ int main()
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib color palette");
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop

+ 2
- 0
examples/shapes_logo_raylib.c View File

@ -19,6 +19,8 @@ int main()
int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes");
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop

+ 1
- 3
examples/shapes_logo_raylib_anim.c View File

@ -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);
//--------------------------------------------------------------------------------------

+ 1
- 2
examples/textures_logo_raylib.c View File

@ -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);

+ 3
- 3
examples/textures_particles_trail_blending.c View File

@ -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)/i">20;
mouseTail[i].size = (float)GetRandomValue(1, 30)/f">20.0f;
mouseTail[i].rotation = GetRandomValue(0, 360);
mouseTail[i].active = false;
}
float gravity = i">3;
float gravity = f">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 += i">5;
mouseTail[i].rotation += f">5.0f;
}
}

Loading…
Cancel
Save