Pārlūkot izejas kodu

REVIEWED: Camera redesign PR

Ray 2 gadi atpakaļ
vecāks
revīzija
ea590c44a9
34 mainītis faili ar 321 papildinājumiem un 268 dzēšanām
  1. 25 16
      examples/core/core_3d_camera_first_person.c
  2. 3 1
      examples/core/core_3d_camera_free.c
  3. 3 6
      examples/core/core_3d_picking.c
  4. 3 3
      examples/core/core_vr_simulator.c
  5. 10 7
      examples/core/core_world_screen.c
  6. 4 10
      examples/models/models_animation.c
  7. 12 10
      examples/models/models_billboard.c
  8. 11 5
      examples/models/models_cubicmap.c
  9. 10 3
      examples/models/models_first_person_maze.c
  10. 17 11
      examples/models/models_heightmap.c
  11. 2 1
      examples/models/models_loading.c
  12. 6 4
      examples/models/models_loading_gltf.c
  13. 7 5
      examples/models/models_loading_m3d.c
  14. 3 2
      examples/models/models_loading_vox.c
  15. 2 1
      examples/models/models_mesh_generation.c
  16. 1 2
      examples/models/models_mesh_picking.c
  17. 7 6
      examples/models/models_rlgl_solar_system.c
  18. 10 4
      examples/models/models_skybox.c
  19. 5 5
      examples/models/models_waving_cubes.c
  20. 4 4
      examples/shaders/shaders_basic_lighting.c
  21. 5 6
      examples/shaders/shaders_custom_uniform.c
  22. 9 8
      examples/shaders/shaders_fog.c
  23. 8 8
      examples/shaders/shaders_mesh_instancing.c
  24. 8 8
      examples/shaders/shaders_model_shader.c
  25. 11 6
      examples/shaders/shaders_postprocessing.c
  26. 4 3
      examples/shaders/shaders_raymarching.c
  27. 13 13
      examples/shaders/shaders_simple_mask.c
  28. 38 41
      examples/shaders/shaders_spotlight.c
  29. 5 4
      examples/text/text_draw_3d.c
  30. 19 0
      projects/VS2022/raylib.sln
  31. 1 1
      src/raylib.h
  32. 44 62
      src/rcamera.h
  33. 0 0
      src/rcamera.old.h
  34. 11 2
      src/rcore.c

+ 25 - 16
examples/core/core_3d_camera_first_person.c

@@ -30,13 +30,12 @@ int main(void)
 
     // Define the camera to look into our 3d world (position, target, up vector)
     Camera camera = { 0 };
-    camera.position = (Vector3){ 0.0f, 2.0f, 4.0f };
-    camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 60.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
-    camera.swingCounter = 1; // Enable view bobbing
-    
+    camera.position = (Vector3){ 0.0f, 2.0f, 4.0f };    // Camera position
+    camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 60.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
+
     int cameraMode = CAMERA_FIRST_PERSON;
 
     // Generates some random columns
@@ -51,36 +50,46 @@ int main(void)
         colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
     }
 
-    DisableCursor();                            // Catch cursor
-    SetTargetFPS(60);                           // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())                // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------
         // Switch camera mode
-        if (IsKeyPressed(KEY_ONE)) {
+        if (IsKeyPressed(KEY_ONE))
+        {
             cameraMode = CAMERA_FREE;
             camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
         }
-        if (IsKeyPressed(KEY_TWO)) {
+
+        if (IsKeyPressed(KEY_TWO))
+        {
             cameraMode = CAMERA_FIRST_PERSON;
             camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
         }
-        if (IsKeyPressed(KEY_THREE)) {
+
+        if (IsKeyPressed(KEY_THREE))
+        {
             cameraMode = CAMERA_THIRD_PERSON;
             camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
         }
-        if (IsKeyPressed(KEY_FOUR)) {
+
+        if (IsKeyPressed(KEY_FOUR))
+        {
             cameraMode = CAMERA_ORBITAL;
             camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Reset roll
         }
 
         // Switch camera projection
-        if (IsKeyPressed(KEY_P)) {
-            if (camera.projection == CAMERA_PERSPECTIVE) {
+        if (IsKeyPressed(KEY_P))
+        {
+            if (camera.projection == CAMERA_PERSPECTIVE)
+            {
                 // Create isometric view
                 cameraMode = CAMERA_THIRD_PERSON;
                 // Note: The target distance is related to the render distance in the orthographic projection

+ 3 - 1
examples/core/core_3d_camera_free.c

@@ -31,10 +31,12 @@ int main(void)
     camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
     camera.fovy = 45.0f;                                // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;                   // Camera mode type
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
 
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
     SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 

+ 3 - 6
examples/core/core_3d_picking.c

@@ -31,16 +31,13 @@ int main(void)
     camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
     camera.fovy = 45.0f;                                // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;                   // Camera mode type
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
     Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
 
     Ray ray = { 0 };                    // Picking line ray
-
-    RayCollision collision = { 0 };
-
-    EnableCursor();                     // Disable camera controls
+    RayCollision collision = { 0 };     // Ray collision hit info
 
     SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
@@ -50,7 +47,7 @@ int main(void)
     {
         // Update
         //----------------------------------------------------------------------------------
-        if (IsCursorHidden()) UpdateCamera(&camera, CAMERA_FIRST_PERSON);          // Update camera
+        if (IsCursorHidden()) UpdateCamera(&camera, CAMERA_FIRST_PERSON);
 
         // Toggle camera controls
         if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))

+ 3 - 3
examples/core/core_vr_simulator.c

@@ -95,12 +95,12 @@ int main(void)
     camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector
     camera.fovy = 60.0f;                                // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;             // Camera type
-    camera.swingCounter = 1;                            // Enable view bobbing
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
 
-    DisableCursor();                    // Catch cursor
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
     SetTargetFPS(90);                   // Set our game to run at 90 frames-per-second
     //--------------------------------------------------------------------------------------
 

+ 10 - 7
examples/core/core_world_screen.c

@@ -27,16 +27,17 @@ int main(void)
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ 10.0f, 10.0f, 10.0f };
-    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 45.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
+    camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
+    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
     Vector2 cubeScreenPosition = { 0.0f, 0.0f };
 
-    DisableCursor();                            // Catch cursor
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
     SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
@@ -67,7 +68,9 @@ int main(void)
             EndMode3D();
 
             DrawText("Enemy: 100 / 100", (int)cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, (int)cubeScreenPosition.y, 20, BLACK);
-            DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20))/2, 25, 20, GRAY);
+            
+            DrawText(TextFormat("Cube position in screen space coordinates: [%i, %i]", (int)cubeScreenPosition.x, (int)cubeScreenPosition.y), 10, 10, 20, LIME);
+            DrawText("Text 2d should be always on top of the cube", 10, 40, 20, GRAY);
 
         EndDrawing();
         //----------------------------------------------------------------------------------

+ 4 - 10
examples/models/models_animation.c

@@ -21,8 +21,6 @@
 
 #include "raylib.h"
 
-#include <stdlib.h>
-
 //------------------------------------------------------------------------------------
 // Program main entry point
 //------------------------------------------------------------------------------------
@@ -102,15 +100,11 @@ int main(void)
 
     // De-Initialization
     //--------------------------------------------------------------------------------------
-    UnloadTexture(texture);     // Unload texture
-
-    // Unload model animations data
-    for (unsigned int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]);
-    RL_FREE(anims);
-
-    UnloadModel(model);         // Unload model
+    UnloadTexture(texture);                     // Unload texture
+    UnloadModelAnimations(anims, animsCount);   // Unload model animations data
+    UnloadModel(model);                         // Unload model
 
-    CloseWindow();              // Close window and OpenGL context
+    CloseWindow();                  // Close window and OpenGL context
     //--------------------------------------------------------------------------------------
 
     return 0;

+ 12 - 10
examples/models/models_billboard.c

@@ -28,15 +28,15 @@ int main(void)
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ 5.0f, 4.0f, 5.0f };
-    camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 45.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
+    camera.position = (Vector3){ 5.0f, 4.0f, 5.0f };    // Camera position
+    camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
-    Texture2D bill = LoadTexture("resources/billboard.png");     // Our billboard texture
-    Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f };                 // Position of billboard
-    Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f };
+    Texture2D bill = LoadTexture("resources/billboard.png");    // Our billboard texture
+    Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f };          // Position of static billboard
+    Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f };        // Position of rotating billboard
 
     // Entire billboard texture, source is used to take a segment from a larger texture.
     Rectangle source = { 0.0f, 0.0f, (float)bill.width, (float)bill.height };
