Upgrade Raylib to 6.0 (#337)
* Updated target to Raylib 6 + synced invoke called with the changes in C. [WARNING: Breaking changes!] * Added severial examples. Corrected towards the correct return type and add utilities to prevent working with pointers * Additional resources from the Raylib repo. * Fixed additional pinvokes to match with the new raylib bindings. [Warning breaking changes!] * Fixing the QOL utils * Fixing the Mesh struct * Applying changes after review. Merged resources.LICENSE + raylib-cs.Native.csproj only targets dotnet8 * Updated README to reflect .NET 10 and Raylib 6 compatibility changes. * Updated shader colors, adjusted car model scale, disabled HDR in SkyboxDemo, and fixed camera mode assignment. Removed unused `Capacity` field in FilePathList struct. * Improved XML comments for consistency, fixed spacing and formatting across examples, added new resources to `resources.LICENSE`. * Updated XML comment for `GetDirectoryFileCountEx` to clarify behavior and filtering options. * Updated and clarified XML comments for methods and parameters, improved naming consistency, and refined shader-related functions. Renamed enums in `Shader.cs` for so it is inline with the upstream. * Improved XML comments for clarity and consistency in `Model.cs` and `Mesh.cs`, updated method and variable names for better readability, and adjusted logic in span creation methods. * Corrected XML comment capitalization in `Model.cs`. --------- Co-authored-by: Meatcorps <info@meatcorps.nl>
This commit is contained in:
parent
1b890169c5
commit
21d83c60a9
189 changed files with 43644 additions and 380 deletions
130
Examples/Core/DeltaTime.cs
Normal file
130
Examples/Core/DeltaTime.cs
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - delta time
|
||||
*
|
||||
* Example complexity rating: [★☆☆☆] 1/4
|
||||
*
|
||||
* Example originally created with raylib 5.5, last time updated with raylib 6.0
|
||||
*
|
||||
* Example contributed by Robin (@RobinsAviary) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2025 Robin (@RobinsAviary)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System.Numerics;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
public class DeltaTime
|
||||
{
|
||||
public static int Main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - delta time");
|
||||
|
||||
int currentFps = 60;
|
||||
|
||||
Vector2 deltaCircle = new Vector2(0, (float)screenHeight / 3.0f);
|
||||
Vector2 frameCircle = new Vector2(0, (float)screenHeight * (2.0f / 3.0f));
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
const float speed = 10.0f;
|
||||
const float circleRadius = 32.0f;
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// Adjust the FPS target based on the mouse wheel
|
||||
float mouseWheel = GetMouseWheelMove();
|
||||
if (mouseWheel != 0)
|
||||
{
|
||||
currentFps += (int)mouseWheel;
|
||||
if (currentFps < 0)
|
||||
{
|
||||
currentFps = 0;
|
||||
}
|
||||
SetTargetFPS(currentFps);
|
||||
}
|
||||
|
||||
// GetFrameTime() returns the time it took to draw the last frame, in seconds (usually called delta time)
|
||||
// Uses the delta time to make the circle look like it's moving at a "consistent" speed regardless of FPS
|
||||
|
||||
// Multiply by 6.0 (an arbitrary value) in order to make the speed
|
||||
// visually closer to the other circle (at 60 fps), for comparison
|
||||
deltaCircle.X += GetFrameTime() * 6.0f * speed;
|
||||
// This circle can move faster or slower visually depending on the FPS
|
||||
frameCircle.X += 0.1f * speed;
|
||||
|
||||
// If either circle is off the screen, reset it back to the start
|
||||
if (deltaCircle.X > screenWidth)
|
||||
{
|
||||
deltaCircle.X = 0;
|
||||
}
|
||||
|
||||
if (frameCircle.X > screenWidth)
|
||||
{
|
||||
frameCircle.X = 0;
|
||||
}
|
||||
|
||||
// Reset both circles positions
|
||||
if (IsKeyPressed(KeyboardKey.R))
|
||||
{
|
||||
deltaCircle.X = 0;
|
||||
frameCircle.X = 0;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
ClearBackground(Color.RayWhite);
|
||||
|
||||
// Draw both circles to the screen
|
||||
DrawCircleV(deltaCircle, circleRadius, Color.Red);
|
||||
DrawCircleV(frameCircle, circleRadius, Color.Blue);
|
||||
|
||||
// Draw the help text
|
||||
// Determine what help text to show depending on the current FPS target
|
||||
var fpsText = "";
|
||||
if (currentFps <= 0)
|
||||
{
|
||||
fpsText = $"FPS: unlimited ({GetFPS()})";
|
||||
}
|
||||
else
|
||||
{
|
||||
fpsText = $"FPS: {GetFPS()} (target: {currentFps})";
|
||||
}
|
||||
DrawText(fpsText, 10, 10, 20, Color.DarkGray);
|
||||
DrawText($"Frame time: {GetFrameTime():F2} ms", 10, 30, 20, Color.DarkGray);
|
||||
DrawText("Use the scroll wheel to change the fps limit, r to reset", 10, 50, 20, Color.DarkGray);
|
||||
|
||||
// Draw the text above the circles
|
||||
DrawText("FUNC: x += GetFrameTime()*speed", 10, 90, 20, Color.Red);
|
||||
DrawText("FUNC: x += speed", 10, 240, 20, Color.Blue);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow();
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue