adjust examples for new UpdateCamera function

This commit is contained in:
Crydsch 2022-09-02 16:19:36 +02:00
parent 866d47434f
commit 42a6520f4d
26 changed files with 54 additions and 81 deletions

View File

@ -51,9 +51,7 @@ int main(void)
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
} }
// Catch cursor DisableCursor(); // Catch cursor
DisableCursor();
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View File

@ -35,8 +35,6 @@ int main(void)
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -45,7 +43,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FREE);
if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@ -40,8 +40,7 @@ int main(void)
RayCollision collision = { 0 }; RayCollision collision = { 0 };
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode EnableCursor(); // Disable camera controls
EnableCursor(); // Disable camera controls
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -51,7 +50,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsCursorHidden()) UpdateCamera(&camera); // Update camera if (IsCursorHidden()) UpdateCamera(&camera, CAMERA_FIRST_PERSON); // Update camera
// Toggle camera controls // Toggle camera controls
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))

View File

@ -96,11 +96,11 @@ int main(void)
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector
camera.fovy = 60.0f; // Camera field-of-view Y camera.fovy = 60.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera type camera.projection = CAMERA_PERSPECTIVE; // Camera type
camera.swingCounter = 1; // Enable view bobbing
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
SetCameraMode(&camera, CAMERA_FIRST_PERSON); // Set first person camera mode DisableCursor(); // Catch cursor
SetTargetFPS(90); // Set our game to run at 90 frames-per-second SetTargetFPS(90); // Set our game to run at 90 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -109,7 +109,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FIRST_PERSON);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View File

@ -36,8 +36,7 @@ int main(void)
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
Vector2 cubeScreenPosition = { 0.0f, 0.0f }; Vector2 cubeScreenPosition = { 0.0f, 0.0f };
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -46,7 +45,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_THIRD_PERSON);
// Calculate cube screen space position (with a little offset to be in top) // Calculate cube screen space position (with a little offset to be in top)
cubeScreenPosition = GetWorldToScreen((Vector3){cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera); cubeScreenPosition = GetWorldToScreen((Vector3){cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera);

View File

@ -54,8 +54,7 @@ int main(void)
ModelAnimation *anims = LoadModelAnimations("resources/models/iqm/guyanim.iqm", &animsCount); ModelAnimation *anims = LoadModelAnimations("resources/models/iqm/guyanim.iqm", &animsCount);
int animFrameCounter = 0; int animFrameCounter = 0;
SetCameraMode(&camera, CAMERA_FREE); // Set free camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -64,7 +63,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FIRST_PERSON);
// Play animation when spacebar is held down // Play animation when spacebar is held down
if (IsKeyDown(KEY_SPACE)) if (IsKeyDown(KEY_SPACE))

View File

@ -36,8 +36,7 @@ int main(void)
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -46,7 +45,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View File

@ -42,8 +42,7 @@ int main(void)
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -52,7 +51,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View File

@ -45,8 +45,7 @@ int main(void)
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position
SetCameraMode(&camera, CAMERA_FIRST_PERSON); // Set camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -57,7 +56,7 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
Vector3 oldCamPos = camera.position; // Store old camera position Vector3 oldCamPos = camera.position; // Store old camera position
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FIRST_PERSON);
// Check player collision (we simplify to 2D collision detection) // Check player collision (we simplify to 2D collision detection)
Vector2 playerPos = { camera.position.x, camera.position.z }; Vector2 playerPos = { camera.position.x, camera.position.z };

View File

@ -39,8 +39,7 @@ int main(void)
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -49,7 +48,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View File

@ -57,10 +57,9 @@ int main(void)
// NOTE: bounds are calculated from the original size of the model, // NOTE: bounds are calculated from the original size of the model,
// if model is scaled on drawing, bounds must be also scaled // if model is scaled on drawing, bounds must be also scaled
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode
bool selected = false; // Selected object flag bool selected = false; // Selected object flag
DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -69,7 +68,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FIRST_PERSON);
// Load new models/textures on drag&drop // Load new models/textures on drag&drop
if (IsFileDropped()) if (IsFileDropped())