@@ -55,11 +55,13 @@ int main(void)
     float distanceRotating;
     float rotation = 0.0f;
 
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 11 - 5
examples/models/models_cubicmap.c

@@ -26,7 +26,12 @@ int main(void)
     InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
 
     // Define the camera to look into our 3d world
-    Camera camera = { { 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+    Camera camera = { 0 };
+    camera.position = (Vector3){ 16.0f, 14.0f, 16.0f };     // Camera position
+    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };          // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };              // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                    // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;                 // Camera projection type
 
     Image image = LoadImage("resources/cubicmap.png");      // Load cubicmap image (RAM)
     Texture2D cubicmap = LoadTextureFromImage(image);       // Convert image to texture to display (VRAM)
@@ -36,18 +41,19 @@ int main(void)
 
     // NOTE: By default each cube is mapped to one part of texture atlas
     Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");    // Load map texture
-    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;             // Set map diffuse texture
+    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;    // Set map diffuse texture
 
     Vector3 mapPosition = { -16.0f, 0.0f, -8.0f };          // Set model position
 
     UnloadImage(image);     // Unload cubesmap image from RAM, already uploaded to VRAM
 
-    DisableCursor();                        // Catch cursor
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 10 - 3
examples/models/models_first_person_maze.c

@@ -28,7 +28,13 @@ int main(void)
     InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");
 
     // Define the camera to look into our 3d world
-    Camera camera = { { 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+    Camera camera = { 0 };
+    camera.position = (Vector3){ 0.2f, 0.4f, 0.2f };    // Camera position
+    camera.target = (Vector3){ 0.185f, 0.4f, 0.0f };    // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
+    Vector3 position = { 0.0f, 0.0f, 0.0f };            // Set model position
 
     Image imMap = LoadImage("resources/cubicmap.png");      // Load cubicmap image (RAM)
     Texture2D cubicmap = LoadTextureFromImage(imMap);       // Convert image to texture to display (VRAM)
@@ -37,7 +43,7 @@ int main(void)
 
     // NOTE: By default each cube is mapped to one part of texture atlas
     Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");    // Load map texture
-    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;             // Set map diffuse texture
+    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;    // Set map diffuse texture
 
     // Get map image data to be used for collision detection
     Color *mapPixels = LoadImageColors(imMap);
@@ -45,7 +51,8 @@ int main(void)
 
     Vector3 mapPosition = { -16.0f, 0.0f, -8.0f };  // Set model position
 
-    DisableCursor();                // Catch cursor
+    DisableCursor();                // Limit cursor to relative movement inside the window
+
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 

+ 17 - 11
examples/models/models_heightmap.c

@@ -26,25 +26,31 @@ int main(void)
     InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
 
     // Define our custom camera to look into our 3d world
-    Camera camera = { { 18.0f, 18.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+    Camera camera = { 0 };
+    camera.position = (Vector3){ 18.0f, 21.0f, 18.0f };     // Camera position
+    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };          // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };              // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                    // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;                 // Camera projection type
 
-    Image image = LoadImage("resources/heightmap.png");             // Load heightmap image (RAM)
-    Texture2D texture = LoadTextureFromImage(image);                // Convert image to texture (VRAM)
+    Image image = LoadImage("resources/heightmap.png");     // Load heightmap image (RAM)
+    Texture2D texture = LoadTextureFromImage(image);        // Convert image to texture (VRAM)
 
-    Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 });    // Generate heightmap mesh (RAM and VRAM)
-    Model model = LoadModelFromMesh(mesh);                          // Load model from generated mesh
+    Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
+    Model model = LoadModelFromMesh(mesh);                  // Load model from generated mesh
 
-    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;         // Set map diffuse texture
-    Vector3 mapPosition = { -8.0f, 0.0f, -8.0f };                   // Define model position
+    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
+    Vector3 mapPosition = { -8.0f, 0.0f, -8.0f };           // Define model position
 
-    UnloadImage(image);                     // Unload heightmap image from RAM, already uploaded to VRAM
+    UnloadImage(image);             // Unload heightmap image from RAM, already uploaded to VRAM
 
-    DisableCursor();                        // Catch cursor
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                // Limit cursor to relative movement inside the window
+
+    SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())    // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 2 - 1
examples/models/models_loading.c

@@ -59,7 +59,8 @@ int main(void)
 
     bool selected = false;          // Selected object flag
 
-    DisableCursor();                // Catch cursor
+    DisableCursor();                // Limit cursor to relative movement inside the window
+
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 

+ 6 - 4
examples/models/models_loading_gltf.c

@@ -34,11 +34,11 @@ int main(void)
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
+    camera.position = (Vector3){ 5.0f, 5.0f, 5.0f };    // Camera position
     camera.target = (Vector3){ 0.0f, 2.0f, 0.0f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
     camera.fovy = 45.0f;                                // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;             // Camera mode type
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     // Load gltf model
     Model model = LoadModel("resources/models/gltf/robot.glb");
@@ -51,11 +51,13 @@ int main(void)
 
     Vector3 position = { 0.0f, 0.0f, 0.0f };    // Set model position
 
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 7 - 5
examples/models/models_loading_m3d.c

@@ -33,11 +33,12 @@ int main(void)
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ 1.5f, 1.5f, 1.5f }; // Camera position
+    camera.position = (Vector3){ 1.5f, 1.5f, 1.5f };    // Camera position
     camera.target = (Vector3){ 0.0f, 0.4f, 0.0f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
     camera.fovy = 45.0f;                                // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;             // Camera mode type
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
+
     Vector3 position = { 0.0f, 0.0f, 0.0f };            // Set model position
     
     char modelFileName[128] = "resources/models/m3d/CesiumMan.m3d";
@@ -53,12 +54,13 @@ int main(void)
     int animFrameCounter = 0, animId = 0;
     ModelAnimation *anims = LoadModelAnimations(modelFileName, &animsCount); // Load skeletal animation data
 
-    DisableCursor();                        // Catch cursor
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 3 - 2
examples/models/models_loading_vox.c

@@ -43,7 +43,7 @@ int main(void)
     camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
     camera.fovy = 45.0f;                                // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;             // Camera mode type
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     // Load MagicaVoxel files
     Model models[MAX_VOX_FILES] = { 0 };
@@ -69,7 +69,8 @@ int main(void)
 
     int currentModel = 0;
 
-    DisableCursor();                            // Catch cursor
+    DisableCursor();                // Limit cursor to relative movement inside the window
+
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 

+ 2 - 1
examples/models/models_mesh_generation.c

@@ -68,7 +68,8 @@ int main(void)
 
     int currentModel = 0;
 
-    DisableCursor();                // Catch cursor
+    DisableCursor();                // Limit cursor to relative movement inside the window
+
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 

+ 1 - 2
examples/models/models_mesh_picking.c

@@ -36,7 +36,7 @@ int main(void)
     camera.target = (Vector3){ 0.0f, 8.0f, 0.0f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.6f, 0.0f };          // Camera up vector (rotation towards target)
     camera.fovy = 45.0f;                                // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;             // Camera mode type
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     Ray ray = { 0 };        // Picking ray
 
@@ -64,7 +64,6 @@ int main(void)
     Vector3 sp = (Vector3){ -30.0f, 5.0f, 5.0f };
     float sr = 4.0f;
 
-    EnableCursor();                     // Disable camera controls
     SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
     // Main game loop

+ 7 - 6
examples/models/models_rlgl_solar_system.c

@@ -43,11 +43,11 @@ int main(void)
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ 16.0f, 16.0f, 16.0f };
-    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 45.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
+    camera.position = (Vector3){ 16.0f, 16.0f, 16.0f }; // Camera position
+    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     float rotationSpeed = 0.2f;         // General system rotation speed
 
@@ -56,7 +56,8 @@ int main(void)
     float moonRotation = 0.0f;          // Rotation of moon around itself
     float moonOrbitRotation = 0.0f;     // Rotation of moon around earth in degrees
 
-    DisableCursor();                    // Catch cursor
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
     SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 

+ 10 - 4
examples/models/models_skybox.c

@@ -38,7 +38,12 @@ int main(void)
     InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
 
     // Define the camera to look into our 3d world
-    Camera camera = { { 1.0f, 1.0f, 1.0f }, { 4.0f, 1.0f, 4.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+    Camera camera = { 0 };
+    camera.position = (Vector3){ 1.0f, 1.0f, 1.0f };    // Camera position
+    camera.target = (Vector3){ 4.0f, 1.0f, 4.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     // Load skybox model
     Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
@@ -87,12 +92,13 @@ int main(void)
         UnloadImage(img);
     }
 
-    DisableCursor();                        // Catch cursor
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 5 - 5
examples/models/models_waving_cubes.c

@@ -31,11 +31,11 @@ int main()
 
     // Initialize the camera
     Camera3D camera = { 0 };
-    camera.position = (Vector3){ 30.0f, 20.0f, 30.0f };
-    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 70.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
+    camera.position = (Vector3){ 30.0f, 20.0f, 30.0f }; // Camera position
+    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 70.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     // Specify the amount of blocks in each direction
     const int numBlocks = 15;

+ 4 - 4
examples/shaders/shaders_basic_lighting.c

@@ -50,7 +50,7 @@ int main(void)
     camera.target = (Vector3){ 0.0f, 0.5f, 0.0f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
     camera.fovy = 45.0f;                                // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;             // Camera mode type
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     // Load plane model from a generated mesh
     Model model = LoadModelFromMesh(GenMeshPlane(10.0f, 10.0f, 3, 3));
@@ -80,12 +80,12 @@ int main(void)
     lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, shader);
     lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, shader);
 
-    DisableCursor();                        // Catch cursor
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 5 - 6
examples/shaders/shaders_custom_uniform.c

@@ -42,11 +42,11 @@ int main(void)
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ 8.0f, 8.0f, 8.0f };
-    camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 45.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
+    camera.position = (Vector3){ 8.0f, 8.0f, 8.0f };    // Camera position
+    camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     Model model = LoadModel("resources/models/barracks.obj");                   // Load OBJ model
     Texture2D texture = LoadTexture("resources/models/barracks_diffuse.png");   // Load model texture (diffuse map)
@@ -67,7 +67,6 @@ int main(void)
     // Create a RenderTexture2D to be used for render to texture
     RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
 
-    DisableCursor();                    // Catch cursor
     SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 

+ 9 - 8
examples/shaders/shaders_fog.c

@@ -45,11 +45,12 @@ int main(void)
     InitWindow(screenWidth, screenHeight, "raylib [shaders] example - fog");
 
     // Define the camera to look into our 3d world
-    Camera camera = {
-        (Vector3){ 2.0f, 2.0f, 6.0f },      // position
-        (Vector3){ 0.0f, 0.5f, 0.0f },      // target
-        (Vector3){ 0.0f, 1.0f, 0.0f },      // up
-        45.0f, CAMERA_PERSPECTIVE };        // fov, type
+    Camera camera = { 0 };
+    camera.position = (Vector3){ 2.0f, 2.0f, 6.0f };    // Camera position
+    camera.target = (Vector3){ 0.0f, 0.5f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     // Load models and texture
     Model modelA = LoadModelFromMesh(GenMeshTorus(0.4f, 1.0f, 16, 32));
@@ -84,12 +85,12 @@ int main(void)
     // Using just 1 point lights
     CreateLight(LIGHT_POINT, (Vector3){ 0, 2, 6 }, Vector3Zero(), WHITE, shader);
 
-    DisableCursor();                        // Catch cursor
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 8 - 8
examples/shaders/shaders_mesh_instancing.c

@@ -44,11 +44,11 @@ int main(void)
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ -125.0f, 125.0f, -125.0f };
-    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 45.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
+    camera.position = (Vector3){ -125.0f, 125.0f, -125.0f };    // Camera position
+    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };              // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };                  // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                        // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;                     // Camera projection type
 
     // Define mesh to be instanced
     Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
