summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorRay <[email protected]>2023-02-14 20:00:51 +0100
committerRay <[email protected]>2023-02-14 20:00:51 +0100
commitea590c44a967075b3f6b420fa76e6387075ecf1d (patch)
treeb456de45fef83507415dcc309c05e64cb9232946 /examples
parent73989a49817225f11f547d270598e93745bf7df0 (diff)
downloadraylib-ea590c44a967075b3f6b420fa76e6387075ecf1d.tar.gz
raylib-ea590c44a967075b3f6b420fa76e6387075ecf1d.zip
REVIEWED: Camera redesign PR
Diffstat (limited to 'examples')
-rw-r--r--examples/core/core_3d_camera_first_person.c41
-rw-r--r--examples/core/core_3d_camera_free.c4
-rw-r--r--examples/core/core_3d_picking.c9
-rw-r--r--examples/core/core_vr_simulator.c6
-rw-r--r--examples/core/core_world_screen.c17
-rw-r--r--examples/models/models_animation.c14
-rw-r--r--examples/models/models_billboard.c22
-rw-r--r--examples/models/models_cubicmap.c16
-rw-r--r--examples/models/models_first_person_maze.c13
-rw-r--r--examples/models/models_heightmap.c28
-rw-r--r--examples/models/models_loading.c3
-rw-r--r--examples/models/models_loading_gltf.c10
-rw-r--r--examples/models/models_loading_m3d.c12
-rw-r--r--examples/models/models_loading_vox.c5
-rw-r--r--examples/models/models_mesh_generation.c3
-rw-r--r--examples/models/models_mesh_picking.c3
-rw-r--r--examples/models/models_rlgl_solar_system.c13
-rw-r--r--examples/models/models_skybox.c14
-rw-r--r--examples/models/models_waving_cubes.c10
-rw-r--r--examples/shaders/shaders_basic_lighting.c8
-rw-r--r--examples/shaders/shaders_custom_uniform.c11
-rw-r--r--examples/shaders/shaders_fog.c17
-rw-r--r--examples/shaders/shaders_mesh_instancing.c16
-rw-r--r--examples/shaders/shaders_model_shader.c16
-rw-r--r--examples/shaders/shaders_postprocessing.c17
-rw-r--r--examples/shaders/shaders_raymarching.c7
-rw-r--r--examples/shaders/shaders_simple_mask.c26
-rw-r--r--examples/shaders/shaders_spotlight.c79
-rw-r--r--examples/text/text_draw_3d.c9
29 files changed, 246 insertions, 203 deletions
diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c
index d98a002f..0fc784fa 100644
--- a/examples/core/core_3d_camera_first_person.c
+++ b/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
diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c
index 887a1df3..59bd158a 100644
--- a/examples/core/core_3d_camera_free.c
+++ b/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
//--------------------------------------------------------------------------------------
diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c
index 0cf56f5f..c7bf9466 100644
--- a/examples/core/core_3d_picking.c
+++ b/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))
diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c
index 3024b785..bc69cc69 100644
--- a/examples/core/core_vr_simulator.c
+++ b/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
//--------------------------------------------------------------------------------------
diff --git a/examples/core/core_world_screen.c b/examples/core/core_world_screen.c
index f96690ba..6c811a50 100644
--- a/examples/core/core_world_screen.c
+++ b/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();
//----------------------------------------------------------------------------------
diff --git a/examples/models/models_animation.c b/examples/models/models_animation.c
index a36f3fe5..ffe2d012 100644
--- a/examples/models/models_animation.c
+++ b/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;
diff --git a/examples/models/models_billboard.c b/examples/models/models_billboard.c
index 6d16cf01..596a09d3 100644
--- a/examples/models/models_billboard.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/models/models_cubicmap.c b/examples/models/models_cubicmap.c
index 83bfab68..714918e4 100644
--- a/examples/models/models_cubicmap.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/models/models_first_person_maze.c b/examples/models/models_first_person_maze.c
index 3f6a935c..6a4345a8 100644
--- a/examples/models/models_first_person_maze.c
+++ b/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
//--------------------------------------------------------------------------------------
diff --git a/examples/models/models_heightmap.c b/examples/models/models_heightmap.c
index 25dc004d..8f32de9f 100644
--- a/examples/models/models_heightmap.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/models/models_loading.c b/examples/models/models_loading.c
index 56dad408..4bce2a79 100644
--- a/examples/models/models_loading.c
+++ b/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
//--------------------------------------------------------------------------------------
diff --git a/examples/models/models_loading_gltf.c b/examples/models/models_loading_gltf.c
index 0c907071..d8b34efe 100644
--- a/examples/models/models_loading_gltf.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/models/models_loading_m3d.c b/examples/models/models_loading_m3d.c
index c1a4af07..42d3416d 100644
--- a/examples/models/models_loading_m3d.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/models/models_loading_vox.c b/examples/models/models_loading_vox.c
index 6a38fe89..d17fd6ee 100644
--- a/examples/models/models_loading_vox.c
+++ b/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
//--------------------------------------------------------------------------------------
diff --git a/examples/models/models_mesh_generation.c b/examples/models/models_mesh_generation.c
index 8e9fdf90..6189fb46 100644
--- a/examples/models/models_mesh_generation.c
+++ b/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
//--------------------------------------------------------------------------------------
diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c
index 1118168c..69d98aa1 100644
--- a/examples/models/models_mesh_picking.c
+++ b/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
diff --git a/examples/models/models_rlgl_solar_system.c b/examples/models/models_rlgl_solar_system.c
index 24f8b9a5..fc2a1f02 100644
--- a/examples/models/models_rlgl_solar_system.c
+++ b/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
//--------------------------------------------------------------------------------------
diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c
index d12cc557..34616de5 100644
--- a/examples/models/models_skybox.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/models/models_waving_cubes.c b/examples/models/models_waving_cubes.c
index 31ed4ff4..d382c998 100644
--- a/examples/models/models_waving_cubes.c
+++ b/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;
diff --git a/examples/shaders/shaders_basic_lighting.c b/examples/shaders/shaders_basic_lighting.c
index 702177f1..49dc1e7d 100644
--- a/examples/shaders/shaders_basic_lighting.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c
index c617a6d1..eaeca5e5 100644
--- a/examples/shaders/shaders_custom_uniform.c
+++ b/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
//--------------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_fog.c b/examples/shaders/shaders_fog.c
index c4b619ed..ddd721d4 100644
--- a/examples/shaders/shaders_fog.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_mesh_instancing.c b/examples/shaders/shaders_mesh_instancing.c
index 0c2f9e1d..02a7ee8f 100644
--- a/examples/shaders/shaders_mesh_instancing.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_model_shader.c b/examples/shaders/shaders_model_shader.c
index 069d0ee2..e84ecbfb 100644
--- a/examples/shaders/shaders_model_shader.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c
index 688ca909..991e9839 100644
--- a/examples/shaders/shaders_postprocessing.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_raymarching.c b/examples/shaders/shaders_raymarching.c
index 5cc9af05..7b34a523 100644
--- a/examples/shaders/shaders_raymarching.c
+++ b/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
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_simple_mask.c b/examples/shaders/shaders_simple_mask.c
index 49470294..6283ccbc 100644
--- a/examples/shaders/shaders_simple_mask.c
+++ b/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();
diff --git a/examples/shaders/shaders_spotlight.c b/examples/shaders/shaders_spotlight.c
index a21e3c82..c96c983d 100644
--- a/examples/shaders/shaders_spotlight.c
+++ b/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);
}
diff --git a/examples/text/text_draw_3d.c b/examples/text/text_draw_3d.c
index c90ea665..097e4fc6 100644
--- a/examples/text/text_draw_3d.c
+++ b/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