View File

@ -38,8 +38,7 @@ int main(void)
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
SetCameraMode(&camera, CAMERA_FREE); // Set free camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -48,7 +47,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_THIRD_PERSON);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View File

@ -69,8 +69,7 @@ int main(void)
int currentModel = 0; int currentModel = 0;
SetCameraMode(&camera, CAMERA_ORBITAL); // Set a orbital camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -79,7 +78,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
// Cycle between models on mouse click // Cycle between models on mouse click
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1)%MAX_VOX_FILES; if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1)%MAX_VOX_FILES;

View File

@ -68,8 +68,7 @@ int main(void)
int currentModel = 0; int currentModel = 0;
SetCameraMode(&camera, CAMERA_ORBITAL); // Set a orbital camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -78,7 +77,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
{ {

View File

@ -64,9 +64,7 @@ int main(void)
Vector3 sp = (Vector3){ -30.0f, 5.0f, 5.0f }; Vector3 sp = (Vector3){ -30.0f, 5.0f, 5.0f };
float sr = 4.0f; float sr = 4.0f;
SetCameraMode(&camera, CAMERA_FREE); // Set a free camera mode EnableCursor(); // Disable camera controls
EnableCursor(); // Disable camera controls
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
@ -74,7 +72,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsCursorHidden()) UpdateCamera(&camera); // Update camera if (IsCursorHidden()) UpdateCamera(&camera, CAMERA_FIRST_PERSON); // Update camera
// Toggle camera controls // Toggle camera controls
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))

View File

@ -49,8 +49,6 @@ int main(void)
camera.fovy = 45.0f; camera.fovy = 45.0f;
camera.projection = CAMERA_PERSPECTIVE; camera.projection = CAMERA_PERSPECTIVE;
SetCameraMode(&camera, CAMERA_FREE);
float rotationSpeed = 0.2f; // General system rotation speed float rotationSpeed = 0.2f; // General system rotation speed
float earthRotation = 0.0f; // Rotation of earth around itself (days) in degrees float earthRotation = 0.0f; // Rotation of earth around itself (days) in degrees
@ -58,6 +56,7 @@ int main(void)
float moonRotation = 0.0f; // Rotation of moon around itself float moonRotation = 0.0f; // Rotation of moon around itself
float moonOrbitRotation = 0.0f; // Rotation of moon around earth in degrees float moonOrbitRotation = 0.0f; // Rotation of moon around earth in degrees
DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -66,7 +65,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
earthRotation += (5.0f*rotationSpeed); earthRotation += (5.0f*rotationSpeed);
earthOrbitRotation += (365/360.0f*(5.0f*rotationSpeed)*rotationSpeed); earthOrbitRotation += (365/360.0f*(5.0f*rotationSpeed)*rotationSpeed);

View File

@ -87,8 +87,7 @@ int main(void)
UnloadImage(img); UnloadImage(img);
} }
SetCameraMode(&camera, CAMERA_FIRST_PERSON); // Set a first person camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -97,7 +96,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FIRST_PERSON);
// Load new cubemap texture on drag&drop // Load new cubemap texture on drag&drop
if (IsFileDropped()) if (IsFileDropped())

View File

@ -80,8 +80,7 @@ int main(void)
lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, shader); lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, shader);
lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, shader); lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, shader);
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -90,7 +89,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
// Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f }) // Update the shader with the camera view vector (points towards { 0.0f, 0.0f, 0.0f })
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };

View File

@ -67,9 +67,7 @@ int main(void)
// Create a RenderTexture2D to be used for render to texture // Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
// Setup orbital camera DisableCursor(); // Catch cursor
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -78,7 +76,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
Vector2 mousePosition = GetMousePosition(); Vector2 mousePosition = GetMousePosition();