@@ -94,12 +94,12 @@ int main(void)
     Material matDefault = LoadMaterialDefault();
     matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE;
 
-    DisableCursor();                       // Catch cursor
-    SetTargetFPS(60);                      // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 8 - 8
examples/shaders/shaders_model_shader.c

@@ -42,11 +42,11 @@ int main(void)
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ 4.0f, 4.0f, 4.0f };
-    camera.target = (Vector3){ 0.0f, 1.0f, -1.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 45.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
+    camera.position = (Vector3){ 4.0f, 4.0f, 4.0f };    // Camera position
+    camera.target = (Vector3){ 0.0f, 1.0f, -1.0f };     // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     Model model = LoadModel("resources/models/watermill.obj");                   // Load OBJ model
     Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png");   // Load model texture
@@ -60,12 +60,12 @@ int main(void)
 
     Vector3 position = { 0.0f, 0.0f, 0.0f };    // Set model position
 
-    DisableCursor();                            // Catch cursor
-    SetTargetFPS(60);                           // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())                // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 11 - 6
examples/shaders/shaders_postprocessing.c

@@ -75,13 +75,18 @@ int main(void)
     InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
 
     // Define the camera to look into our 3d world
-    Camera camera = { { 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+    Camera camera = { 0 };
+    camera.position = (Vector3){ 2.0f, 3.0f, 2.0f };    // Camera position
+    camera.target = (Vector3){ 0.0f, 1.0f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     Model model = LoadModel("resources/models/church.obj");                 // Load OBJ model
     Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
-    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;                     // Set model diffuse texture
+    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;        // Set model diffuse texture
 
-    Vector3 position = { 0.0f, 0.0f, 0.0f };                             // Set model position
+    Vector3 position = { 0.0f, 0.0f, 0.0f };            // Set model position
 
     // Load all postpro shaders
     // NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
@@ -107,12 +112,12 @@ int main(void)
     // Create a RenderTexture2D to be used for render to texture
     RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
 
-    DisableCursor();                        // Catch cursor
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 4 - 3
examples/shaders/shaders_raymarching.c

@@ -40,6 +40,7 @@ int main(void)
     camera.target = (Vector3){ 0.0f, 0.0f, 0.7f };      // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
     camera.fovy = 65.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     // Load raymarching shader
     // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
@@ -56,12 +57,12 @@ int main(void)
 
     float runTime = 0.0f;
 
-    DisableCursor();                            // Catch cursor
-    SetTargetFPS(60);                       // Set our game to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())            // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------

+ 13 - 13
examples/shaders/shaders_simple_mask.c

@@ -39,15 +39,15 @@ int main(void)
     const int screenWidth = 800;
     const int screenHeight = 450;
 
-    InitWindow(screenWidth, screenHeight, "raylib - simple shader mask");
+    InitWindow(screenWidth, screenHeight, "raylib [shaders] example - simple shader mask");
 
     // Define the camera to look into our 3d world
     Camera camera = { 0 };
-    camera.position = (Vector3){ 0.0f, 1.0f, 2.0f };
-    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
-    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
-    camera.fovy = 45.0f;
-    camera.projection = CAMERA_PERSPECTIVE;
+    camera.position = (Vector3){ 0.0f, 1.0f, 2.0f };    // Camera position
+    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
+    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
+    camera.fovy = 45.0f;                                // Camera field-of-view Y
+    camera.projection = CAMERA_PERSPECTIVE;             // Camera projection type
 
     // Define our three models to show the shader on
     Mesh torus = GenMeshTorus(0.3f, 1, 16, 32);
@@ -83,14 +83,14 @@ int main(void)
     model2.materials[0].shader = shader;
 
     int framesCounter = 0;
-    Vector3 rotation = { 0 };       // Model rotation angles
+    Vector3 rotation = { 0 };           // Model rotation angles
 
-    DisableCursor();                            // Catch cursor
-    SetTargetFPS(60);               // Set  to run at 60 frames-per-second
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+    SetTargetFPS(60);                   // Set  to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop
-    while (!WindowShouldClose())    // Detect window close button or ESC key
+    while (!WindowShouldClose())        // Detect window close button or ESC key
     {
         // Update
         //----------------------------------------------------------------------------------
@@ -116,9 +116,9 @@ int main(void)
 
             BeginMode3D(camera);
 
-                DrawModel(model1, (Vector3){0.5,0,0}, 1, WHITE);
-                DrawModelEx(model2, (Vector3){-.5,0,0}, (Vector3){1,1,0}, 50, (Vector3){1,1,1}, WHITE);
-                DrawModel(model3,(Vector3){0,0,-1.5}, 1, WHITE);
+                DrawModel(model1, (Vector3){ 0.5f, 0.0f, 0.0f }, 1, WHITE);
+                DrawModelEx(model2, (Vector3){ -0.5f, 0.0f, 0.0f }, (Vector3){ 1.0f, 1.0f, 0.0f }, 50, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
+                DrawModel(model3,(Vector3){ 0.0f, 0.0f, -1.5f }, 1, WHITE);
                 DrawGrid(10, 1.0f);        // Draw a grid
 
             EndMode3D();

+ 38 - 41
examples/shaders/shaders_spotlight.c

@@ -29,10 +29,8 @@
 ********************************************************************************************/
 
 #include "raylib.h"
-#include "raymath.h"
 
-#include <stddef.h>
-#include <stdint.h>
+#include "raymath.h"
 
 #if defined(PLATFORM_DESKTOP)
     #define GLSL_VERSION            330
@@ -44,26 +42,26 @@
 #define MAX_STARS       400
 
 // Spot data
-typedef struct {
-    Vector2 pos;
-    Vector2 vel;
+typedef struct Spot {
+    Vector2 position;
+    Vector2 speed;
     float inner;
     float radius;
 
     // Shader locations
-    unsigned int posLoc;
+    unsigned int positionLoc;
     unsigned int innerLoc;
     unsigned int radiusLoc;
 } Spot;
 
 // Stars in the star field have a position and velocity
 typedef struct Star {
-    Vector2 pos;
-    Vector2 vel;
+    Vector2 position;
+    Vector2 speed;
 } Star;
 
-void UpdateStar(Star *s);
-void ResetStar(Star *s);
+static void UpdateStar(Star *s);
+static void ResetStar(Star *s);
 
 //------------------------------------------------------------------------------------
 // Program main entry point
@@ -75,7 +73,7 @@ int main(void)
     const int screenWidth = 800;
     const int screenHeight = 450;
 
-    InitWindow(screenWidth, screenHeight, "raylib - shader spotlight");
+    InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shader spotlight");
     HideCursor();
 
     Texture texRay = LoadTexture("resources/raysan.png");
@@ -108,7 +106,7 @@ int main(void)
         innerName[6] = '0' + i;
         radiusName[6] = '0' + i;
 
-        spots[i].posLoc = GetShaderLocation(shdrSpot, posName);
+        spots[i].positionLoc = GetShaderLocation(shdrSpot, posName);
         spots[i].innerLoc = GetShaderLocation(shdrSpot, innerName);
         spots[i].radiusLoc = GetShaderLocation(shdrSpot, radiusName);
 
@@ -124,20 +122,20 @@ int main(void)
     // and initialize the shader locations
     for (int i = 0; i < MAX_SPOTS; i++)
     {
-        spots[i].pos.x = (float)GetRandomValue(64, screenWidth - 64);
-        spots[i].pos.y = (float)GetRandomValue(64, screenHeight - 64);
-        spots[i].vel = (Vector2){ 0, 0 };
+        spots[i].position.x = (float)GetRandomValue(64, screenWidth - 64);
+        spots[i].position.y = (float)GetRandomValue(64, screenHeight - 64);
+        spots[i].speed = (Vector2){ 0, 0 };
 
-        while ((fabs(spots[i].vel.x) + fabs(spots[i].vel.y)) < 2)
+        while ((fabs(spots[i].speed.x) + fabs(spots[i].speed.y)) < 2)
         {
-            spots[i].vel.x = GetRandomValue(-400, 40) / 10.0f;
-            spots[i].vel.y = GetRandomValue(-400, 40) / 10.0f;
+            spots[i].speed.x = GetRandomValue(-400, 40) / 10.0f;
+            spots[i].speed.y = GetRandomValue(-400, 40) / 10.0f;
         }
 
         spots[i].inner = 28.0f * (i + 1);
         spots[i].radius = 48.0f * (i + 1);
 
-        SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
+        SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
         SetShaderValue(shdrSpot, spots[i].innerLoc, &spots[i].inner, SHADER_UNIFORM_FLOAT);
         SetShaderValue(shdrSpot, spots[i].radiusLoc, &spots[i].radius, SHADER_UNIFORM_FLOAT);
     }
@@ -161,21 +159,21 @@ int main(void)
             if (i == 0)
             {
                 Vector2 mp = GetMousePosition();
-                spots[i].pos.x = mp.x;
-                spots[i].pos.y = screenHeight - mp.y;
+                spots[i].position.x = mp.x;
+                spots[i].position.y = screenHeight - mp.y;
             }
             else
             {
-                spots[i].pos.x += spots[i].vel.x;
-                spots[i].pos.y += spots[i].vel.y;
+                spots[i].position.x += spots[i].speed.x;
+                spots[i].position.y += spots[i].speed.y;
 
-                if (spots[i].pos.x < 64) spots[i].vel.x = -spots[i].vel.x;
-                if (spots[i].pos.x > (screenWidth - 64)) spots[i].vel.x = -spots[i].vel.x;
-                if (spots[i].pos.y < 64) spots[i].vel.y = -spots[i].vel.y;
-                if (spots[i].pos.y > (screenHeight - 64)) spots[i].vel.y = -spots[i].vel.y;
+                if (spots[i].position.x < 64) spots[i].speed.x = -spots[i].speed.x;
+                if (spots[i].position.x > (screenWidth - 64)) spots[i].speed.x = -spots[i].speed.x;
+                if (spots[i].position.y < 64) spots[i].speed.y = -spots[i].speed.y;
+                if (spots[i].position.y > (screenHeight - 64)) spots[i].speed.y = -spots[i].speed.y;
             }
 
-            SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
+            SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
         }
 
         // Draw
@@ -188,7 +186,7 @@ int main(void)
             for (int n = 0; n < MAX_STARS; n++)
             {
                 // Single pixel is just too small these days!
-                DrawRectangle((int)stars[n].pos.x, (int)stars[n].pos.y, 2, 2, WHITE);
+                DrawRectangle((int)stars[n].position.x, (int)stars[n].position.y, 2, 2, WHITE);
             }
 
             for (int i = 0; i < 16; i++)
@@ -213,7 +211,6 @@ int main(void)
             DrawText("Pitch Black", (int)(screenWidth*0.2f), screenHeight/2, 20, GREEN);
             DrawText("Dark", (int)(screenWidth*.66f), screenHeight/2, 20, GREEN);
 
-
         EndDrawing();
         //----------------------------------------------------------------------------------
     }
@@ -230,26 +227,26 @@ int main(void)
 }
 
 
-void ResetStar(Star *s)
+static void ResetStar(Star *s)
 {
-    s->pos = (Vector2){ GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
+    s->position = (Vector2){ GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
 
     do
     {
-        s->vel.x = (float)GetRandomValue(-1000, 1000)/100.0f;
-        s->vel.y = (float)GetRandomValue(-1000, 1000)/100.0f;
+        s->speed.x = (float)GetRandomValue(-1000, 1000)/100.0f;
+        s->speed.y = (float)GetRandomValue(-1000, 1000)/100.0f;
 
-    } while (!(fabs(s->vel.x) + (fabs(s->vel.y) > 1)));
+    } while (!(fabs(s->speed.x) + (fabs(s->speed.y) > 1)));
 
-    s->pos = Vector2Add(s->pos, Vector2Multiply(s->vel, (Vector2){ 8.0f, 8.0f }));
+    s->position = Vector2Add(s->position, Vector2Multiply(s->speed, (Vector2){ 8.0f, 8.0f }));
 }
 
-void UpdateStar(Star *s)
+static void UpdateStar(Star *s)
 {
-    s->pos = Vector2Add(s->pos, s->vel);
+    s->position = Vector2Add(s->position, s->speed);
 
-    if ((s->pos.x < 0) || (s->pos.x > GetScreenWidth()) ||
-        (s->pos.y < 0) || (s->pos.y > GetScreenHeight()))
+    if ((s->position.x < 0) || (s->position.x > GetScreenWidth()) ||
+        (s->position.y < 0) || (s->position.y > GetScreenHeight()))
     {
         ResetStar(s);
     }

+ 5 - 4
examples/text/text_draw_3d.c

@@ -96,16 +96,13 @@ int main(void)
     camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };          // Camera looking at point
     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };              // Camera up vector (rotation towards target)
     camera.fovy = 45.0f;                                    // Camera field-of-view Y
-    camera.projection = CAMERA_PERSPECTIVE;                 // Camera mode type
+    camera.projection = CAMERA_PERSPECTIVE;                 // Camera projection type
 
     int camera_mode = CAMERA_ORBITAL;
 
     Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
     Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
 
-    DisableCursor();                    // Catch cursor
-    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
-
     // Use the default font
     Font font = GetFontDefault();
     float fontSize = 8.0f;
@@ -135,6 +132,10 @@ int main(void)
 
     // Array filled with multiple random colors (when multicolor mode is set)
     Color multi[TEXT_MAX_LAYERS] = {0};
+
+    DisableCursor();                    // Limit cursor to relative movement inside the window
+
+    SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
 
     // Main game loop

+ 19 - 0
projects/VS2022/raylib.sln

@@ -265,6 +265,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio_stream_effects", "exa
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_textured_curve", "examples\textures_textured_curve.vcxproj", "{769FF0C1-4424-4FA3-BC44-D7A7DA312A06}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_loading_m3d", "examples\models_loading_m3d.vcxproj", "{6D9E00D8-2893-45E4-9363-3F7F61D416BD}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug.DLL|x64 = Debug.DLL|x64
@@ -2225,6 +2227,22 @@ Global
 		{769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release|x64.Build.0 = Release|x64
 		{769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release|x86.ActiveCfg = Release|Win32
 		{769FF0C1-4424-4FA3-BC44-D7A7DA312A06}.Release|x86.Build.0 = Release|Win32
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug|x64.ActiveCfg = Debug|x64
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug|x64.Build.0 = Debug|x64
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug|x86.ActiveCfg = Debug|Win32
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Debug|x86.Build.0 = Debug|Win32
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release.DLL|x64.Build.0 = Release.DLL|x64
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release.DLL|x86.Build.0 = Release.DLL|Win32
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release|x64.ActiveCfg = Release|x64
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release|x64.Build.0 = Release|x64
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release|x86.ActiveCfg = Release|Win32
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD}.Release|x86.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -2359,6 +2377,7 @@ Global
 		{1DE84812-E143-4C4B-A61D-9267AAD55401} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE}
 		{4A87569C-4BD3-4113-B4B9-573D65B3D3F8} = {CC132A4D-D081-4C26-BFB9-AB11984054F8}
 		{769FF0C1-4424-4FA3-BC44-D7A7DA312A06} = {DA049009-21FF-4AC0-84E4-830DD1BCD0CE}
+		{6D9E00D8-2893-45E4-9363-3F7F61D416BD} = {AF5BEC5C-1F2B-4DA8-B12D-D09FE569237C}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29}

+ 1 - 1
src/raylib.h

@@ -1156,7 +1156,7 @@ RLAPI float GetGesturePinchAngle(void);                 // Get gesture pinch ang
 //------------------------------------------------------------------------------------
 // Camera System Functions (Module: rcamera)
 //------------------------------------------------------------------------------------
-RLAPI void UpdateCamera(Camera3D *camera, int mode);              // Update camera position for selected mode
+RLAPI void UpdateCamera(Camera *camera, int mode);      // Update camera position for selected mode
 
 //------------------------------------------------------------------------------------
 // Basic Shapes Drawing Functions (Module: shapes)

+ 44 - 62
src/rcamera.h

@@ -1,6 +1,6 @@
 /*******************************************************************************************
 *
-*   rcamera - Basic camera system for multiple camera modes
+*   rcamera - Basic camera system with support for multiple camera modes
 *
 *   CONFIGURATION:
 *
@@ -15,13 +15,13 @@
 *
 *   CONTRIBUTORS:
 *       Ramon Santamaria:   Supervision, review, update and maintenance
-*       Christoph Wagner:   Redesign (2022)
+*       Christoph Wagner:   Complete redesign, using raymath (2022)
 *       Marc Palau:         Initial implementation (2014)
 *
 *
 *   LICENSE: zlib/libpng
 *
-*   Copyright (c) 2015-2023 Ramon Santamaria (@raysan5)
+*   Copyright (c) 2022-2023 Christoph Wagner (@Crydsch) & Ramon Santamaria (@raysan5)
 *
 *   This software is provided "as-is", without any express or implied warranty. In no event
 *   will the authors be held liable for any damages arising from the use of this software.
@@ -43,9 +43,6 @@
 #ifndef RCAMERA_H
 #define RCAMERA_H
 
-// The only dependency // TODO review standalone mode
-#include "raymath.h"
-
 //----------------------------------------------------------------------------------
 // Defines and Macros
 //----------------------------------------------------------------------------------
@@ -86,6 +83,8 @@
         int projection;         // Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
     } Camera3D;
 
+    typedef Camera3D Camera;    // Camera type fallback, defaults to Camera3D
+
     // Camera system modes
     typedef enum {
         CAMERA_CUSTOM = 0,
@@ -115,19 +114,21 @@
 extern "C" {            // Prevents name mangling of functions
 #endif
 
-Vector3 GetCameraForward(Camera3D* camera);
-Vector3 GetCameraUp(Camera3D* camera);
-Vector3 GetCameraRight(Camera3D* camera);
-void CameraMoveForward(Camera3D* camera, float distance, bool moveInWorldPlane);
-void CameraMoveUp(Camera3D* camera, float distance);
-void CameraMoveRight(Camera3D* camera, float distance, bool moveInWorldPlane);
-void CameraZoom(Camera3D* camera, float delta);
-void CameraYaw(Camera3D* camera, float angle, bool rotateAroundTarget);
-void CameraPitch(Camera3D* camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp);
-void CameraRoll(Camera3D* camera, float angle);
-void CameraViewBobbing(Camera3D* camera);
-Matrix GetCameraViewMatrix(Camera3D* camera);
-Matrix GetCameraProjectionMatrix(Camera3D* camera, float aspect);
+Vector3 GetCameraForward(Camera *camera);
+Vector3 GetCameraUp(Camera *camera);
+Vector3 GetCameraRight(Camera *camera);
+
+void CameraMoveForward(Camera *camera, float distance, bool moveInWorldPlane);
+void CameraMoveUp(Camera *camera, float distance);
+void CameraMoveRight(Camera *camera, float distance, bool moveInWorldPlane);
+void CameraMoveToTarget(Camera *camera, float delta);
+
+void CameraYaw(Camera *camera, float angle, bool rotateAroundTarget);
+void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp);
+void CameraRoll(Camera *camera, float angle);
+
+Matrix GetCameraViewMatrix(Camera *camera);
+Matrix GetCameraProjectionMatrix(Camera* camera, float aspect);
 
 #if defined(__cplusplus)
 }
@@ -144,10 +145,12 @@ Matrix GetCameraProjectionMatrix(Camera3D* camera, float aspect);
 
 #if defined(CAMERA_IMPLEMENTATION)
 
+
+#include "raymath.h"        // Required for some vector maths
+
 //----------------------------------------------------------------------------------
 // Defines and Macros
 //----------------------------------------------------------------------------------
-
 #define CAMERA_MOVE_SPEED                               0.09f
 #define CAMERA_ROTATION_SPEED                           0.03f
 
@@ -185,20 +188,20 @@ Matrix GetCameraProjectionMatrix(Camera3D* camera, float aspect);
 //----------------------------------------------------------------------------------
 
 // Returns the cameras forward vector (normalized)
-Vector3 GetCameraForward(Camera3D *camera)
+Vector3 GetCameraForward(Camera *camera)
 {
     return Vector3Normalize(Vector3Subtract(camera->target, camera->position));
 }
 
 // Returns the cameras up vector (normalized)
 // Note: The up vector might not be perpendicular to the forward vector
-Vector3 GetCameraUp(Camera3D *camera)
+Vector3 GetCameraUp(Camera *camera)
 {
     return Vector3Normalize(camera->up);
 }
 
 // Returns the cameras right vector (normalized)
-Vector3 GetCameraRight(Camera3D *camera)
+Vector3 GetCameraRight(Camera *camera)
 {
     Vector3 forward = GetCameraForward(camera);
     Vector3 up = GetCameraUp(camera);
@@ -206,7 +209,7 @@ Vector3 GetCameraRight(Camera3D *camera)
 }
 
 // Moves the camera in its forward direction
-void CameraMoveForward(Camera3D *camera, float distance, bool moveInWorldPlane)
+void CameraMoveForward(Camera *camera, float distance, bool moveInWorldPlane)
 {
     Vector3 forward = GetCameraForward(camera);
 
@@ -226,7 +229,7 @@ void CameraMoveForward(Camera3D *camera, float distance, bool moveInWorldPlane)
 }
 
 // Moves the camera in its up direction
-void CameraMoveUp(Camera3D *camera, float distance)
+void CameraMoveUp(Camera *camera, float distance)
 {
     Vector3 up = GetCameraUp(camera);
     
@@ -239,7 +242,7 @@ void CameraMoveUp(Camera3D *camera, float distance)
 }
 
 // Moves the camera target in its current right direction
-void CameraMoveRight(Camera3D *camera, float distance, bool moveInWorldPlane)
+void CameraMoveRight(Camera *camera, float distance, bool moveInWorldPlane)
 {
     Vector3 right = GetCameraRight(camera);
 
@@ -259,7 +262,7 @@ void CameraMoveRight(Camera3D *camera, float distance, bool moveInWorldPlane)
 }
 
 // Moves the camera position closer/farther to/from the camera target
-void CameraZoom(Camera3D *camera, float delta)
+void CameraMoveToTarget(Camera *camera, float delta)
 {
     float distance = Vector3Distance(camera->position, camera->target);
 
@@ -278,7 +281,7 @@ void CameraZoom(Camera3D *camera, float delta)
 // Yaw is "looking left and right"
 // If rotateAroundTarget is false, the camera rotates around its position
 // Note: angle must be provided in radians
-void CameraYaw(Camera3D *camera, float angle, bool rotateAroundTarget)
+void CameraYaw(Camera *camera, float angle, bool rotateAroundTarget)
 {
     // Rotation axis
     Vector3 up = GetCameraUp(camera);
@@ -307,7 +310,7 @@ void CameraYaw(Camera3D *camera, float angle, bool rotateAroundTarget)
 // If rotateAroundTarget is false, the camera rotates around its position
 // rotateUp rotates the up direction as well (typically only usefull in CAMERA_FREE)
 // Note: angle must be provided in radians
-void CameraPitch(Camera3D *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp)
+void CameraPitch(Camera *camera, float angle, bool lockView, bool rotateAroundTarget, bool rotateUp)
 {
     // Up direction
     Vector3 up = GetCameraUp(camera);
@@ -359,7 +362,7 @@ void CameraPitch(Camera3D *camera, float angle, bool lockView, bool rotateAround
 // Rotates the camera around its forward vector
 // Roll is "turning your head sideways to the left or right"
 // Note: angle must be provided in radians
-void CameraRoll(Camera3D *camera, float angle)
+void CameraRoll(Camera *camera, float angle)
 {
     // Rotation axis
     Vector3 forward = GetCameraForward(camera);
@@ -368,30 +371,14 @@ void CameraRoll(Camera3D *camera, float angle)
     camera->up = Vector3RotateByAxisAngle(camera->up, forward, angle);
 }
 
-// Moves camera slightly to simulate a walking motion
-// Note: Only active if camera->swingCounter > 0
-void CameraViewBobbing(Camera3D *camera)
-{
-    if (camera->swingCounter > 0)
-    {
-        // NOTE: We delay the target movement relative to the position movement to create a little pitch with each step.
-        camera->position.y = camera->position.y - 0.25f * sinf((camera->swingCounter + 1) / CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER) / CAMERA_FIRST_PERSON_STEP_DIVIDER;
-        camera->target.y = camera->target.y - 0.25f * sinf((camera->swingCounter - 1) / CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER) / CAMERA_FIRST_PERSON_STEP_DIVIDER;
-
-        // Update counter for next frame
-        camera->swingCounter %= 2147483647 /* INT_MAX */; // Counter must be positive
-        camera->swingCounter++;
-    }
-}
-
 // Returns the camera view matrix
-Matrix GetCameraViewMatrix(Camera3D *camera)
+Matrix GetCameraViewMatrix(Camera *camera)
 {
     return MatrixLookAt(camera->position, camera->target, camera->up);
 }
 
 // Returns the camera projection matrix
-Matrix GetCameraProjectionMatrix(Camera3D *camera, float aspect)
+Matrix GetCameraProjectionMatrix(Camera *camera, float aspect)
 {
     if (camera->projection == CAMERA_PERSPECTIVE)
     {
@@ -407,11 +394,10 @@ Matrix GetCameraProjectionMatrix(Camera3D *camera, float aspect)
     return MatrixIdentity();
 }
 
-
 #ifndef CAMERA_STANDALONE
 // Update camera position for selected mode
 // Camera mode: CAMERA_FREE, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON, CAMERA_ORBITAL or CUSTOM
-void UpdateCamera(Camera3D *camera, int mode)
+void UpdateCamera(Camera *camera, int mode)
 {
     Vector2 mousePositionDelta = GetMouseDelta();
 
@@ -422,11 +408,11 @@ void UpdateCamera(Camera3D *camera, int mode)
     
     // Camera movement
     if (IsKeyDown(KEY_W)) CameraMoveForward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
+    if (IsKeyDown(KEY_A)) CameraMoveRight(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
     if (IsKeyDown(KEY_S)) CameraMoveForward(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
     if (IsKeyDown(KEY_D)) CameraMoveRight(camera, CAMERA_MOVE_SPEED, moveInWorldPlane);
-    if (IsKeyDown(KEY_A)) CameraMoveRight(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane);
-    if (IsKeyDown(KEY_SPACE)) CameraMoveUp(camera, CAMERA_MOVE_SPEED);
-    if (IsKeyDown(KEY_LEFT_CONTROL)) CameraMoveUp(camera, -CAMERA_MOVE_SPEED);
+    //if (IsKeyDown(KEY_SPACE)) CameraMoveUp(camera, CAMERA_MOVE_SPEED);
+    //if (IsKeyDown(KEY_LEFT_CONTROL)) CameraMoveUp(camera, -CAMERA_MOVE_SPEED);
 
     // Camera rotation
     if (IsKeyDown(KEY_DOWN)) CameraPitch(camera, -CAMERA_ROTATION_SPEED, lockView, rotateAroundTarget, rotateUp);
@@ -436,17 +422,13 @@ void UpdateCamera(Camera3D *camera, int mode)
     if (IsKeyDown(KEY_Q)) CameraRoll(camera, -CAMERA_ROTATION_SPEED);
     if (IsKeyDown(KEY_E)) CameraRoll(camera, CAMERA_ROTATION_SPEED);
 
-    CameraYaw(camera, mousePositionDelta.x * -CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget);
-    CameraPitch(camera, mousePositionDelta.y * -CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp);
+    CameraYaw(camera, -mousePositionDelta.x*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget);
+    CameraPitch(camera, -mousePositionDelta.y*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp);
 
     // Zoom target distance
-    CameraZoom(camera, -GetMouseWheelMove());
-    if (IsKeyPressed(KEY_KP_SUBTRACT)) CameraZoom(camera, 2.0f);
-    if (IsKeyPressed(KEY_KP_ADD)) CameraZoom(camera, -2.0f);
-
-
-    // Apply view bobbing when moving around (per default only active in CAMERA_FIRST_PERSON)
-    if (mode == CAMERA_FIRST_PERSON && (IsKeyDown(KEY_W) || IsKeyDown(KEY_A) || IsKeyDown(KEY_S) || IsKeyDown(KEY_D))) CameraViewBobbing(camera);
+    CameraMoveToTarget(camera, -GetMouseWheelMove());
+    if (IsKeyPressed(KEY_KP_SUBTRACT)) CameraMoveToTarget(camera, 2.0f);
+    if (IsKeyPressed(KEY_KP_ADD)) CameraMoveToTarget(camera, -2.0f);
 }
 #endif // !CAMERA_STANDALONE
 

+ 0 - 0
src/rcamera_old.h → src/rcamera.old.h


+ 11 - 2
src/rcore.c

@@ -925,6 +925,8 @@ 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;
+    
+    SetMousePosition((int)CORE.Input.Mouse.currentPosition.x, (int)CORE.Input.Mouse.currentPosition.x);
 
 #if defined(SUPPORT_EVENTS_AUTOMATION)
     events = (AutomationEvent *)malloc(MAX_CODE_AUTOMATION_EVENTS*sizeof(AutomationEvent));
@@ -2024,6 +2026,13 @@ void DisableCursor(void)
 {
 #if defined(PLATFORM_DESKTOP)
     glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
+
+    // Set cursor position in the middle of screen and update delta accordingly
+    SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
+    CORE.Input.Mouse.currentPosition.x = CORE.Window.screen.width/2;
+    CORE.Input.Mouse.currentPosition.y = CORE.Window.screen.width/2;
+    CORE.Input.Mouse.previousPosition.x = CORE.Input.Mouse.currentPosition.x;
+    CORE.Input.Mouse.previousPosition.y = CORE.Input.Mouse.currentPosition.y;
 #endif
 #if defined(PLATFORM_WEB)
     emscripten_request_pointerlock("#canvas", 1);
@@ -2189,7 +2198,7 @@ void EndMode2D(void)
 }
 
 // Initializes 3D mode with custom camera (3D)
-void BeginMode3D(Camera3D camera)
+void BeginMode3D(Camera camera)
 {
     rlDrawRenderBatchActive();      // Update and draw internal render batch
 
@@ -3788,7 +3797,7 @@ Vector2 GetMousePosition(void)
 // Get mouse delta between frames
 Vector2 GetMouseDelta(void)
 {
-    Vector2 delta = {0};
+    Vector2 delta = { 0 };
 
     delta.x = CORE.Input.Mouse.currentPosition.x - CORE.Input.Mouse.previousPosition.x;
     delta.y = CORE.Input.Mouse.currentPosition.y - CORE.Input.Mouse.previousPosition.y;