View File

@ -84,8 +84,7 @@ int main(void)
// Using just 1 point lights // Using just 1 point lights
CreateLight(LIGHT_POINT, (Vector3){ 0, 2, 6 }, Vector3Zero(), WHITE, shader); CreateLight(LIGHT_POINT, (Vector3){ 0, 2, 6 }, Vector3Zero(), WHITE, shader);
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -94,7 +93,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
if (IsKeyDown(KEY_UP)) if (IsKeyDown(KEY_UP))
{ {

View File

@ -94,9 +94,7 @@ int main(void)
Material matDefault = LoadMaterialDefault(); Material matDefault = LoadMaterialDefault();
matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE; matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE;
// Set an orbital camera mode DisableCursor(); // Catch cursor
SetCameraMode(&camera, CAMERA_ORBITAL);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -105,7 +103,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
// Update the light shader with the camera view position // Update the light shader with the camera view position
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };

View File

@ -60,8 +60,7 @@ int main(void)
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
SetCameraMode(&camera, CAMERA_FREE); // Set an orbital camera mode DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -70,7 +69,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FIRST_PERSON);
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View File

@ -107,9 +107,7 @@ int main(void)
// Create a RenderTexture2D to be used for render to texture // Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
// Setup orbital camera DisableCursor(); // Catch cursor
SetCameraMode(&camera, CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -118,7 +116,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_ORBITAL);
if (IsKeyPressed(KEY_RIGHT)) currentShader++; if (IsKeyPressed(KEY_RIGHT)) currentShader++;
else if (IsKeyPressed(KEY_LEFT)) currentShader--; else if (IsKeyPressed(KEY_LEFT)) currentShader--;

View File

@ -41,8 +41,6 @@ int main(void)
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) 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.fovy = 65.0f; // Camera field-of-view Y
SetCameraMode(&camera, CAMERA_FREE); // Set camera mode
// Load raymarching shader // Load raymarching shader
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/raymarching.fs", GLSL_VERSION)); Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/raymarching.fs", GLSL_VERSION));
@ -58,6 +56,7 @@ int main(void)
float runTime = 0.0f; float runTime = 0.0f;
DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -66,7 +65,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FIRST_PERSON);
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
float cameraTarget[3] = { camera.target.x, camera.target.y, camera.target.z }; float cameraTarget[3] = { camera.target.x, camera.target.y, camera.target.z };

View File

@ -85,6 +85,7 @@ int main(void)
int framesCounter = 0; 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 SetTargetFPS(60); // Set to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -93,7 +94,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, CAMERA_FIRST_PERSON);
framesCounter++; framesCounter++;
rotation.x += 0.01f; rotation.x += 0.01f;

View File

@ -98,11 +98,12 @@ int main(void)
camera.fovy = 45.0f; // Camera field-of-view Y camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
SetCameraMode(&camera, CAMERA_ORBITAL); int camera_mode = CAMERA_ORBITAL;
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f }; Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
// Use the default font // Use the default font
@ -141,7 +142,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateCamera(&camera); UpdateCamera(&camera, camera_mode);
// Handle font files dropped // Handle font files dropped
if (IsFileDropped()) if (IsFileDropped())
@ -181,12 +182,12 @@ int main(void)
if (spin) if (spin)
{ {
camera.position = (Vector3){ -10.0f, 15.0f, -10.0f }; // Camera position camera.position = (Vector3){ -10.0f, 15.0f, -10.0f }; // Camera position
SetCameraMode(&camera, CAMERA_ORBITAL); camera_mode = CAMERA_ORBITAL;
} }
else else
{ {
camera.position = (Vector3){ 10.0f, 10.0f, -10.0f }; // Camera position camera.position = (Vector3){ 10.0f, 10.0f, -10.0f }; // Camera position
SetCameraMode(&camera, CAMERA_FREE); camera_mode = CAMERA_FREE;
} }
} }