2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-03 11:09:40 -04:00

Update enum/color names to match C# naming convention (#224)

This commit is contained in:
Danil 2024-01-18 21:00:57 +02:00 committed by GitHub
parent 2a1889403d
commit 70d86837d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
123 changed files with 1843 additions and 1847 deletions

View File

@ -36,27 +36,27 @@ public class ModulePlaying
const int screenWidth = 800;
const int screenHeight = 450;
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
SetConfigFlags(ConfigFlags.Msaa4xHint); // NOTE: Try to enable MSAA 4X
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
InitAudioDevice();
Color[] colors = new Color[14] {
Color.ORANGE,
Color.RED,
Color.GOLD,
Color.LIME,
Color.BLUE,
Color.VIOLET,
Color.BROWN,
Color.LIGHTGRAY,
Color.PINK,
Color.YELLOW,
Color.GREEN,
Color.SKYBLUE,
Color.PURPLE,
Color.BEIGE
Color.Orange,
Color.Red,
Color.Gold,
Color.Lime,
Color.Blue,
Color.Violet,
Color.Brown,
Color.LightGray,
Color.Pink,
Color.Yellow,
Color.Green,
Color.SkyBlue,
Color.Purple,
Color.Beige
};
// Creates ome circles for visual effect
@ -92,14 +92,14 @@ public class ModulePlaying
UpdateMusicStream(music); // Update music buffer with new stream data
// Restart music playing (stop and play)
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
StopMusicStream(music);
PlayMusicStream(music);
}
// Pause/Resume music playing
if (IsKeyPressed(KeyboardKey.KEY_P))
if (IsKeyPressed(KeyboardKey.P))
{
pause = !pause;
@ -113,11 +113,11 @@ public class ModulePlaying
}
}
if (IsKeyDown(KeyboardKey.KEY_DOWN))
if (IsKeyDown(KeyboardKey.Down))
{
pitch -= 0.01f;
}
else if (IsKeyDown(KeyboardKey.KEY_UP))
else if (IsKeyDown(KeyboardKey.Up))
{
pitch += 0.01f;
}
@ -159,7 +159,7 @@ public class ModulePlaying
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
for (int i = MaxCircles - 1; i >= 0; i--)
{
@ -171,9 +171,9 @@ public class ModulePlaying
}
// Draw time bar
DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, Color.LIGHTGRAY);
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, Color.MAROON);
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, Color.GRAY);
DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, Color.LightGray);
DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, Color.Maroon);
DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -44,14 +44,14 @@ public class MusicStreamDemo
UpdateMusicStream(music); // Update music buffer with new stream data
// Restart music playing (stop and play)
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
StopMusicStream(music);
PlayMusicStream(music);
}
// Pause/Resume music playing
if (IsKeyPressed(KeyboardKey.KEY_P))
if (IsKeyPressed(KeyboardKey.P))
{
pause = !pause;
@ -77,16 +77,16 @@ public class MusicStreamDemo
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, Color.LIGHTGRAY);
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, Color.LightGray);
DrawRectangle(200, 200, 400, 12, Color.LIGHTGRAY);
DrawRectangle(200, 200, (int)timePlayed, 12, Color.MAROON);
DrawRectangleLines(200, 200, 400, 12, Color.GRAY);
DrawRectangle(200, 200, 400, 12, Color.LightGray);
DrawRectangle(200, 200, (int)timePlayed, 12, Color.Maroon);
DrawRectangleLines(200, 200, 400, 12, Color.Gray);
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, Color.LIGHTGRAY);
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, Color.LIGHTGRAY);
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, Color.LightGray);
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -38,12 +38,12 @@ public class SoundLoading
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
PlaySound(fxWav);
}
if (IsKeyPressed(KeyboardKey.KEY_ENTER))
if (IsKeyPressed(KeyboardKey.Enter))
{
PlaySound(fxOgg);
}
@ -52,10 +52,10 @@ public class SoundLoading
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, Color.LIGHTGRAY);
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, Color.LIGHTGRAY);
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, Color.LightGray);
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -78,7 +78,7 @@ public class BasicScreenManager
// TODO: Update TITLE screen variables here!
// Press enter to change to GAMEPLAY screen
if (IsKeyPressed(KeyboardKey.KEY_ENTER) || IsGestureDetected(Gesture.GESTURE_TAP))
if (IsKeyPressed(KeyboardKey.Enter) || IsGestureDetected(Gesture.Tap))
{
currentScreen = GameScreen.Gameplay;
}
@ -89,7 +89,7 @@ public class BasicScreenManager
// TODO: Update GAMEPLAY screen variables here!
// Press enter to change to ENDING screen
if (IsKeyPressed(KeyboardKey.KEY_ENTER) || IsGestureDetected(Gesture.GESTURE_TAP))
if (IsKeyPressed(KeyboardKey.Enter) || IsGestureDetected(Gesture.Tap))
{
currentScreen = GameScreen.Ending;
}
@ -100,7 +100,7 @@ public class BasicScreenManager
// TODO: Update ENDING screen variables here!
// Press enter to return to TITLE screen
if (IsKeyPressed(KeyboardKey.KEY_ENTER) || IsGestureDetected(Gesture.GESTURE_TAP))
if (IsKeyPressed(KeyboardKey.Enter) || IsGestureDetected(Gesture.Tap))
{
currentScreen = GameScreen.Title;
}
@ -115,42 +115,42 @@ public class BasicScreenManager
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
switch (currentScreen)
{
case GameScreen.Logo:
{
// TODO: Draw LOGO screen here!
DrawText("LOGO SCREEN", 20, 20, 40, Color.LIGHTGRAY);
DrawText("WAIT for 2 SECONDS...", 290, 220, 20, Color.GRAY);
DrawText("LOGO SCREEN", 20, 20, 40, Color.LightGray);
DrawText("WAIT for 2 SECONDS...", 290, 220, 20, Color.Gray);
}
break;
case GameScreen.Title:
{
// TODO: Draw TITLE screen here!
DrawRectangle(0, 0, screenWidth, screenHeight, Color.GREEN);
DrawText("TITLE SCREEN", 20, 20, 40, Color.DARKGREEN);
DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, Color.DARKGREEN);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.Green);
DrawText("TITLE SCREEN", 20, 20, 40, Color.DarkGreen);
DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, Color.DarkGreen);
}
break;
case GameScreen.Gameplay:
{
// TODO: Draw GAMEPLAY screen here!
DrawRectangle(0, 0, screenWidth, screenHeight, Color.PURPLE);
DrawText("GAMEPLAY SCREEN", 20, 20, 40, Color.MAROON);
DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, Color.MAROON);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.Purple);
DrawText("GAMEPLAY SCREEN", 20, 20, 40, Color.Maroon);
DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, Color.Maroon);
}
break;
case GameScreen.Ending:
{
// TODO: Draw ENDING screen here!
DrawRectangle(0, 0, screenWidth, screenHeight, Color.BLUE);
DrawText("ENDING SCREEN", 20, 20, 40, Color.DARKBLUE);
DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, Color.DARKBLUE);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.Blue);
DrawText("ENDING SCREEN", 20, 20, 40, Color.DarkBlue);
DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, Color.DarkBlue);
}
break;

View File

@ -51,9 +51,9 @@ public class BasicWindow
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Congrats! You created your first window!", 190, 200, 20, Color.MAROON);
DrawText("Congrats! You created your first window!", 190, 200, 20, Color.Maroon);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -66,11 +66,11 @@ public class Camera2dDemo
//----------------------------------------------------------------------------------
// Player movement
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
player.X += 2;
}
else if (IsKeyDown(KeyboardKey.KEY_LEFT))
else if (IsKeyDown(KeyboardKey.Left))
{
player.X -= 2;
}
@ -79,11 +79,11 @@ public class Camera2dDemo
camera.Target = new Vector2(player.X + 20, player.Y + 20);
// Camera3D rotation controls
if (IsKeyDown(KeyboardKey.KEY_A))
if (IsKeyDown(KeyboardKey.A))
{
camera.Rotation--;
}
else if (IsKeyDown(KeyboardKey.KEY_S))
else if (IsKeyDown(KeyboardKey.S))
{
camera.Rotation++;
}
@ -111,7 +111,7 @@ public class Camera2dDemo
}
// Camera3D reset (zoom and rotation)
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
camera.Zoom = 1.0f;
camera.Rotation = 0.0f;
@ -121,45 +121,45 @@ public class Camera2dDemo
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode2D(camera);
DrawRectangle(-6000, 320, 13000, 8000, Color.DARKGRAY);
DrawRectangle(-6000, 320, 13000, 8000, Color.DarkGray);
for (int i = 0; i < MaxBuildings; i++)
{
DrawRectangleRec(buildings[i], buildColors[i]);
}
DrawRectangleRec(player, Color.RED);
DrawRectangleRec(player, Color.Red);
DrawRectangle((int)camera.Target.X, -500, 1, (int)(screenHeight * 4), Color.GREEN);
DrawRectangle((int)camera.Target.X, -500, 1, (int)(screenHeight * 4), Color.Green);
DrawLine(
(int)(-screenWidth * 10),
(int)camera.Target.Y,
(int)(screenWidth * 10),
(int)camera.Target.Y,
Color.GREEN
Color.Green
);
EndMode2D();
DrawText("SCREEN AREA", 640, 10, 20, Color.RED);
DrawText("SCREEN AREA", 640, 10, 20, Color.Red);
DrawRectangle(0, 0, (int)screenWidth, 5, Color.RED);
DrawRectangle(0, 5, 5, (int)screenHeight - 10, Color.RED);
DrawRectangle((int)screenWidth - 5, 5, 5, (int)screenHeight - 10, Color.RED);
DrawRectangle(0, (int)screenHeight - 5, (int)screenWidth, 5, Color.RED);
DrawRectangle(0, 0, (int)screenWidth, 5, Color.Red);
DrawRectangle(0, 5, 5, (int)screenHeight - 10, Color.Red);
DrawRectangle((int)screenWidth - 5, 5, 5, (int)screenHeight - 10, Color.Red);
DrawRectangle(0, (int)screenHeight - 5, (int)screenWidth, 5, Color.Red);
DrawRectangle(10, 10, 250, 113, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(10, 10, 250, 113, Color.BLUE);
DrawRectangle(10, 10, 250, 113, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(10, 10, 250, 113, Color.Blue);
DrawText("Free 2d camera controls:", 20, 20, 10, Color.BLACK);
DrawText("- Right/Left to move Offset", 40, 40, 10, Color.DARKGRAY);
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, Color.DARKGRAY);
DrawText("- A / S to Rotate", 40, 80, 10, Color.DARKGRAY);
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, Color.DARKGRAY);
DrawText("Free 2d camera controls:", 20, 20, 10, Color.Black);
DrawText("- Right/Left to move Offset", 40, 40, 10, Color.DarkGray);
DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, Color.DarkGray);
DrawText("- A / S to Rotate", 40, 80, 10, Color.DarkGray);
DrawText("- R to reset Zoom and Rotation", 40, 100, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -70,11 +70,11 @@ public class Camera2dPlatformer
EnvItem[] envItems = new EnvItem[]
{
new EnvItem(new Rectangle(0, 0, 1000, 400), 0, Color.LIGHTGRAY),
new EnvItem(new Rectangle(0, 400, 1000, 200), 1, Color.GRAY),
new EnvItem(new Rectangle(300, 200, 400, 10), 1, Color.GRAY),
new EnvItem(new Rectangle(250, 300, 100, 10), 1, Color.GRAY),
new EnvItem(new Rectangle(650, 300, 100, 10), 1, Color.GRAY)
new EnvItem(new Rectangle(0, 0, 1000, 400), 0, Color.LightGray),
new EnvItem(new Rectangle(0, 400, 1000, 200), 1, Color.Gray),
new EnvItem(new Rectangle(300, 200, 400, 10), 1, Color.Gray),
new EnvItem(new Rectangle(250, 300, 100, 10), 1, Color.Gray),
new EnvItem(new Rectangle(650, 300, 100, 10), 1, Color.Gray)
};
Camera2D camera = new();
@ -127,13 +127,13 @@ public class Camera2dPlatformer
camera.Zoom = 0.25f;
}
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
camera.Zoom = 1.0f;
player.Position = new Vector2(400, 280);
}
if (IsKeyPressed(KeyboardKey.KEY_C))
if (IsKeyPressed(KeyboardKey.C))
{
cameraOption = (cameraOption + 1) % cameraUpdatersLength;
}
@ -145,7 +145,7 @@ public class Camera2dPlatformer
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.LIGHTGRAY);
ClearBackground(Color.LightGray);
BeginMode2D(camera);
@ -155,17 +155,17 @@ public class Camera2dPlatformer
}
Rectangle playerRect = new(player.Position.X - 20, player.Position.Y - 40, 40, 40);
DrawRectangleRec(playerRect, Color.RED);
DrawRectangleRec(playerRect, Color.Red);
EndMode2D();
DrawText("Controls:", 20, 20, 10, Color.BLACK);
DrawText("- Right/Left to move", 40, 40, 10, Color.DARKGRAY);
DrawText("- Space to jump", 40, 60, 10, Color.DARKGRAY);
DrawText("- Mouse Wheel to Zoom in-out, R to reset zoom", 40, 80, 10, Color.DARKGRAY);
DrawText("- C to change camera mode", 40, 100, 10, Color.DARKGRAY);
DrawText("Current camera mode:", 20, 120, 10, Color.BLACK);
DrawText(cameraDescriptions[cameraOption], 40, 140, 10, Color.DARKGRAY);
DrawText("Controls:", 20, 20, 10, Color.Black);
DrawText("- Right/Left to move", 40, 40, 10, Color.DarkGray);
DrawText("- Space to jump", 40, 60, 10, Color.DarkGray);
DrawText("- Mouse Wheel to Zoom in-out, R to reset zoom", 40, 80, 10, Color.DarkGray);
DrawText("- C to change camera mode", 40, 100, 10, Color.DarkGray);
DrawText("Current camera mode:", 20, 120, 10, Color.Black);
DrawText(cameraDescriptions[cameraOption], 40, 140, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------
@ -181,17 +181,17 @@ public class Camera2dPlatformer
static void UpdatePlayer(ref Player player, EnvItem[] envItems, float delta)
{
if (IsKeyDown(KeyboardKey.KEY_LEFT))
if (IsKeyDown(KeyboardKey.Left))
{
player.Position.X -= PlayerHorSpeed * delta;
}
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
player.Position.X += PlayerHorSpeed * delta;
}
if (IsKeyDown(KeyboardKey.KEY_SPACE) && player.CanJump)
if (IsKeyDown(KeyboardKey.Space) && player.CanJump)
{
player.Speed = -PlayerJumpSpeed;
player.CanJump = false;

View File

@ -33,7 +33,7 @@ public class Camera3dFirstPerson
camera.Target = new Vector3(0.0f, 1.8f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 60.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Generates some random columns
float[] heights = new float[MaxColumns];
@ -47,7 +47,7 @@ public class Camera3dFirstPerson
colors[i] = new Color(GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255);
}
CameraMode cameraMode = CameraMode.CAMERA_FIRST_PERSON;
CameraMode cameraMode = CameraMode.FirstPerson;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -58,54 +58,54 @@ public class Camera3dFirstPerson
// Update
//----------------------------------------------------------------------------------
// Switch camera mode
if (IsKeyPressed(KeyboardKey.KEY_ONE))
if (IsKeyPressed(KeyboardKey.One))
{
cameraMode = CameraMode.CAMERA_FREE;
cameraMode = CameraMode.Free;
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
}
if (IsKeyPressed(KeyboardKey.KEY_TWO))
if (IsKeyPressed(KeyboardKey.Two))
{
cameraMode = CameraMode.CAMERA_FIRST_PERSON;
cameraMode = CameraMode.FirstPerson;
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
}
if (IsKeyPressed(KeyboardKey.KEY_THREE))
if (IsKeyPressed(KeyboardKey.Three))
{
cameraMode = CameraMode.CAMERA_THIRD_PERSON;
cameraMode = CameraMode.ThirdPerson;
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
}
if (IsKeyPressed(KeyboardKey.KEY_FOUR))
if (IsKeyPressed(KeyboardKey.Four))
{
cameraMode = CameraMode.CAMERA_ORBITAL;
cameraMode = CameraMode.Orbital;
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
}
// Switch camera projection
if (IsKeyPressed(KeyboardKey.KEY_P))
if (IsKeyPressed(KeyboardKey.P))
{
if (camera.Projection == CameraProjection.CAMERA_PERSPECTIVE)
if (camera.Projection == CameraProjection.Perspective)
{
// Create isometric view
cameraMode = CameraMode.CAMERA_THIRD_PERSON;
cameraMode = CameraMode.ThirdPerson;
// Note: The target distance is related to the render distance in the orthographic projection
camera.Position = new Vector3(0.0f, 2.0f, -100.0f);
camera.Target = new Vector3(0.0f, 2.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.Projection = CameraProjection.CAMERA_ORTHOGRAPHIC;
camera.Projection = CameraProjection.Orthographic;
camera.FovY = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC
// CameraYaw(&camera, -135 * DEG2RAD, true);
// CameraPitch(&camera, -45 * DEG2RAD, true, true, false);
}
else if (camera.Projection == CameraProjection.CAMERA_ORTHOGRAPHIC)
else if (camera.Projection == CameraProjection.Orthographic)
{
// Reset to default view
cameraMode = CameraMode.CAMERA_THIRD_PERSON;
cameraMode = CameraMode.ThirdPerson;
camera.Position = new Vector3(0.0f, 2.0f, 10.0f);
camera.Target = new Vector3(0.0f, 2.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
camera.FovY = 60.0f;
}
}
@ -113,64 +113,64 @@ public class Camera3dFirstPerson
// Update camera computes movement internally depending on the camera mode
// Some default standard keyboard/mouse inputs are hardcoded to simplify use
// For advance camera controls, it's reecommended to compute camera movement manually
UpdateCamera(ref camera, CameraMode.CAMERA_CUSTOM);
UpdateCamera(ref camera, CameraMode.Custom);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
// Draw ground
DrawPlane(new Vector3(0.0f, 0.0f, 0.0f), new Vector2(32.0f, 32.0f), Color.LIGHTGRAY);
DrawPlane(new Vector3(0.0f, 0.0f, 0.0f), new Vector2(32.0f, 32.0f), Color.LightGray);
// Draw a blue wall
DrawCube(new Vector3(-16.0f, 2.5f, 0.0f), 1.0f, 5.0f, 32.0f, Color.BLUE);
DrawCube(new Vector3(-16.0f, 2.5f, 0.0f), 1.0f, 5.0f, 32.0f, Color.Blue);
// Draw a green wall
DrawCube(new Vector3(16.0f, 2.5f, 0.0f), 1.0f, 5.0f, 32.0f, Color.LIME);
DrawCube(new Vector3(16.0f, 2.5f, 0.0f), 1.0f, 5.0f, 32.0f, Color.Lime);
// Draw a yellow wall
DrawCube(new Vector3(0.0f, 2.5f, 16.0f), 32.0f, 5.0f, 1.0f, Color.GOLD);
DrawCube(new Vector3(0.0f, 2.5f, 16.0f), 32.0f, 5.0f, 1.0f, Color.Gold);
// Draw some cubes around
for (int i = 0; i < MaxColumns; i++)
{
DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]);
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, Color.MAROON);
DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, Color.Maroon);
}
// Draw player cube
if (cameraMode == CameraMode.CAMERA_THIRD_PERSON)
if (cameraMode == CameraMode.ThirdPerson)
{
DrawCube(camera.Target, 0.5f, 0.5f, 0.5f, Color.PURPLE);
DrawCubeWires(camera.Target, 0.5f, 0.5f, 0.5f, Color.DARKPURPLE);
DrawCube(camera.Target, 0.5f, 0.5f, 0.5f, Color.Purple);
DrawCubeWires(camera.Target, 0.5f, 0.5f, 0.5f, Color.DarkPurple);
}
EndMode3D();
// Draw info boxes
DrawRectangle(5, 5, 330, 100, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(10, 10, 330, 100, Color.BLUE);
DrawRectangle(5, 5, 330, 100, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(10, 10, 330, 100, Color.Blue);
DrawText("Camera controls:", 15, 15, 10, Color.BLACK);
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, Color.BLACK);
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, Color.BLACK);
DrawText("- Camera mode keys: 1, 2, 3, 4", 15, 60, 10, Color.BLACK);
DrawText("- Zoom keys: num-plus, num-minus or mouse scroll", 15, 75, 10, Color.BLACK);
DrawText("- Camera projection key: P", 15, 90, 10, Color.BLACK);
DrawText("Camera controls:", 15, 15, 10, Color.Black);
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 10, Color.Black);
DrawText("- Look around: arrow keys or mouse", 15, 45, 10, Color.Black);
DrawText("- Camera mode keys: 1, 2, 3, 4", 15, 60, 10, Color.Black);
DrawText("- Zoom keys: num-plus, num-minus or mouse scroll", 15, 75, 10, Color.Black);
DrawText("- Camera projection key: P", 15, 90, 10, Color.Black);
DrawRectangle(600, 5, 195, 100, Fade(Color.SKYBLUE, 0.5f));
DrawRectangleLines(600, 5, 195, 100, Color.BLUE);
DrawRectangle(600, 5, 195, 100, Fade(Color.SkyBlue, 0.5f));
DrawRectangleLines(600, 5, 195, 100, Color.Blue);
DrawText("Camera status:", 610, 15, 10, Color.BLACK);
DrawText($"- Mode: {cameraMode}", 610, 30, 10, Color.BLACK);
DrawText($"- Projection: {camera.Projection}", 610, 45, 10, Color.BLACK);
DrawText($"- Position: {camera.Position}", 610, 60, 10, Color.BLACK);
DrawText($"- Target: {camera.Target}", 610, 75, 10, Color.BLACK);
DrawText($"- Up: {camera.Up}", 610, 90, 10, Color.BLACK);
DrawText("Camera status:", 610, 15, 10, Color.Black);
DrawText($"- Mode: {cameraMode}", 610, 30, 10, Color.Black);
DrawText($"- Projection: {camera.Projection}", 610, 45, 10, Color.Black);
DrawText($"- Position: {camera.Position}", 610, 60, 10, Color.Black);
DrawText($"- Target: {camera.Target}", 610, 75, 10, Color.Black);
DrawText($"- Up: {camera.Up}", 610, 90, 10, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class Camera3dFree
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 0.0f, 0.0f);
@ -43,9 +43,9 @@ public class Camera3dFree
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
if (IsKeyDown(KeyboardKey.KEY_Z))
if (IsKeyDown(KeyboardKey.Z))
{
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
}
@ -54,26 +54,26 @@ public class Camera3dFree
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.Red);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.Maroon);
DrawGrid(10, 1.0f);
EndMode3D();
DrawRectangle(10, 10, 320, 133, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(10, 10, 320, 133, Color.BLUE);
DrawRectangle(10, 10, 320, 133, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(10, 10, 320, 133, Color.Blue);
DrawText("Free camera default controls:", 20, 20, 10, Color.BLACK);
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, Color.DARKGRAY);
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, Color.DARKGRAY);
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, Color.DARKGRAY);
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, Color.DARKGRAY);
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, Color.DARKGRAY);
DrawText("Free camera default controls:", 20, 20, 10, Color.Black);
DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, Color.DarkGray);
DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, Color.DarkGray);
DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, Color.DarkGray);
DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, Color.DarkGray);
DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class Camera3dMode
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 0.0f, 0.0f);
@ -49,18 +49,18 @@ public class Camera3dMode
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.Red);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.Maroon);
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("Welcome to the third dimension!", 10, 40, 20, Color.DARKGRAY);
DrawText("Welcome to the third dimension!", 10, 40, 20, Color.DarkGray);
DrawFPS(10, 10);

View File

@ -68,9 +68,9 @@ public unsafe class CustomLogging
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, Color.LIGHTGRAY);
DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -45,30 +45,30 @@ public class DropFiles
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (files.Length == 0)
{
DrawText("Drop your files to this window!", 100, 40, 20, Color.DARKGRAY);
DrawText("Drop your files to this window!", 100, 40, 20, Color.DarkGray);
}
else
{
DrawText("Dropped files:", 100, 40, 20, Color.DARKGRAY);
DrawText("Dropped files:", 100, 40, 20, Color.DarkGray);
for (int i = 0; i < files.Length; i++)
{
if (i % 2 == 0)
{
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, ColorAlpha(Color.LIGHTGRAY, 0.5f));
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, ColorAlpha(Color.LightGray, 0.5f));
}
else
{
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, ColorAlpha(Color.LIGHTGRAY, 0.3f));
DrawRectangle(0, 85 + 40 * i, screenWidth, 40, ColorAlpha(Color.LightGray, 0.3f));
}
DrawText(files[i], 120, 100 + 40 * i, 10, Color.GRAY);
DrawText(files[i], 120, 100 + 40 * i, 10, Color.Gray);
}
DrawText("Drop new files...", 100, 110 + 40 * files.Length, 20, Color.DARKGRAY);
DrawText("Drop new files...", 100, 110 + 40 * files.Length, 20, Color.DarkGray);
}
EndDrawing();

View File

@ -38,7 +38,7 @@ public class InputGamepad
const int screenHeight = 450;
// Set MSAA 4X hint before windows creation
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
Texture2D texPs3Pad = LoadTexture("resources/ps3.png");
@ -58,232 +58,232 @@ public class InputGamepad
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (IsGamepadAvailable(0))
{
string gamepadName = GetGamepadName_(0);
DrawText($"GP1: {gamepadName}", 10, 10, 10, Color.BLACK);
DrawText($"GP1: {gamepadName}", 10, 10, 10, Color.Black);
if (gamepadName == XBOX360_LEGACY_NAME_ID ||
gamepadName == XBOX360_NAME_ID ||
gamepadName == XBOX360_NAME_ID_RPI)
{
DrawTexture(texXboxPad, 0, 0, Color.DARKGRAY);
DrawTexture(texXboxPad, 0, 0, Color.DarkGray);
// Draw buttons: xbox home
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE))
if (IsGamepadButtonDown(0, GamepadButton.Middle))
{
DrawCircle(394, 89, 19, Color.RED);
DrawCircle(394, 89, 19, Color.Red);
}
// Draw buttons: basic
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.MiddleRight))
{
DrawCircle(436, 150, 9, Color.RED);
DrawCircle(436, 150, 9, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.MiddleLeft))
{
DrawCircle(352, 150, 9, Color.RED);
DrawCircle(352, 150, 9, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceLeft))
{
DrawCircle(501, 151, 15, Color.BLUE);
DrawCircle(501, 151, 15, Color.Blue);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_DOWN))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceDown))
{
DrawCircle(536, 187, 15, Color.LIME);
DrawCircle(536, 187, 15, Color.Lime);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceRight))
{
DrawCircle(572, 151, 15, Color.MAROON);
DrawCircle(572, 151, 15, Color.Maroon);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_UP))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceUp))
{
DrawCircle(536, 115, 15, Color.GOLD);
DrawCircle(536, 115, 15, Color.Gold);
}
// Draw buttons: d-pad
DrawRectangle(317, 202, 19, 71, Color.BLACK);
DrawRectangle(293, 228, 69, 19, Color.BLACK);
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_UP))
DrawRectangle(317, 202, 19, 71, Color.Black);
DrawRectangle(293, 228, 69, 19, Color.Black);
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceUp))
{
DrawRectangle(317, 202, 19, 26, Color.RED);
DrawRectangle(317, 202, 19, 26, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_DOWN))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceDown))
{
DrawRectangle(317, 202 + 45, 19, 26, Color.RED);
DrawRectangle(317, 202 + 45, 19, 26, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceLeft))
{
DrawRectangle(292, 228, 25, 19, Color.RED);
DrawRectangle(292, 228, 25, 19, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceRight))
{
DrawRectangle(292 + 44, 228, 26, 19, Color.RED);
DrawRectangle(292 + 44, 228, 26, 19, Color.Red);
}
// Draw buttons: left-right back
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_TRIGGER_1))
if (IsGamepadButtonDown(0, GamepadButton.LeftTrigger1))
{
DrawCircle(259, 61, 20, Color.RED);
DrawCircle(259, 61, 20, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_TRIGGER_1))
if (IsGamepadButtonDown(0, GamepadButton.RightTrigger1))
{
DrawCircle(536, 61, 20, Color.RED);
DrawCircle(536, 61, 20, Color.Red);
}
// Draw axis: left joystick
DrawCircle(259, 152, 39, Color.BLACK);
DrawCircle(259, 152, 34, Color.LIGHTGRAY);
DrawCircle(259, 152, 39, Color.Black);
DrawCircle(259, 152, 34, Color.LightGray);
DrawCircle(
259 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_X) * 20),
152 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_Y) * 20),
259 + (int)(GetGamepadAxisMovement(0, GamepadAxis.LeftX) * 20),
152 + (int)(GetGamepadAxisMovement(0, GamepadAxis.LeftY) * 20),
25,
Color.BLACK
Color.Black
);
// Draw axis: right joystick
DrawCircle(461, 237, 38, Color.BLACK);
DrawCircle(461, 237, 33, Color.LIGHTGRAY);
DrawCircle(461, 237, 38, Color.Black);
DrawCircle(461, 237, 33, Color.LightGray);
DrawCircle(
461 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_X) * 20),
237 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_Y) * 20),
25, Color.BLACK
461 + (int)(GetGamepadAxisMovement(0, GamepadAxis.RightX) * 20),
237 + (int)(GetGamepadAxisMovement(0, GamepadAxis.RightY) * 20),
25, Color.Black
);
// Draw axis: left-right triggers
float leftTriggerX = GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_TRIGGER);
float rightTriggerX = GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_TRIGGER);
DrawRectangle(170, 30, 15, 70, Color.GRAY);
DrawRectangle(604, 30, 15, 70, Color.GRAY);
DrawRectangle(170, 30, 15, (int)(((1.0f + leftTriggerX) / 2.0f) * 70), Color.RED);
DrawRectangle(604, 30, 15, (int)(((1.0f + rightTriggerX) / 2.0f) * 70), Color.RED);
float leftTriggerX = GetGamepadAxisMovement(0, GamepadAxis.LeftTrigger);
float rightTriggerX = GetGamepadAxisMovement(0, GamepadAxis.RightTrigger);
DrawRectangle(170, 30, 15, 70, Color.Gray);
DrawRectangle(604, 30, 15, 70, Color.Gray);
DrawRectangle(170, 30, 15, (int)(((1.0f + leftTriggerX) / 2.0f) * 70), Color.Red);
DrawRectangle(604, 30, 15, (int)(((1.0f + rightTriggerX) / 2.0f) * 70), Color.Red);
}
else if (gamepadName == PS3_NAME_ID)
{
DrawTexture(texPs3Pad, 0, 0, Color.DARKGRAY);
DrawTexture(texPs3Pad, 0, 0, Color.DarkGray);
// Draw buttons: ps
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE))
if (IsGamepadButtonDown(0, GamepadButton.Middle))
{
DrawCircle(396, 222, 13, Color.RED);
DrawCircle(396, 222, 13, Color.Red);
}
// Draw buttons: basic
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.MiddleLeft))
{
DrawRectangle(328, 170, 32, 13, Color.RED);
DrawRectangle(328, 170, 32, 13, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_MIDDLE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.MiddleRight))
{
DrawTriangle(
new Vector2(436, 168),
new Vector2(436, 185),
new Vector2(464, 177),
Color.RED
Color.Red
);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_UP))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceUp))
{
DrawCircle(557, 144, 13, Color.LIME);
DrawCircle(557, 144, 13, Color.Lime);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceRight))
{
DrawCircle(586, 173, 13, Color.RED);
DrawCircle(586, 173, 13, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_DOWN))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceDown))
{
DrawCircle(557, 203, 13, Color.VIOLET);
DrawCircle(557, 203, 13, Color.Violet);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_FACE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.RightFaceLeft))
{
DrawCircle(527, 173, 13, Color.PINK);
DrawCircle(527, 173, 13, Color.Pink);
}
// Draw buttons: d-pad
DrawRectangle(225, 132, 24, 84, Color.BLACK);
DrawRectangle(195, 161, 84, 25, Color.BLACK);
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_UP))
DrawRectangle(225, 132, 24, 84, Color.Black);
DrawRectangle(195, 161, 84, 25, Color.Black);
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceUp))
{
DrawRectangle(225, 132, 24, 29, Color.RED);
DrawRectangle(225, 132, 24, 29, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_DOWN))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceDown))
{
DrawRectangle(225, 132 + 54, 24, 30, Color.RED);
DrawRectangle(225, 132 + 54, 24, 30, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_LEFT))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceLeft))
{
DrawRectangle(195, 161, 30, 25, Color.RED);
DrawRectangle(195, 161, 30, 25, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_FACE_RIGHT))
if (IsGamepadButtonDown(0, GamepadButton.LeftFaceRight))
{
DrawRectangle(195 + 54, 161, 30, 25, Color.RED);
DrawRectangle(195 + 54, 161, 30, 25, Color.Red);
}
// Draw buttons: left-right back buttons
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_LEFT_TRIGGER_1))
if (IsGamepadButtonDown(0, GamepadButton.LeftTrigger1))
{
DrawCircle(239, 82, 20, Color.RED);
DrawCircle(239, 82, 20, Color.Red);
}
if (IsGamepadButtonDown(0, GamepadButton.GAMEPAD_BUTTON_RIGHT_TRIGGER_1))
if (IsGamepadButtonDown(0, GamepadButton.RightTrigger1))
{
DrawCircle(557, 82, 20, Color.RED);
DrawCircle(557, 82, 20, Color.Red);
}
// Draw axis: left joystick
DrawCircle(319, 255, 35, Color.BLACK);
DrawCircle(319, 255, 31, Color.LIGHTGRAY);
DrawCircle(319, 255, 35, Color.Black);
DrawCircle(319, 255, 31, Color.LightGray);
DrawCircle(
319 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_X) * 20),
255 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_Y) * 20),
319 + (int)(GetGamepadAxisMovement(0, GamepadAxis.LeftX) * 20),
255 + (int)(GetGamepadAxisMovement(0, GamepadAxis.LeftY) * 20),
25,
Color.BLACK
Color.Black
);
// Draw axis: right joystick
DrawCircle(475, 255, 35, Color.BLACK);
DrawCircle(475, 255, 31, Color.LIGHTGRAY);
DrawCircle(475, 255, 35, Color.Black);
DrawCircle(475, 255, 31, Color.LightGray);
DrawCircle(
475 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_X) * 20),
255 + (int)(GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_Y) * 20),
475 + (int)(GetGamepadAxisMovement(0, GamepadAxis.RightX) * 20),
255 + (int)(GetGamepadAxisMovement(0, GamepadAxis.RightY) * 20),
25,
Color.BLACK
Color.Black
);
// Draw axis: left-right triggers
float leftTriggerX = GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_LEFT_TRIGGER);
float rightTriggerX = GetGamepadAxisMovement(0, GamepadAxis.GAMEPAD_AXIS_RIGHT_TRIGGER);
DrawRectangle(169, 48, 15, 70, Color.GRAY);
DrawRectangle(611, 48, 15, 70, Color.GRAY);
DrawRectangle(169, 48, 15, (int)(((1.0f - leftTriggerX) / 2.0f) * 70), Color.RED);
DrawRectangle(611, 48, 15, (int)(((1.0f - rightTriggerX) / 2.0f) * 70), Color.RED);
float leftTriggerX = GetGamepadAxisMovement(0, GamepadAxis.LeftTrigger);
float rightTriggerX = GetGamepadAxisMovement(0, GamepadAxis.RightTrigger);
DrawRectangle(169, 48, 15, 70, Color.Gray);
DrawRectangle(611, 48, 15, 70, Color.Gray);
DrawRectangle(169, 48, 15, (int)(((1.0f - leftTriggerX) / 2.0f) * 70), Color.Red);
DrawRectangle(611, 48, 15, (int)(((1.0f - rightTriggerX) / 2.0f) * 70), Color.Red);
}
else
{
DrawText("- GENERIC GAMEPAD -", 280, 180, 20, Color.GRAY);
DrawText("- GENERIC GAMEPAD -", 280, 180, 20, Color.Gray);
// TODO: Draw generic gamepad
}
DrawText($"DETECTED AXIS [{GetGamepadAxisCount(0)}]:", 10, 50, 10, Color.MAROON);
DrawText($"DETECTED AXIS [{GetGamepadAxisCount(0)}]:", 10, 50, 10, Color.Maroon);
for (int i = 0; i < GetGamepadAxisCount(0); i++)
{
@ -292,23 +292,23 @@ public class InputGamepad
20,
70 + 20 * i,
10,
Color.DARKGRAY
Color.DarkGray
);
}
if (GetGamepadButtonPressed() != (int)GamepadButton.GAMEPAD_BUTTON_UNKNOWN)
if (GetGamepadButtonPressed() != (int)GamepadButton.Unknown)
{
DrawText($"DETECTED BUTTON: {GetGamepadButtonPressed()}", 10, 430, 10, Color.RED);
DrawText($"DETECTED BUTTON: {GetGamepadButtonPressed()}", 10, 430, 10, Color.Red);
}
else
{
DrawText("DETECTED BUTTON: NONE", 10, 430, 10, Color.GRAY);
DrawText("DETECTED BUTTON: NONE", 10, 430, 10, Color.Gray);
}
}
else
{
DrawText("GP1: NOT DETECTED", 10, 10, 10, Color.GRAY);
DrawTexture(texXboxPad, 0, 0, Color.LIGHTGRAY);
DrawText("GP1: NOT DETECTED", 10, 10, 10, Color.Gray);
DrawTexture(texXboxPad, 0, 0, Color.LightGray);
}
EndDrawing();

View File

@ -33,8 +33,8 @@ public class InputGestures
int gesturesCount = 0;
string[] gestureStrings = new string[MaxGestureStrings];
Gesture currentGesture = Gesture.GESTURE_NONE;
Gesture lastGesture = Gesture.GESTURE_NONE;
Gesture currentGesture = Gesture.None;
Gesture lastGesture = Gesture.None;
// SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected
@ -50,41 +50,41 @@ public class InputGestures
currentGesture = GetGestureDetected();
touchPosition = GetTouchPosition(0);
if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != Gesture.GESTURE_NONE))
if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != Gesture.None))
{
if (currentGesture != lastGesture)
{
// Store gesture string
switch ((Gesture)currentGesture)
{
case Gesture.GESTURE_TAP:
case Gesture.Tap:
gestureStrings[gesturesCount] = "GESTURE TAP";
break;
case Gesture.GESTURE_DOUBLETAP:
case Gesture.DoubleTap:
gestureStrings[gesturesCount] = "GESTURE DOUBLETAP";
break;
case Gesture.GESTURE_HOLD:
case Gesture.Hold:
gestureStrings[gesturesCount] = "GESTURE HOLD";
break;
case Gesture.GESTURE_DRAG:
case Gesture.Drag:
gestureStrings[gesturesCount] = "GESTURE DRAG";
break;
case Gesture.GESTURE_SWIPE_RIGHT:
case Gesture.SwipeRight:
gestureStrings[gesturesCount] = "GESTURE SWIPE RIGHT";
break;
case Gesture.GESTURE_SWIPE_LEFT:
case Gesture.SwipeLeft:
gestureStrings[gesturesCount] = "GESTURE SWIPE LEFT";
break;
case Gesture.GESTURE_SWIPE_UP:
case Gesture.SwipeUp:
gestureStrings[gesturesCount] = "GESTURE SWIPE UP";
break;
case Gesture.GESTURE_SWIPE_DOWN:
case Gesture.SwipeDown:
gestureStrings[gesturesCount] = "GESTURE SWIPE DOWN";
break;
case Gesture.GESTURE_PINCH_IN:
case Gesture.PinchIn:
gestureStrings[gesturesCount] = "GESTURE PINCH IN";
break;
case Gesture.GESTURE_PINCH_OUT:
case Gesture.PinchOut:
gestureStrings[gesturesCount] = "GESTURE PINCH OUT";
break;
default:
@ -109,40 +109,40 @@ public class InputGestures
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawRectangleRec(touchArea, Color.GRAY);
DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, Color.RAYWHITE);
DrawRectangleRec(touchArea, Color.Gray);
DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, Color.RayWhite);
DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, ColorAlpha(Color.GRAY, 0.5f));
DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, ColorAlpha(Color.Gray, 0.5f));
for (int i = 0; i < gesturesCount; i++)
{
if (i % 2 == 0)
{
DrawRectangle(10, 30 + 20 * i, 200, 20, ColorAlpha(Color.LIGHTGRAY, 0.5f));
DrawRectangle(10, 30 + 20 * i, 200, 20, ColorAlpha(Color.LightGray, 0.5f));
}
else
{
DrawRectangle(10, 30 + 20 * i, 200, 20, ColorAlpha(Color.LIGHTGRAY, 0.3f));
DrawRectangle(10, 30 + 20 * i, 200, 20, ColorAlpha(Color.LightGray, 0.3f));
}
if (i < gesturesCount - 1)
{
DrawText(gestureStrings[i], 35, 36 + 20 * i, 10, Color.DARKGRAY);
DrawText(gestureStrings[i], 35, 36 + 20 * i, 10, Color.DarkGray);
}
else
{
DrawText(gestureStrings[i], 35, 36 + 20 * i, 10, Color.MAROON);
DrawText(gestureStrings[i], 35, 36 + 20 * i, 10, Color.Maroon);
}
}
DrawRectangleLines(10, 29, 200, screenHeight - 50, Color.GRAY);
DrawText("DETECTED GESTURES", 50, 15, 10, Color.GRAY);
DrawRectangleLines(10, 29, 200, screenHeight - 50, Color.Gray);
DrawText("DETECTED GESTURES", 50, 15, 10, Color.Gray);
if (currentGesture != Gesture.GESTURE_NONE)
if (currentGesture != Gesture.None)
{
DrawCircleV(touchPosition, 30, Color.MAROON);
DrawCircleV(touchPosition, 30, Color.Maroon);
}
EndDrawing();

View File

@ -35,22 +35,22 @@ public class InputKeys
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
ballPosition.X += 2.0f;
}
if (IsKeyDown(KeyboardKey.KEY_LEFT))
if (IsKeyDown(KeyboardKey.Left))
{
ballPosition.X -= 2.0f;
}
if (IsKeyDown(KeyboardKey.KEY_UP))
if (IsKeyDown(KeyboardKey.Up))
{
ballPosition.Y -= 2.0f;
}
if (IsKeyDown(KeyboardKey.KEY_DOWN))
if (IsKeyDown(KeyboardKey.Down))
{
ballPosition.Y += 2.0f;
}
@ -59,11 +59,11 @@ public class InputKeys
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("move the ball with arrow keys", 10, 10, 20, Color.DARKGRAY);
DrawText("move the ball with arrow keys", 10, 10, 20, Color.DarkGray);
DrawCircleV(ballPosition, 50, Color.MAROON);
DrawCircleV(ballPosition, 50, Color.Maroon);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -26,7 +26,7 @@ public class InputMouse
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
Vector2 ballPosition = new(-100.0f, -100.0f);
Color ballColor = Color.DARKBLUE;
Color ballColor = Color.DarkBlue;
SetTargetFPS(60);
//---------------------------------------------------------------------------------------
@ -38,28 +38,28 @@ public class InputMouse
//----------------------------------------------------------------------------------
ballPosition = GetMousePosition();
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
ballColor = Color.MAROON;
ballColor = Color.Maroon;
}
else if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON))
else if (IsMouseButtonPressed(MouseButton.Middle))
{
ballColor = Color.LIME;
ballColor = Color.Lime;
}
else if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON))
else if (IsMouseButtonPressed(MouseButton.Right))
{
ballColor = Color.DARKBLUE;
ballColor = Color.DarkBlue;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawCircleV(ballPosition, 40, ballColor);
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, Color.DARKGRAY);
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -43,12 +43,12 @@ public class InputMouseWheel
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawRectangle(screenWidth / 2 - 40, boxPositionY, 80, 80, Color.MAROON);
DrawRectangle(screenWidth / 2 - 40, boxPositionY, 80, 80, Color.Maroon);
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, Color.GRAY);
DrawText($"Box position Y: {boxPositionY}", 10, 40, 20, Color.LIGHTGRAY);
DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, Color.Gray);
DrawText($"Box position Y: {boxPositionY}", 10, 40, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -57,7 +57,7 @@ public class InputMultitouch
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
for (int i = 0; i < tCount; i++)
{
@ -65,17 +65,17 @@ public class InputMultitouch
if ((touchPositions[i].X > 0) && (touchPositions[i].Y > 0))
{
// Draw circle and touch index number
DrawCircleV(touchPositions[i], 34, Color.ORANGE);
DrawCircleV(touchPositions[i], 34, Color.Orange);
DrawText(i.ToString(),
(int)touchPositions[i].X - 10,
(int)touchPositions[i].Y - 70,
40,
Color.BLACK
Color.Black
);
}
}
DrawText("touch the screen at multiple locations to get multiple balls", 10, 10, 20, Color.DARKGRAY);
DrawText("touch the screen at multiple locations to get multiple balls", 10, 10, 20, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class Picking3d
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 1.0f, 0.0f);
Vector3 cubeSize = new(2.0f, 2.0f, 2.0f);
@ -48,9 +48,9 @@ public class Picking3d
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
if (!collision.Hit)
{
@ -75,34 +75,34 @@ public class Picking3d
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
if (collision.Hit)
{
DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.RED);
DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.MAROON);
DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.Red);
DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.Maroon);
DrawCubeWires(cubePosition, cubeSize.X + 0.2f, cubeSize.Y + 0.2f, cubeSize.Z + 0.2f, Color.GREEN);
DrawCubeWires(cubePosition, cubeSize.X + 0.2f, cubeSize.Y + 0.2f, cubeSize.Z + 0.2f, Color.Green);
}
else
{
DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.GRAY);
DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.DARKGRAY);
DrawCube(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.Gray);
DrawCubeWires(cubePosition, cubeSize.X, cubeSize.Y, cubeSize.Z, Color.DarkGray);
}
DrawRay(ray, Color.MAROON);
DrawRay(ray, Color.Maroon);
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("Try selecting the box with mouse!", 240, 10, 20, Color.DARKGRAY);
DrawText("Try selecting the box with mouse!", 240, 10, 20, Color.DarkGray);
if (collision.Hit)
{
int posX = (screenWidth - MeasureText("BOX SELECTED", 30)) / 2;
DrawText("BOX SELECTED", posX, (int)(screenHeight * 0.1f), 30, Color.GREEN);
DrawText("BOX SELECTED", posX, (int)(screenHeight * 0.1f), 30, Color.Green);
}
DrawFPS(10, 10);

View File

@ -51,11 +51,11 @@ public class RandomValues
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, Color.MAROON);
DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, Color.Maroon);
DrawText($"{randValue}", 360, 180, 80, Color.LIGHTGRAY);
DrawText($"{randValue}", 360, 180, 80, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -37,7 +37,7 @@ public class ScissorTest
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_S))
if (IsKeyPressed(KeyboardKey.S))
{
scissorMode = !scissorMode;
}
@ -50,7 +50,7 @@ public class ScissorTest
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (scissorMode)
{
@ -59,16 +59,16 @@ public class ScissorTest
// Draw full screen rectangle and some text
// NOTE: Only part defined by scissor area will be rendered
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.RED);
DrawText("Move the mouse around to reveal this text!", 190, 200, 20, Color.LIGHTGRAY);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.Red);
DrawText("Move the mouse around to reveal this text!", 190, 200, 20, Color.LightGray);
if (scissorMode)
{
EndScissorMode();
}
DrawRectangleLinesEx(scissorArea, 1, Color.BLACK);
DrawText("Press S to toggle scissor test", 10, 10, 20, Color.BLACK);
DrawRectangleLinesEx(scissorArea, 1, Color.Black);
DrawText("Press S to toggle scissor test", 10, 10, 20, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -100,25 +100,25 @@ public static class SmoothPixelPerfect
// Draw
//----------------------------------------------------------------------------------
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode2D(worldSpaceCamera);
DrawRectanglePro(rec01, origin, rotation, Color.BLACK);
DrawRectanglePro(rec02, origin, -rotation, Color.RED);
DrawRectanglePro(rec03, origin, rotation + 45.0f, Color.BLUE);
DrawRectanglePro(rec01, origin, rotation, Color.Black);
DrawRectanglePro(rec02, origin, -rotation, Color.Red);
DrawRectanglePro(rec03, origin, rotation + 45.0f, Color.Blue);
EndMode2D();
EndTextureMode();
BeginDrawing();
ClearBackground(Color.RED);
ClearBackground(Color.Red);
BeginMode2D(screenSpaceCamera);
DrawTexturePro(target.Texture, sourceRec, destRec, origin, 0.0f, Color.WHITE);
DrawTexturePro(target.Texture, sourceRec, destRec, origin, 0.0f, Color.White);
EndMode2D();
DrawText($"Screen resolution: {screenWidth}x{screenHeight}", 10, 10, 20, Color.DARKBLUE);
DrawText($"World resolution: {virtualScreenWidth}x{virtualScreenHeight}", 10, 40, 20, Color.DARKGREEN);
DrawText($"Screen resolution: {screenWidth}x{screenHeight}", 10, 10, 20, Color.DarkBlue);
DrawText($"World resolution: {virtualScreenWidth}x{virtualScreenHeight}", 10, 40, 20, Color.DarkGreen);
DrawFPS(GetScreenWidth() - 95, 10);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -30,20 +30,20 @@ public unsafe class SplitScreen
// Grid of cube trees on a plane to make a "world"
// Simple world plane
DrawPlane(new Vector3(0, 0, 0), new Vector2(50, 50), Color.BEIGE);
DrawPlane(new Vector3(0, 0, 0), new Vector2(50, 50), Color.Beige);
for (float x = -count * spacing; x <= count * spacing; x += spacing)
{
for (float z = -count * spacing; z <= count * spacing; z += spacing)
{
DrawCube(new Vector3(x, 1.5f, z), 1, 1, 1, Color.LIME);
DrawCube(new Vector3(x, 0.5f, z), 0.25f, 1, 0.25f, Color.BROWN);
DrawCube(new Vector3(x, 1.5f, z), 1, 1, 1, Color.Lime);
DrawCube(new Vector3(x, 0.5f, z), 0.25f, 1, 0.25f, Color.Brown);
}
}
// Draw a cube at each player's position
DrawCube(CameraPlayer1.Position, 1, 1, 1, Color.RED);
DrawCube(CameraPlayer2.Position, 1, 1, 1, Color.BLUE);
DrawCube(CameraPlayer1.Position, 1, 1, 1, Color.Red);
DrawCube(CameraPlayer2.Position, 1, 1, 1, Color.Blue);
}
public static int Main()
@ -56,11 +56,11 @@ public unsafe class SplitScreen
InitWindow(screenWidth, screenHeight, "raylib [core] example - split screen");
// Generate a simple texture to use for trees
Image img = GenImageChecked(256, 256, 32, 32, Color.DARKGRAY, Color.WHITE);
Image img = GenImageChecked(256, 256, 32, 32, Color.DarkGray, Color.White);
TextureGrid = LoadTextureFromImage(img);
UnloadImage(img);
SetTextureFilter(TextureGrid, TextureFilter.TEXTURE_FILTER_ANISOTROPIC_16X);
SetTextureWrap(TextureGrid, TextureWrap.TEXTURE_WRAP_CLAMP);
SetTextureFilter(TextureGrid, TextureFilter.Anisotropic16X);
SetTextureWrap(TextureGrid, TextureWrap.Clamp);
// Setup player 1 camera and screen
CameraPlayer1.FovY = 45.0f;
@ -101,24 +101,24 @@ public unsafe class SplitScreen
float offsetThisFrame = 10.0f * GetFrameTime();
// Move Player1 forward and backwards (no turning)
if (IsKeyDown(KeyboardKey.KEY_W))
if (IsKeyDown(KeyboardKey.W))
{
CameraPlayer1.Position.Z += offsetThisFrame;
CameraPlayer1.Target.Z += offsetThisFrame;
}
else if (IsKeyDown(KeyboardKey.KEY_S))
else if (IsKeyDown(KeyboardKey.S))
{
CameraPlayer1.Position.Z -= offsetThisFrame;
CameraPlayer1.Target.Z -= offsetThisFrame;
}
// Move Player2 forward and backwards (no turning)
if (IsKeyDown(KeyboardKey.KEY_UP))
if (IsKeyDown(KeyboardKey.Up))
{
CameraPlayer2.Position.X += offsetThisFrame;
CameraPlayer2.Target.X += offsetThisFrame;
}
else if (IsKeyDown(KeyboardKey.KEY_DOWN))
else if (IsKeyDown(KeyboardKey.Down))
{
CameraPlayer2.Position.X -= offsetThisFrame;
CameraPlayer2.Target.X -= offsetThisFrame;
@ -129,32 +129,32 @@ public unsafe class SplitScreen
//----------------------------------------------------------------------------------
// Draw Player1 view to the render texture
BeginTextureMode(screenPlayer1);
ClearBackground(Color.SKYBLUE);
ClearBackground(Color.SkyBlue);
BeginMode3D(CameraPlayer1);
DrawScene();
EndMode3D();
DrawText("PLAYER 1 W/S to move", 10, 10, 20, Color.RED);
DrawText("PLAYER 1 W/S to move", 10, 10, 20, Color.Red);
EndTextureMode();
// Draw Player2 view to the render texture
BeginTextureMode(screenPlayer2);
ClearBackground(Color.SKYBLUE);
ClearBackground(Color.SkyBlue);
BeginMode3D(CameraPlayer2);
DrawScene();
EndMode3D();
DrawText("PLAYER 2 UP/DOWN to move", 10, 10, 20, Color.BLUE);
DrawText("PLAYER 2 UP/DOWN to move", 10, 10, 20, Color.Blue);
EndTextureMode();
// Draw both views render textures to the screen side by side
BeginDrawing();
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
DrawTextureRec(screenPlayer1.Texture, splitScreenRect, new Vector2(0, 0), Color.WHITE);
DrawTextureRec(screenPlayer2.Texture, splitScreenRect, new Vector2(screenWidth / 2.0f, 0), Color.WHITE);
DrawTextureRec(screenPlayer1.Texture, splitScreenRect, new Vector2(0, 0), Color.White);
DrawTextureRec(screenPlayer2.Texture, splitScreenRect, new Vector2(screenWidth / 2.0f, 0), Color.White);
EndDrawing();
}

View File

@ -44,18 +44,18 @@ public class StorageValues
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
score = GetRandomValue(1000, 2000);
hiscore = GetRandomValue(2000, 4000);
}
if (IsKeyPressed(KeyboardKey.KEY_ENTER))
if (IsKeyPressed(KeyboardKey.Enter))
{
SaveStorageValue(storageDataFile, (int)StorageData.Score, score);
SaveStorageValue(storageDataFile, (int)StorageData.HiScore, hiscore);
}
else if (IsKeyPressed(KeyboardKey.KEY_SPACE))
else if (IsKeyPressed(KeyboardKey.Space))
{
// NOTE: If requested position could not be found, value 0 is returned
score = LoadStorageValue(storageDataFile, (int)StorageData.Score);
@ -68,16 +68,16 @@ public class StorageValues
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText($"SCORE: {score}", 280, 130, 40, Color.MAROON);
DrawText($"HI-SCORE: {hiscore}", 210, 200, 50, Color.BLACK);
DrawText($"SCORE: {score}", 280, 130, 40, Color.Maroon);
DrawText($"HI-SCORE: {hiscore}", 210, 200, 50, Color.Black);
DrawText($"frames: {framesCounter}", 10, 10, 20, Color.LIME);
DrawText($"frames: {framesCounter}", 10, 10, 20, Color.Lime);
DrawText("Press R to generate random numbers", 220, 40, 20, Color.LIGHTGRAY);
DrawText("Press ENTER to SAVE values", 250, 310, 20, Color.LIGHTGRAY);
DrawText("Press SPACE to LOAD values", 252, 350, 20, Color.LIGHTGRAY);
DrawText("Press R to generate random numbers", 220, 40, 20, Color.LightGray);
DrawText("Press ENTER to SAVE values", 250, 310, 20, Color.LightGray);
DrawText("Press SPACE to LOAD values", 252, 350, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------
@ -123,7 +123,7 @@ public class StorageValues
// RL_REALLOC failed
uint positionInBytes = position * sizeof(int);
TraceLog(
TraceLogLevel.LOG_WARNING,
TraceLogLevel.Warning,
@$"FILEIO: [{fileName}] Failed to realloc data ({dataSize}),
position in bytes({positionInBytes}) bigger than actual file size"
);
@ -147,11 +147,11 @@ public class StorageValues
success = SaveFileData(fileNameBuffer.AsPointer(), newFileData, newDataSize);
MemFree(newFileData);
TraceLog(TraceLogLevel.LOG_INFO, $"FILEIO: [{fileName}] Saved storage value: {value}");
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] Saved storage value: {value}");
}
else
{
TraceLog(TraceLogLevel.LOG_INFO, $"FILEIO: [{fileName}] File created successfully");
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] File created successfully");
dataSize = (position + 1) * sizeof(int);
fileData = (byte*)MemAlloc((int)dataSize);
@ -161,7 +161,7 @@ public class StorageValues
success = SaveFileData(fileNameBuffer.AsPointer(), fileData, dataSize);
UnloadFileData(fileData);
TraceLog(TraceLogLevel.LOG_INFO, $"FILEIO: [{fileName}] Saved storage value: {value}");
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] Saved storage value: {value}");
}
return success;
@ -182,7 +182,7 @@ public class StorageValues
if (dataSize < (position * 4))
{
TraceLog(
TraceLogLevel.LOG_WARNING,
TraceLogLevel.Warning,
$"FILEIO: [{fileName}] Failed to find storage position: {value}"
);
}
@ -194,7 +194,7 @@ public class StorageValues
UnloadFileData(fileData);
TraceLog(TraceLogLevel.LOG_INFO, $"FILEIO: [{fileName}] Loaded storage value: {value}");
TraceLog(TraceLogLevel.Info, $"FILEIO: [{fileName}] Loaded storage value: {value}");
}
return value;

View File

@ -24,7 +24,7 @@ public class VrSimulator
const int screenWidth = 1080;
const int screenHeight = 600;
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
// VR device parameters definition
@ -67,38 +67,38 @@ public class VrSimulator
distortion,
GetShaderLocation(distortion, "leftLensCenter"),
config.LeftLensCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "rightLensCenter"),
config.RightLensCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "leftScreenCenter"),
config.LeftScreenCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "rightScreenCenter"),
config.RightScreenCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "scale"),
config.Scale,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
distortion,
GetShaderLocation(distortion, "scaleIn"),
config.ScaleIn,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
unsafe
@ -107,13 +107,13 @@ public class VrSimulator
distortion,
GetShaderLocation(distortion, "deviceWarpParam"),
device.LensDistortionValues,
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
SetShaderValue(
distortion,
GetShaderLocation(distortion, "chromaAbParam"),
device.ChromaAbCorrection,
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
}
@ -127,7 +127,7 @@ public class VrSimulator
camera.Target = new Vector3(0.0f, 2.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 60.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 0.0f, 0.0f);
@ -139,22 +139,22 @@ public class VrSimulator
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FIRST_PERSON);
UpdateCamera(ref camera, CameraMode.FirstPerson);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginVrStereoMode(config);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.Red);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.Maroon);
DrawGrid(40, 1.0f);
EndMode3D();
@ -166,7 +166,7 @@ public class VrSimulator
target.Texture,
new Rectangle(0, 0, (float)target.Texture.Width, (float)-target.Texture.Height),
new Vector2(0.0f, 0.0f),
Color.WHITE
Color.White
);
EndShaderMode();

View File

@ -42,7 +42,7 @@ public class WindowFlags
*/
// Set configuration flags for window creation
SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT);
SetConfigFlags(VSyncHint | Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [core] example - window flags");
Vector2 ballPosition = new(GetScreenWidth() / 2, GetScreenHeight() / 2);
@ -57,59 +57,59 @@ public class WindowFlags
{
// Update
//-----------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_F))
if (IsKeyPressed(KeyboardKey.F))
{
// modifies window size when scaling!
ToggleFullscreen();
}
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
if (IsWindowState(FLAG_WINDOW_RESIZABLE))
if (IsWindowState(ResizableWindow))
{
ClearWindowState(FLAG_WINDOW_RESIZABLE);
ClearWindowState(ResizableWindow);
}
else
{
SetWindowState(FLAG_WINDOW_RESIZABLE);
SetWindowState(ResizableWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_D))
if (IsKeyPressed(KeyboardKey.D))
{
if (IsWindowState(FLAG_WINDOW_UNDECORATED))
if (IsWindowState(UndecoratedWindow))
{
ClearWindowState(FLAG_WINDOW_UNDECORATED);
ClearWindowState(UndecoratedWindow);
}
else
{
SetWindowState(FLAG_WINDOW_UNDECORATED);
SetWindowState(UndecoratedWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_H))
if (IsKeyPressed(KeyboardKey.H))
{
if (!IsWindowState(FLAG_WINDOW_HIDDEN))
if (!IsWindowState(HiddenWindow))
{
SetWindowState(FLAG_WINDOW_HIDDEN);
SetWindowState(HiddenWindow);
}
framesCounter = 0;
}
if (IsWindowState(FLAG_WINDOW_HIDDEN))
if (IsWindowState(HiddenWindow))
{
framesCounter++;
if (framesCounter >= 240)
{
// Show window after 3 seconds
ClearWindowState(FLAG_WINDOW_HIDDEN);
ClearWindowState(HiddenWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_N))
if (IsKeyPressed(KeyboardKey.N))
{
if (!IsWindowState(FLAG_WINDOW_MINIMIZED))
if (!IsWindowState(MinimizedWindow))
{
MinimizeWindow();
}
@ -117,7 +117,7 @@ public class WindowFlags
framesCounter = 0;
}
if (IsWindowState(FLAG_WINDOW_MINIMIZED))
if (IsWindowState(MinimizedWindow))
{
framesCounter++;
if (framesCounter >= 240)
@ -127,10 +127,10 @@ public class WindowFlags
}
}
if (IsKeyPressed(KeyboardKey.KEY_M))
if (IsKeyPressed(KeyboardKey.M))
{
// NOTE: Requires FLAG_WINDOW_RESIZABLE enabled!
if (IsWindowState(FLAG_WINDOW_MAXIMIZED))
if (IsWindowState(MaximizedWindow))
{
RestoreWindow();
}
@ -140,51 +140,51 @@ public class WindowFlags
}
}
if (IsKeyPressed(KeyboardKey.KEY_U))
if (IsKeyPressed(KeyboardKey.U))
{
if (IsWindowState(FLAG_WINDOW_UNFOCUSED))
if (IsWindowState(UnfocusedWindow))
{
ClearWindowState(FLAG_WINDOW_UNFOCUSED);
ClearWindowState(UnfocusedWindow);
}
else
{
SetWindowState(FLAG_WINDOW_UNFOCUSED);
SetWindowState(UnfocusedWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_T))
if (IsKeyPressed(KeyboardKey.T))
{
if (IsWindowState(FLAG_WINDOW_TOPMOST))
if (IsWindowState(TopmostWindow))
{
ClearWindowState(FLAG_WINDOW_TOPMOST);
ClearWindowState(TopmostWindow);
}
else
{
SetWindowState(FLAG_WINDOW_TOPMOST);
SetWindowState(TopmostWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_A))
if (IsKeyPressed(KeyboardKey.A))
{
if (IsWindowState(FLAG_WINDOW_ALWAYS_RUN))
if (IsWindowState(AlwaysRunWindow))
{
ClearWindowState(FLAG_WINDOW_ALWAYS_RUN);
ClearWindowState(AlwaysRunWindow);
}
else
{
SetWindowState(FLAG_WINDOW_ALWAYS_RUN);
SetWindowState(AlwaysRunWindow);
}
}
if (IsKeyPressed(KeyboardKey.KEY_V))
if (IsKeyPressed(KeyboardKey.V))
{
if (IsWindowState(FLAG_VSYNC_HINT))
if (IsWindowState(VSyncHint))
{
ClearWindowState(FLAG_VSYNC_HINT);
ClearWindowState(VSyncHint);
}
else
{
SetWindowState(FLAG_VSYNC_HINT);
SetWindowState(VSyncHint);
}
}
@ -205,46 +205,46 @@ public class WindowFlags
//-----------------------------------------------------
BeginDrawing();
if (IsWindowState(FLAG_WINDOW_TRANSPARENT))
if (IsWindowState(TransparentWindow))
{
ClearBackground(Color.BLANK);
ClearBackground(Color.Blank);
}
else
{
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
}
DrawCircleV(ballPosition, ballRadius, Color.MAROON);
DrawRectangleLinesEx(new Rectangle(0, 0, GetScreenWidth(), GetScreenHeight()), 4, Color.RAYWHITE);
DrawCircleV(ballPosition, ballRadius, Color.Maroon);
DrawRectangleLinesEx(new Rectangle(0, 0, GetScreenWidth(), GetScreenHeight()), 4, Color.RayWhite);
DrawCircleV(GetMousePosition(), 10, Color.DARKBLUE);
DrawCircleV(GetMousePosition(), 10, Color.DarkBlue);
DrawFPS(10, 10);
DrawText($"Screen Size: [{GetScreenWidth()}, {GetScreenHeight()}]", 10, 40, 10, Color.GREEN);
DrawText($"Screen Size: [{GetScreenWidth()}, {GetScreenHeight()}]", 10, 40, 10, Color.Green);
// Draw window state info
Color on = Color.LIME;
Color off = Color.MAROON;
Color on = Color.Lime;
Color off = Color.Maroon;
DrawText("Following flags can be set after window creation:", 10, 60, 10, Color.GRAY);
DrawText("Following flags can be set after window creation:", 10, 60, 10, Color.Gray);
DrawWindowState(FLAG_FULLSCREEN_MODE, "[F] FLAG_FULLSCREEN_MODE: ", 10, 80, 10);
DrawWindowState(FLAG_WINDOW_RESIZABLE, "[R] FLAG_WINDOW_RESIZABLE: ", 10, 100, 10);
DrawWindowState(FLAG_WINDOW_UNDECORATED, "[D] FLAG_WINDOW_UNDECORATED: ", 10, 120, 10);
DrawWindowState(FLAG_WINDOW_HIDDEN, "[H] FLAG_WINDOW_HIDDEN: ", 10, 140, 10);
DrawWindowState(FLAG_WINDOW_MINIMIZED, "[N] FLAG_WINDOW_MINIMIZED: ", 10, 160, 10);
DrawWindowState(FLAG_WINDOW_MAXIMIZED, "[M] FLAG_WINDOW_MAXIMIZED: ", 10, 180, 10);
DrawWindowState(FLAG_WINDOW_UNFOCUSED, "[G] FLAG_WINDOW_UNFOCUSED: ", 10, 200, 10);
DrawWindowState(FLAG_WINDOW_TOPMOST, "[T] FLAG_WINDOW_TOPMOST: ", 10, 220, 10);
DrawWindowState(FLAG_WINDOW_ALWAYS_RUN, "[A] FLAG_WINDOW_ALWAYS_RUN: ", 10, 240, 10);
DrawWindowState(FLAG_VSYNC_HINT, "[V] FLAG_VSYNC_HINT: ", 10, 260, 10);
DrawWindowState(FullscreenMode, "[F] FLAG_FULLSCREEN_MODE: ", 10, 80, 10);
DrawWindowState(ResizableWindow, "[R] FLAG_WINDOW_RESIZABLE: ", 10, 100, 10);
DrawWindowState(UndecoratedWindow, "[D] FLAG_WINDOW_UNDECORATED: ", 10, 120, 10);
DrawWindowState(HiddenWindow, "[H] FLAG_WINDOW_HIDDEN: ", 10, 140, 10);
DrawWindowState(MinimizedWindow, "[N] FLAG_WINDOW_MINIMIZED: ", 10, 160, 10);
DrawWindowState(MaximizedWindow, "[M] FLAG_WINDOW_MAXIMIZED: ", 10, 180, 10);
DrawWindowState(UnfocusedWindow, "[G] FLAG_WINDOW_UNFOCUSED: ", 10, 200, 10);
DrawWindowState(TopmostWindow, "[T] FLAG_WINDOW_TOPMOST: ", 10, 220, 10);
DrawWindowState(AlwaysRunWindow, "[A] FLAG_WINDOW_ALWAYS_RUN: ", 10, 240, 10);
DrawWindowState(VSyncHint, "[V] FLAG_VSYNC_HINT: ", 10, 260, 10);
DrawText("Following flags can only be set before window creation:", 10, 300, 10, Color.GRAY);
DrawText("Following flags can only be set before window creation:", 10, 300, 10, Color.Gray);
DrawWindowState(FLAG_WINDOW_HIGHDPI, "[F] FLAG_WINDOW_HIGHDPI: ", 10, 320, 10);
DrawWindowState(FLAG_WINDOW_TRANSPARENT, "[F] FLAG_WINDOW_TRANSPARENT: ", 10, 340, 10);
DrawWindowState(FLAG_MSAA_4X_HINT, "[F] FLAG_MSAA_4X_HINT: ", 10, 360, 10);
DrawWindowState(HighDpiWindow, "[F] FLAG_WINDOW_HIGHDPI: ", 10, 320, 10);
DrawWindowState(TransparentWindow, "[F] FLAG_WINDOW_TRANSPARENT: ", 10, 340, 10);
DrawWindowState(Msaa4xHint, "[F] FLAG_MSAA_4X_HINT: ", 10, 360, 10);
EndDrawing();
//-----------------------------------------------------
@ -260,8 +260,8 @@ public class WindowFlags
static void DrawWindowState(ConfigFlags flag, string text, int posX, int posY, int fontSize)
{
Color onColor = Color.LIME;
Color offColor = Color.MAROON;
Color onColor = Color.Lime;
Color offColor = Color.Maroon;
if (Raylib.IsWindowState(flag))
{

View File

@ -25,7 +25,7 @@ public class WindowLetterbox
const int windowHeight = 450;
// Enable config flags for resizable window and vertical synchro
SetConfigFlags(ConfigFlags.FLAG_WINDOW_RESIZABLE | ConfigFlags.FLAG_VSYNC_HINT);
SetConfigFlags(ConfigFlags.ResizableWindow | ConfigFlags.VSyncHint);
InitWindow(windowWidth, windowHeight, "raylib [core] example - window scale letterbox");
SetWindowMinSize(320, 240);
@ -34,7 +34,7 @@ public class WindowLetterbox
// Render texture initialization, used to hold the rendering result so we can easily resize it
RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight);
SetTextureFilter(target.Texture, TextureFilter.TEXTURE_FILTER_BILINEAR);
SetTextureFilter(target.Texture, TextureFilter.Bilinear);
Color[] colors = new Color[10];
for (int i = 0; i < 10; i++)
@ -56,7 +56,7 @@ public class WindowLetterbox
(float)GetScreenHeight() / gameScreenHeight
);
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
// Recalculate random colors for the bars
for (int i = 0; i < 10; i++)
@ -83,11 +83,11 @@ public class WindowLetterbox
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
// Draw everything in the render texture, note this will not be rendered on screen, yet
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
for (int i = 0; i < 10; i++)
{
@ -99,11 +99,11 @@ public class WindowLetterbox
10,
25,
20,
Color.WHITE
Color.White
);
DrawText($"Default Mouse: [{(int)mouse.X} {(int)mouse.Y}]", 350, 25, 20, Color.GREEN);
DrawText($"Virtual Mouse: [{(int)virtualMouse.X}, {(int)virtualMouse.Y}]", 350, 55, 20, Color.YELLOW);
DrawText($"Default Mouse: [{(int)mouse.X} {(int)mouse.Y}]", 350, 25, 20, Color.Green);
DrawText($"Virtual Mouse: [{(int)virtualMouse.X}, {(int)virtualMouse.Y}]", 350, 55, 20, Color.Yellow);
EndTextureMode();
@ -120,7 +120,7 @@ public class WindowLetterbox
(float)gameScreenWidth * scale,
(float)gameScreenHeight * scale
);
DrawTexturePro(target.Texture, sourceRec, destRec, new Vector2(0, 0), 0.0f, Color.WHITE);
DrawTexturePro(target.Texture, sourceRec, destRec, new Vector2(0, 0), 0.0f, Color.White);
EndDrawing();
//--------------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class WorldScreen
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 cubePosition = new(0.0f, 0.0f, 0.0f);
Vector2 cubeScreenPosition;
@ -44,7 +44,7 @@ public class WorldScreen
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
// Calculate cube screen space position (with a little offset to be in top)
cubeScreenPosition = GetWorldToScreen(
@ -56,12 +56,12 @@ public class WorldScreen
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.RED);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.MAROON);
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, Color.Red);
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, Color.Maroon);
DrawGrid(10, 1.0f);
@ -72,14 +72,14 @@ public class WorldScreen
(int)cubeScreenPosition.X - MeasureText("Enemy: 100 / 100", 20) / 2,
(int)cubeScreenPosition.Y,
20,
Color.BLACK
Color.Black
);
DrawText(
"Text is always on top of the cube",
(screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2,
25,
20,
Color.GRAY
Color.Gray
);
EndDrawing();

View File

@ -39,11 +39,11 @@ public class AnimationDemo
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Model model = LoadModel("resources/models/iqm/guy.iqm");
Texture2D texture = LoadTexture("resources/models/iqm/guytex.png");
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 position = new(0.0f, 0.0f, 0.0f);
// Load animation data
@ -59,10 +59,10 @@ public class AnimationDemo
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
// Play animation when spacebar is held down
if (IsKeyDown(KeyboardKey.KEY_SPACE))
if (IsKeyDown(KeyboardKey.Space))
{
animFrameCounter++;
UpdateModelAnimation(model, anims[0], animFrameCounter);
@ -76,7 +76,7 @@ public class AnimationDemo
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
@ -86,21 +86,21 @@ public class AnimationDemo
new Vector3(1.0f, 0.0f, 0.0f),
-90.0f,
new Vector3(1.0f, 1.0f, 1.0f),
Color.WHITE
Color.White
);
for (int i = 0; i < model.BoneCount; i++)
{
var framePoses = anims[0].FramePoses;
DrawCube(framePoses[animFrameCounter][i].Translation, 0.2f, 0.2f, 0.2f, Color.RED);
DrawCube(framePoses[animFrameCounter][i].Translation, 0.2f, 0.2f, 0.2f, Color.Red);
}
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, Color.MAROON);
DrawText("(c) Guy IQM 3D model by @culacant", screenWidth - 200, screenHeight - 20, 10, Color.GRAY);
DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, Color.Maroon);
DrawText("(c) Guy IQM 3D model by @culacant", screenWidth - 200, screenHeight - 20, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class BillboardDemo
camera.Target = new Vector3(0.0f, 2.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Our texture billboard
Texture2D bill = LoadTexture("resources/billboard.png");
@ -66,7 +66,7 @@ public class BillboardDemo
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
rotation += 0.4f;
distanceStatic = Vector3.Distance(camera.Position, billPositionStatic);
distanceRotating = Vector3.Distance(camera.Position, billPositionRotating);
@ -75,7 +75,7 @@ public class BillboardDemo
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
@ -84,7 +84,7 @@ public class BillboardDemo
// Draw order matters!
if (distanceStatic > distanceRotating)
{
DrawBillboard(camera, bill, billPositionStatic, 2.0f, Color.WHITE);
DrawBillboard(camera, bill, billPositionStatic, 2.0f, Color.White);
DrawBillboardPro(
camera,
bill,
@ -94,7 +94,7 @@ public class BillboardDemo
new Vector2(1.0f, 1.0f),
rotateOrigin,
rotation,
Color.WHITE
Color.White
);
}
else
@ -108,9 +108,9 @@ public class BillboardDemo
new Vector2(1.0f, 1.0f),
rotateOrigin,
rotation,
Color.WHITE
Color.White
);
DrawBillboard(camera, bill, billPositionStatic, 2.0f, Color.WHITE);
DrawBillboard(camera, bill, billPositionStatic, 2.0f, Color.White);
}
EndMode3D();

View File

@ -31,11 +31,11 @@ public class BoxCollisions
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Vector3 playerPosition = new(0.0f, 1.0f, 2.0f);
Vector3 playerSize = new(1.0f, 2.0f, 1.0f);
Color playerColor = Color.GREEN;
Color playerColor = Color.Green;
Vector3 enemyBoxPos = new(-4.0f, 1.0f, 0.0f);
Vector3 enemyBoxSize = new(2.0f, 2.0f, 2.0f);
@ -55,19 +55,19 @@ public class BoxCollisions
//----------------------------------------------------------------------------------
// Move player
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
playerPosition.X += 0.2f;
}
else if (IsKeyDown(KeyboardKey.KEY_LEFT))
else if (IsKeyDown(KeyboardKey.Left))
{
playerPosition.X -= 0.2f;
}
else if (IsKeyDown(KeyboardKey.KEY_DOWN))
else if (IsKeyDown(KeyboardKey.Down))
{
playerPosition.Z += 0.2f;
}
else if (IsKeyDown(KeyboardKey.KEY_UP))
else if (IsKeyDown(KeyboardKey.Up))
{
playerPosition.Z -= 0.2f;
}
@ -97,28 +97,28 @@ public class BoxCollisions
if (collision)
{
playerColor = Color.RED;
playerColor = Color.Red;
}
else
{
playerColor = Color.GREEN;
playerColor = Color.Green;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
// Draw enemy-box
DrawCube(enemyBoxPos, enemyBoxSize.X, enemyBoxSize.Y, enemyBoxSize.Z, Color.GRAY);
DrawCubeWires(enemyBoxPos, enemyBoxSize.X, enemyBoxSize.Y, enemyBoxSize.Z, Color.DARKGRAY);
DrawCube(enemyBoxPos, enemyBoxSize.X, enemyBoxSize.Y, enemyBoxSize.Z, Color.Gray);
DrawCubeWires(enemyBoxPos, enemyBoxSize.X, enemyBoxSize.Y, enemyBoxSize.Z, Color.DarkGray);
// Draw enemy-sphere
DrawSphere(enemySpherePos, enemySphereSize, Color.GRAY);
DrawSphereWires(enemySpherePos, enemySphereSize, 16, 16, Color.DARKGRAY);
DrawSphere(enemySpherePos, enemySphereSize, Color.Gray);
DrawSphereWires(enemySpherePos, enemySphereSize, 16, 16, Color.DarkGray);
// Draw player
DrawCubeV(playerPosition, playerSize, playerColor);
@ -127,7 +127,7 @@ public class BoxCollisions
EndMode3D();
DrawText("Move player with cursors to collide", 220, 40, 20, Color.GRAY);
DrawText("Move player with cursors to collide", 220, 40, 20, Color.Gray);
DrawFPS(10, 10);
EndDrawing();

View File

@ -31,7 +31,7 @@ public class CubicmapDemo
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Image image = LoadImage("resources/cubicmap.png");
Texture2D cubicmap = LoadTextureFromImage(image);
@ -43,7 +43,7 @@ public class CubicmapDemo
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");
// Set map diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 mapPosition = new(-16.0f, 0.0f, -8.0f);
UnloadImage(image);
@ -56,32 +56,32 @@ public class CubicmapDemo
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, mapPosition, 1.0f, Color.WHITE);
DrawModel(model, mapPosition, 1.0f, Color.White);
EndMode3D();
Vector2 position = new(screenWidth - cubicmap.Width * 4 - 20, 20);
DrawTextureEx(cubicmap, position, 0.0f, 4.0f, Color.WHITE);
DrawTextureEx(cubicmap, position, 0.0f, 4.0f, Color.White);
DrawRectangleLines(
screenWidth - cubicmap.Width * 4 - 20,
20,
cubicmap.Width * 4,
cubicmap.Height * 4,
Color.GREEN
Color.Green
);
DrawText("cubicmap image used to", 658, 90, 10, Color.GRAY);
DrawText("generate map 3d model", 658, 104, 10, Color.GRAY);
DrawText("cubicmap image used to", 658, 90, 10, Color.Gray);
DrawText("generate map 3d model", 658, 104, 10, Color.Gray);
DrawFPS(10, 10);

View File

@ -31,7 +31,7 @@ public class FirstPersonMaze
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Image imMap = LoadImage("resources/cubicmap.png");
Texture2D cubicmap = LoadTextureFromImage(imMap);
@ -42,7 +42,7 @@ public class FirstPersonMaze
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");
// Set map diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
// Get map image data to be used for collision detection
Color* mapPixels = LoadImageColors(imMap);
@ -61,7 +61,7 @@ public class FirstPersonMaze
//----------------------------------------------------------------------------------
Vector3 oldCamPos = camera.Position;
UpdateCamera(ref camera, CameraMode.CAMERA_FIRST_PERSON);
UpdateCamera(ref camera, CameraMode.FirstPerson);
// Check player collision (we simplify to 2D collision detection)
Vector2 playerPos = new(camera.Position.X, camera.Position.Z);
@ -120,18 +120,18 @@ public class FirstPersonMaze
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Draw maze map
BeginMode3D(camera);
DrawModel(model, mapPosition, 1.0f, Color.WHITE);
DrawModel(model, mapPosition, 1.0f, Color.White);
EndMode3D();
DrawTextureEx(cubicmap, new Vector2(GetScreenWidth() - cubicmap.Width * 4 - 20, 20), 0.0f, 4.0f, Color.WHITE);
DrawRectangleLines(GetScreenWidth() - cubicmap.Width * 4 - 20, 20, cubicmap.Width * 4, cubicmap.Height * 4, Color.GREEN);
DrawTextureEx(cubicmap, new Vector2(GetScreenWidth() - cubicmap.Width * 4 - 20, 20), 0.0f, 4.0f, Color.White);
DrawRectangleLines(GetScreenWidth() - cubicmap.Width * 4 - 20, 20, cubicmap.Width * 4, cubicmap.Height * 4, Color.Green);
// Draw player position radar
DrawRectangle(GetScreenWidth() - cubicmap.Width * 4 - 20 + playerCellX * 4, 20 + playerCellY * 4, 4, 4, Color.RED);
DrawRectangle(GetScreenWidth() - cubicmap.Width * 4 - 20 + playerCellX * 4, 20 + playerCellY * 4, 4, 4, Color.Red);
DrawFPS(10, 10);

View File

@ -31,7 +31,7 @@ public class GeometricShapes
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -47,23 +47,23 @@ public class GeometricShapes
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawCube(new Vector3(-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, Color.RED);
DrawCubeWires(new Vector3(-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, Color.GOLD);
DrawCubeWires(new Vector3(-4.0f, 0.0f, -2.0f), 3.0f, 6.0f, 2.0f, Color.MAROON);
DrawCube(new Vector3(-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, Color.Red);
DrawCubeWires(new Vector3(-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, Color.Gold);
DrawCubeWires(new Vector3(-4.0f, 0.0f, -2.0f), 3.0f, 6.0f, 2.0f, Color.Maroon);
DrawSphere(new Vector3(-1.0f, 0.0f, -2.0f), 1.0f, Color.GREEN);
DrawSphereWires(new Vector3(1.0f, 0.0f, 2.0f), 2.0f, 16, 16, Color.LIME);
DrawSphere(new Vector3(-1.0f, 0.0f, -2.0f), 1.0f, Color.Green);
DrawSphereWires(new Vector3(1.0f, 0.0f, 2.0f), 2.0f, 16, 16, Color.Lime);
DrawCylinder(new Vector3(4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, Color.SKYBLUE);
DrawCylinderWires(new Vector3(4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, Color.DARKBLUE);
DrawCylinderWires(new Vector3(4.5f, -1.0f, 2.0f), 1.0f, 1.0f, 2.0f, 6, Color.BROWN);
DrawCylinder(new Vector3(4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, Color.SkyBlue);
DrawCylinderWires(new Vector3(4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, Color.DarkBlue);
DrawCylinderWires(new Vector3(4.5f, -1.0f, 2.0f), 1.0f, 1.0f, 2.0f, 6, Color.Brown);
DrawCylinder(new Vector3(1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, Color.GOLD);
DrawCylinderWires(new Vector3(1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, Color.PINK);
DrawCylinder(new Vector3(1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, Color.Gold);
DrawCylinderWires(new Vector3(1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, Color.Pink);
DrawGrid(10, 1.0f);

View File

@ -31,7 +31,7 @@ public class HeightmapDemo
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Image image = LoadImage("resources/heightmap.png");
Texture2D texture = LoadTextureFromImage(image);
@ -40,7 +40,7 @@ public class HeightmapDemo
Model model = LoadModelFromMesh(mesh);
// Set map diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 mapPosition = new(-8.0f, 0.0f, -8.0f);
@ -54,24 +54,24 @@ public class HeightmapDemo
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, mapPosition, 1.0f, Color.RED);
DrawModel(model, mapPosition, 1.0f, Color.Red);
DrawGrid(20, 1.0f);
EndMode3D();
DrawTexture(texture, screenWidth - texture.Width - 20, 20, Color.WHITE);
DrawRectangleLines(screenWidth - texture.Width - 20, 20, texture.Width, texture.Height, Color.GREEN);
DrawTexture(texture, screenWidth - texture.Width - 20, 20, Color.White);
DrawRectangleLines(screenWidth - texture.Width - 20, 20, texture.Width, texture.Height, Color.Green);
DrawFPS(10, 10);

View File

@ -20,7 +20,7 @@ public class MeshDemo
camera.Target = Vector3.Zero;
camera.Up = Vector3.UnitY;
camera.FovY = 60.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Generate a mesh using utils to allocate/access mesh attribute data
Mesh tetrahedron = new(4, 4);
@ -44,10 +44,10 @@ public class MeshDemo
texcoords[2] = Vector2.UnitY;
texcoords[3] = Vector2.One;
colors[0] = Color.PINK;
colors[1] = Color.LIME;
colors[2] = Color.SKYBLUE;
colors[3] = Color.VIOLET;
colors[0] = Color.Pink;
colors[1] = Color.Lime;
colors[2] = Color.SkyBlue;
colors[3] = Color.Violet;
indices[0] = 2;
indices[1] = 1;
@ -76,7 +76,7 @@ public class MeshDemo
Texture2D texture = Raylib.LoadTextureFromImage(image);
Raylib.UnloadImage(image);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_DIFFUSE, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Diffuse, ref texture);
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -86,17 +86,17 @@ public class MeshDemo
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
rotationAngle = Raymath.Wrap(rotationAngle += 1f, 0f, 360f);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
Raylib.DrawModelEx(model, Vector3.Zero, Vector3.UnitX, rotationAngle, Vector3.One, Color.WHITE);
Raylib.DrawModelEx(model, Vector3.Zero, Vector3.UnitX, rotationAngle, Vector3.One, Color.White);
EndMode3D();
EndDrawing();

View File

@ -26,7 +26,7 @@ public class MeshGeneration
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation");
// We generate a isChecked image for texturing
Image isChecked = GenImageChecked(2, 2, 1, 1, Color.RED, Color.GREEN);
Image isChecked = GenImageChecked(2, 2, 1, 1, Color.Red, Color.Green);
Texture2D texture = LoadTextureFromImage(isChecked);
UnloadImage(isChecked);
@ -46,7 +46,7 @@ public class MeshGeneration
for (int i = 0; i < models.Length; i++)
{
// Set map diffuse texture
Raylib.SetMaterialTexture(ref models[i], 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref models[i], 0, MaterialMapIndex.Albedo, ref texture);
}
// Define the camera to look into our 3d world
@ -55,7 +55,7 @@ public class MeshGeneration
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Model drawing position
Vector3 position = new(0.0f, 0.0f, 0.0f);
@ -70,9 +70,9 @@ public class MeshGeneration
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
// Cycle between the textures
currentModel = (currentModel + 1) % models.Length;
@ -82,48 +82,48 @@ public class MeshGeneration
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(models[currentModel], position, 1.0f, Color.WHITE);
DrawModel(models[currentModel], position, 1.0f, Color.White);
DrawGrid(10, 1.0f);
EndMode3D();
DrawRectangle(30, 400, 310, 30, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(30, 400, 310, 30, ColorAlpha(Color.DARKBLUE, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, Color.BLUE);
DrawRectangle(30, 400, 310, 30, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(30, 400, 310, 30, ColorAlpha(Color.DarkBlue, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, Color.Blue);
switch (currentModel)
{
case 0:
DrawText("PLANE", 680, 10, 20, Color.DARKBLUE);
DrawText("PLANE", 680, 10, 20, Color.DarkBlue);
break;
case 1:
DrawText("CUBE", 680, 10, 20, Color.DARKBLUE);
DrawText("CUBE", 680, 10, 20, Color.DarkBlue);
break;
case 2:
DrawText("SPHERE", 680, 10, 20, Color.DARKBLUE);
DrawText("SPHERE", 680, 10, 20, Color.DarkBlue);
break;
case 3:
DrawText("HEMISPHERE", 640, 10, 20, Color.DARKBLUE);
DrawText("HEMISPHERE", 640, 10, 20, Color.DarkBlue);
break;
case 4:
DrawText("CYLINDER", 680, 10, 20, Color.DARKBLUE);
DrawText("CYLINDER", 680, 10, 20, Color.DarkBlue);
break;
case 5:
DrawText("TORUS", 680, 10, 20, Color.DARKBLUE);
DrawText("TORUS", 680, 10, 20, Color.DarkBlue);
break;
case 6:
DrawText("KNOT", 680, 10, 20, Color.DARKBLUE);
DrawText("KNOT", 680, 10, 20, Color.DarkBlue);
break;
case 7:
DrawText("POLY", 680, 10, 20, Color.DARKBLUE);
DrawText("POLY", 680, 10, 20, Color.DarkBlue);
break;
case 8:
DrawText("Custom (triagnle)", 580, 10, 20, Color.DARKBLUE);
DrawText("Custom (triagnle)", 580, 10, 20, Color.DarkBlue);
break;
default:
break;

View File

@ -33,14 +33,14 @@ public class MeshPicking
camera.Target = new Vector3(0.0f, 8.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.6f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Picking ray
Ray ray = new();
Model tower = LoadModel("resources/models/obj/turret.obj");
Texture2D texture = LoadTexture("resources/models/obj/turret_diffuse.png");
Raylib.SetMaterialTexture(ref tower, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref tower, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 towerPos = new(0.0f, 0.0f, 0.0f);
BoundingBox towerBBox = GetMeshBoundingBox(tower.Meshes[0]);
@ -75,11 +75,11 @@ public class MeshPicking
//----------------------------------------------------------------------------------
if (IsCursorHidden())
{
UpdateCamera(ref camera, CameraMode.CAMERA_FIRST_PERSON);
UpdateCamera(ref camera, CameraMode.FirstPerson);
}
// Toggle camera controls
if (IsMouseButtonPressed(MouseButton.MOUSE_BUTTON_RIGHT))
if (IsMouseButtonPressed(MouseButton.Right))
{
if (IsCursorHidden())
{
@ -96,7 +96,7 @@ public class MeshPicking
string hitObjectName = "None";
collision.Distance = float.MaxValue;
collision.Hit = false;
Color cursorColor = Color.WHITE;
Color cursorColor = Color.White;
// Get ray and test against objects
ray = GetMouseRay(GetMousePosition(), camera);
@ -106,7 +106,7 @@ public class MeshPicking
if (groundHitInfo.Hit && (groundHitInfo.Distance < collision.Distance))
{
collision = groundHitInfo;
cursorColor = Color.GREEN;
cursorColor = Color.Green;
hitObjectName = "Ground";
}
@ -115,7 +115,7 @@ public class MeshPicking
if (triHitInfo.Hit && (triHitInfo.Distance < collision.Distance))
{
collision = triHitInfo;
cursorColor = Color.PURPLE;
cursorColor = Color.Purple;
hitObjectName = "Triangle";
bary = Vector3Barycenter(collision.Point, ta, tb, tc);
@ -126,7 +126,7 @@ public class MeshPicking
if ((sphereHitInfo.Hit) && (sphereHitInfo.Distance < collision.Distance))
{
collision = sphereHitInfo;
cursorColor = Color.ORANGE;
cursorColor = Color.Orange;
hitObjectName = "Sphere";
}
@ -135,7 +135,7 @@ public class MeshPicking
if (boxHitInfo.Hit && boxHitInfo.Distance < collision.Distance)
{
collision = boxHitInfo;
cursorColor = Color.ORANGE;
cursorColor = Color.Orange;
hitObjectName = "Box";
// Check ray collision against model meshes
@ -160,7 +160,7 @@ public class MeshPicking
if (meshHitInfo.Hit)
{
collision = meshHitInfo;
cursorColor = Color.ORANGE;
cursorColor = Color.Orange;
hitObjectName = "Mesh";
}
}
@ -169,65 +169,65 @@ public class MeshPicking
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
// Draw the tower
DrawModel(tower, towerPos, 1.0f, Color.WHITE);
DrawModel(tower, towerPos, 1.0f, Color.White);
// Draw the test triangle
DrawLine3D(ta, tb, Color.PURPLE);
DrawLine3D(tb, tc, Color.PURPLE);
DrawLine3D(tc, ta, Color.PURPLE);
DrawLine3D(ta, tb, Color.Purple);
DrawLine3D(tb, tc, Color.Purple);
DrawLine3D(tc, ta, Color.Purple);
// Draw the test sphere
DrawSphereWires(sp, sr, 8, 8, Color.PURPLE);
DrawSphereWires(sp, sr, 8, 8, Color.Purple);
// Draw the mesh bbox if we hit it
if (boxHitInfo.Hit)
{
DrawBoundingBox(towerBBox, Color.LIME);
DrawBoundingBox(towerBBox, Color.Lime);
}
// If we hit something, draw the cursor at the hit point
if (collision.Hit)
{
DrawCube(collision.Point, 0.3f, 0.3f, 0.3f, cursorColor);
DrawCubeWires(collision.Point, 0.3f, 0.3f, 0.3f, Color.RED);
DrawCubeWires(collision.Point, 0.3f, 0.3f, 0.3f, Color.Red);
Vector3 normalEnd = collision.Point + collision.Normal;
DrawLine3D(collision.Point, normalEnd, Color.RED);
DrawLine3D(collision.Point, normalEnd, Color.Red);
}
DrawRay(ray, Color.MAROON);
DrawRay(ray, Color.Maroon);
DrawGrid(10, 10.0f);
EndMode3D();
// Draw some debug GUI text
DrawText($"Hit Object: {hitObjectName}", 10, 50, 10, Color.BLACK);
DrawText($"Hit Object: {hitObjectName}", 10, 50, 10, Color.Black);
if (collision.Hit)
{
int ypos = 70;
DrawText($"Distance: {collision.Distance}", 10, ypos, 10, Color.BLACK);
DrawText($"Distance: {collision.Distance}", 10, ypos, 10, Color.Black);
DrawText($"Hit Pos: {collision.Point}", 10, ypos + 15, 10, Color.BLACK);
DrawText($"Hit Pos: {collision.Point}", 10, ypos + 15, 10, Color.Black);
DrawText($"Hit Norm: {collision.Normal}", 10, ypos + 30, 10, Color.BLACK);
DrawText($"Hit Norm: {collision.Normal}", 10, ypos + 30, 10, Color.Black);
if (triHitInfo.Hit)
{
DrawText($"Barycenter: {bary}", 10, ypos + 45, 10, Color.BLACK);
DrawText($"Barycenter: {bary}", 10, ypos + 45, 10, Color.Black);
}
}
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, Color.GRAY);
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, Color.Gray);
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, Color.GRAY);
DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, Color.Gray);
DrawFPS(10, 10);

View File

@ -33,7 +33,7 @@ public class ModelCubeTexture
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Load texture to be applied to the cubes sides
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png");
@ -51,12 +51,12 @@ public class ModelCubeTexture
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
// Draw cube with an applied texture
DrawCubeTexture(texture, new Vector3(-2.0f, 2.0f, 0.0f), 2.0f, 4.0f, 2.0f, Color.WHITE);
DrawCubeTexture(texture, new Vector3(-2.0f, 2.0f, 0.0f), 2.0f, 4.0f, 2.0f, Color.White);
// Draw cube with an applied texture, but only a defined rectangle piece of the texture
DrawCubeTextureRec(
@ -66,7 +66,7 @@ public class ModelCubeTexture
2.0f,
2.0f,
2.0f,
Color.WHITE
Color.White
);
DrawGrid(10, 1.0f);
@ -113,7 +113,7 @@ public class ModelCubeTexture
// Rlgl.Rotatef(45, 0, 1, 0);
// Rlgl.Scalef(2.0f, 2.0f, 2.0f);
Rlgl.Begin(DrawMode.QUADS);
Rlgl.Begin(DrawMode.Quads);
Rlgl.Color4ub(color.R, color.G, color.B, color.A);
// Front Face
@ -239,7 +239,7 @@ public class ModelCubeTexture
// We calculate the normalized texture coordinates for the desired texture-source-rectangle
// It means converting from (tex.Width, tex.Height) coordinates to [0.0f, 1.0f] equivalent
Rlgl.Begin(DrawMode.QUADS);
Rlgl.Begin(DrawMode.Quads);
Rlgl.Color4ub(color.R, color.G, color.B, color.A);
// Front face

View File

@ -40,13 +40,13 @@ public class ModelLoading
camera.Target = new Vector3(0.0f, 10.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Model model = LoadModel("resources/models/obj/castle.obj");
Texture2D texture = LoadTexture("resources/models/obj/castle_diffuse.png");
// Set map diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 position = new(0.0f, 0.0f, 0.0f);
BoundingBox bounds = GetMeshBoundingBox(model.Meshes[0]);
@ -64,7 +64,7 @@ public class ModelLoading
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
if (IsFileDropped())
{
@ -81,7 +81,7 @@ public class ModelLoading
model = LoadModel(files[0]);
// Set current map diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
bounds = GetMeshBoundingBox(model.Meshes[0]);
@ -92,13 +92,13 @@ public class ModelLoading
// Unload model texture and load new one
UnloadTexture(texture);
texture = LoadTexture(files[0]);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
}
}
}
// Select model on mouse click
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
// Check collision between ray and box
if (GetRayCollisionBox(GetMouseRay(GetMousePosition(), camera), bounds).Hit)
@ -115,28 +115,28 @@ public class ModelLoading
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, position, 1.0f, Color.WHITE);
DrawModel(model, position, 1.0f, Color.White);
DrawGrid(20, 10.0f);
if (selected)
{
DrawBoundingBox(bounds, Color.GREEN);
DrawBoundingBox(bounds, Color.Green);
}
EndMode3D();
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, Color.DARKGRAY);
DrawText("Drag & drop model to load mesh/texture.", 10, GetScreenHeight() - 20, 10, Color.DarkGray);
if (selected)
{
DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, Color.GREEN);
DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, Color.Green);
}
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, Color.GRAY);
DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, Color.Gray);
DrawFPS(10, 10);

View File

@ -36,7 +36,7 @@ public class OrthographicProjection
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = FOVY_PERSPECTIVE;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -46,17 +46,17 @@ public class OrthographicProjection
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
if (camera.Projection == CameraProjection.CAMERA_PERSPECTIVE)
if (camera.Projection == CameraProjection.Perspective)
{
camera.FovY = WIDTH_ORTHOGRAPHIC;
camera.Projection = CameraProjection.CAMERA_ORTHOGRAPHIC;
camera.Projection = CameraProjection.Orthographic;
}
else
{
camera.FovY = FOVY_PERSPECTIVE;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
}
}
//----------------------------------------------------------------------------------
@ -64,37 +64,37 @@ public class OrthographicProjection
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawCube(new Vector3(-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, Color.RED);
DrawCubeWires(new Vector3(-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, Color.GOLD);
DrawCubeWires(new Vector3(-4.0f, 0.0f, -2.0f), 3.0f, 6.0f, 2.0f, Color.MAROON);
DrawCube(new Vector3(-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, Color.Red);
DrawCubeWires(new Vector3(-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, Color.Gold);
DrawCubeWires(new Vector3(-4.0f, 0.0f, -2.0f), 3.0f, 6.0f, 2.0f, Color.Maroon);
DrawSphere(new Vector3(-1.0f, 0.0f, -2.0f), 1.0f, Color.GREEN);
DrawSphereWires(new Vector3(1.0f, 0.0f, 2.0f), 2.0f, 16, 16, Color.LIME);
DrawSphere(new Vector3(-1.0f, 0.0f, -2.0f), 1.0f, Color.Green);
DrawSphereWires(new Vector3(1.0f, 0.0f, 2.0f), 2.0f, 16, 16, Color.Lime);
DrawCylinder(new Vector3(4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, Color.SKYBLUE);
DrawCylinderWires(new Vector3(4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, Color.DARKBLUE);
DrawCylinderWires(new Vector3(4.5f, -1.0f, 2.0f), 1.0f, 1.0f, 2.0f, 6, Color.BROWN);
DrawCylinder(new Vector3(4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, Color.SkyBlue);
DrawCylinderWires(new Vector3(4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, Color.DarkBlue);
DrawCylinderWires(new Vector3(4.5f, -1.0f, 2.0f), 1.0f, 1.0f, 2.0f, 6, Color.Brown);
DrawCylinder(new Vector3(1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, Color.GOLD);
DrawCylinderWires(new Vector3(1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, Color.PINK);
DrawCylinder(new Vector3(1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, Color.Gold);
DrawCylinderWires(new Vector3(1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, Color.Pink);
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, Color.DARKGRAY);
DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, Color.DarkGray);
if (camera.Projection == CameraProjection.CAMERA_ORTHOGRAPHIC)
if (camera.Projection == CameraProjection.Orthographic)
{
DrawText("ORTHOGRAPHIC", 10, 40, 20, Color.BLACK);
DrawText("ORTHOGRAPHIC", 10, 40, 20, Color.Black);
}
else if (camera.Projection == CameraProjection.CAMERA_PERSPECTIVE)
else if (camera.Projection == CameraProjection.Perspective)
{
DrawText("PERSPECTIVE", 10, 40, 20, Color.BLACK);
DrawText("PERSPECTIVE", 10, 40, 20, Color.Black);
}
DrawFPS(10, 10);

View File

@ -31,7 +31,7 @@ public class SkyboxDemo
camera.Target = new Vector3(4.0f, 1.0f, 4.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Load skybox model
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
@ -46,22 +46,22 @@ public class SkyboxDemo
Raylib.SetShaderValue(
shdrSkybox,
GetShaderLocation(shdrSkybox, "environmentMap"),
(int)MaterialMapIndex.MATERIAL_MAP_CUBEMAP,
ShaderUniformDataType.SHADER_UNIFORM_INT
(int)MaterialMapIndex.Cubemap,
ShaderUniformDataType.Int
);
Raylib.SetShaderValue(
shdrSkybox,
GetShaderLocation(shdrSkybox, "doGamma"),
useHdr ? 1 : 0,
ShaderUniformDataType.SHADER_UNIFORM_INT
ShaderUniformDataType.Int
);
Raylib.SetShaderValue(
shdrSkybox,
GetShaderLocation(shdrSkybox, "vflipped"),
useHdr ? 1 : 0,
ShaderUniformDataType.SHADER_UNIFORM_INT
ShaderUniformDataType.Int
);
Raylib.SetMaterialShader(ref skybox, 0, ref shdrSkybox);
@ -75,7 +75,7 @@ public class SkyboxDemo
shdrCubemap,
GetShaderLocation(shdrCubemap, "equirectangularMap"),
0,
ShaderUniformDataType.SHADER_UNIFORM_INT
ShaderUniformDataType.Int
);
// Load skybox
@ -90,16 +90,16 @@ public class SkyboxDemo
shdrCubemap,
panorama,
1024,
PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
PixelFormat.UncompressedR8G8B8A8
);
SetMaterialTexture(ref skybox, 0, MaterialMapIndex.MATERIAL_MAP_CUBEMAP, ref cubemap);
SetMaterialTexture(ref skybox, 0, MaterialMapIndex.Cubemap, ref cubemap);
UnloadTexture(panorama);
}
else
{
Image img = LoadImage("resources/skybox.png");
Texture2D cubemap = LoadTextureCubemap(img, CubemapLayout.CUBEMAP_LAYOUT_AUTO_DETECT);
SetMaterialTexture(ref skybox, 0, MaterialMapIndex.MATERIAL_MAP_CUBEMAP, ref cubemap);
Texture2D cubemap = LoadTextureCubemap(img, CubemapLayout.AutoDetect);
SetMaterialTexture(ref skybox, 0, MaterialMapIndex.Cubemap, ref cubemap);
UnloadImage(img);
}
@ -113,7 +113,7 @@ public class SkyboxDemo
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FIRST_PERSON);
UpdateCamera(ref camera, CameraMode.FirstPerson);
// Load new cubemap texture on drag & drop
if (IsFileDropped())
@ -125,7 +125,7 @@ public class SkyboxDemo
if (IsFileExtension(files[0], ".png;.jpg;.hdr;.bmp;.tga"))
{
// Unload cubemap texture and load new one
UnloadTexture(Raylib.GetMaterialTexture(ref skybox, 0, MaterialMapIndex.MATERIAL_MAP_CUBEMAP));
UnloadTexture(Raylib.GetMaterialTexture(ref skybox, 0, MaterialMapIndex.Cubemap));
if (useHdr)
{
@ -134,16 +134,16 @@ public class SkyboxDemo
shdrCubemap,
panorama,
1024,
PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
PixelFormat.UncompressedR8G8B8A8
);
SetMaterialTexture(ref skybox, 0, MaterialMapIndex.MATERIAL_MAP_CUBEMAP, ref cubemap);
SetMaterialTexture(ref skybox, 0, MaterialMapIndex.Cubemap, ref cubemap);
UnloadTexture(panorama);
}
else
{
Image img = LoadImage(files[0]);
Texture2D cubemap = LoadTextureCubemap(img, CubemapLayout.CUBEMAP_LAYOUT_AUTO_DETECT);
SetMaterialTexture(ref skybox, 0, MaterialMapIndex.MATERIAL_MAP_CUBEMAP, ref cubemap);
Texture2D cubemap = LoadTextureCubemap(img, CubemapLayout.AutoDetect);
SetMaterialTexture(ref skybox, 0, MaterialMapIndex.Cubemap, ref cubemap);
UnloadImage(img);
}
@ -156,14 +156,14 @@ public class SkyboxDemo
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
// We are inside the cube, we need to disable backface culling!
Rlgl.DisableBackfaceCulling();
Rlgl.DisableDepthMask();
DrawModel(skybox, Vector3.Zero, 1.0f, Color.WHITE);
DrawModel(skybox, Vector3.Zero, 1.0f, Color.White);
Rlgl.EnableBackfaceCulling();
Rlgl.EnableDepthMask();
@ -178,12 +178,12 @@ public class SkyboxDemo
10,
GetScreenHeight() - 20,
10,
Color.BLACK
Color.Black
);
}
else
{
DrawText($": {skyboxFileName}", 10, GetScreenHeight() - 20, 10, Color.BLACK);
DrawText($": {skyboxFileName}", 10, GetScreenHeight() - 20, 10, Color.Black);
}
DrawFPS(10, 10);
@ -195,7 +195,7 @@ public class SkyboxDemo
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadShader(Raylib.GetMaterial(ref skybox, 0).Shader);
UnloadTexture(Raylib.GetMaterialTexture(ref skybox, 0, MaterialMapIndex.MATERIAL_MAP_CUBEMAP));
UnloadTexture(Raylib.GetMaterialTexture(ref skybox, 0, MaterialMapIndex.Cubemap));
UnloadModel(skybox);
@ -222,15 +222,15 @@ public class SkyboxDemo
Rlgl.FramebufferAttach(
fbo,
rbo,
FramebufferAttachType.RL_ATTACHMENT_DEPTH,
FramebufferAttachTextureType.RL_ATTACHMENT_RENDERBUFFER,
FramebufferAttachType.Depth,
FramebufferAttachTextureType.Renderbuffer,
0
);
Rlgl.FramebufferAttach(
fbo,
cubemap.Id,
FramebufferAttachType.RL_ATTACHMENT_COLOR_CHANNEL0,
FramebufferAttachTextureType.RL_ATTACHMENT_CUBEMAP_POSITIVE_X,
FramebufferAttachType.ColorChannel0,
FramebufferAttachTextureType.CubemapPositiveX,
0
);
@ -253,7 +253,7 @@ public class SkyboxDemo
Rlgl.CULL_DISTANCE_NEAR,
Rlgl.CULL_DISTANCE_FAR
);
Rlgl.SetUniformMatrix(shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_PROJECTION], matFboProjection);
Rlgl.SetUniformMatrix(shader.Locs[(int)ShaderLocationIndex.MatrixProjection], matFboProjection);
// Define view matrix for every side of the cubemap
Matrix4x4[] fboViews = new[]
@ -276,15 +276,15 @@ public class SkyboxDemo
for (int i = 0; i < 6; i++)
{
// Set the view matrix for the current cube face
Rlgl.SetUniformMatrix(shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_VIEW], fboViews[i]);
Rlgl.SetUniformMatrix(shader.Locs[(int)ShaderLocationIndex.MatrixView], fboViews[i]);
// Select the current cubemap face attachment for the fbo
// WARNING: This function by default enables->attach->disables fbo!!!
Rlgl.FramebufferAttach(
fbo,
cubemap.Id,
FramebufferAttachType.RL_ATTACHMENT_COLOR_CHANNEL0,
FramebufferAttachTextureType.RL_ATTACHMENT_CUBEMAP_POSITIVE_X + i,
FramebufferAttachType.ColorChannel0,
FramebufferAttachTextureType.CubemapPositiveX + i,
0
);
Rlgl.EnableFramebuffer(fbo);

View File

@ -40,7 +40,7 @@ public class SolarSystem
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// General system rotation speed
float rotationSpeed = 0.2f;
@ -61,7 +61,7 @@ public class SolarSystem
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
earthRotation += (5.0f * rotationSpeed);
earthOrbitRotation += (365 / 360.0f * (5.0f * rotationSpeed) * rotationSpeed);
@ -72,7 +72,7 @@ public class SolarSystem
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
@ -80,7 +80,7 @@ public class SolarSystem
// Scale Sun
Rlgl.Scalef(sunRadius, sunRadius, sunRadius);
// Draw the Sun
DrawSphereBasic(Color.GOLD);
DrawSphereBasic(Color.Gold);
Rlgl.PopMatrix();
Rlgl.PushMatrix();
@ -98,7 +98,7 @@ public class SolarSystem
Rlgl.Scalef(earthRadius, earthRadius, earthRadius);
// Draw the Earth
DrawSphereBasic(Color.BLUE);
DrawSphereBasic(Color.Blue);
Rlgl.PopMatrix();
// Rotation for Moon orbit around Earth
@ -113,7 +113,7 @@ public class SolarSystem
Rlgl.Scalef(moonRadius, moonRadius, moonRadius);
// Draw the Moon
DrawSphereBasic(Color.LIGHTGRAY);
DrawSphereBasic(Color.LightGray);
Rlgl.PopMatrix();
// Some reference elements (not affected by previous matrix transformations)
@ -122,13 +122,13 @@ public class SolarSystem
earthOrbitRadius,
new Vector3(1, 0, 0),
90.0f,
ColorAlpha(Color.RED, 0.5f)
ColorAlpha(Color.Red, 0.5f)
);
DrawGrid(20, 1.0f);
EndMode3D();
DrawText("EARTH ORBITING AROUND THE SUN!", 400, 10, 20, Color.MAROON);
DrawText("EARTH ORBITING AROUND THE SUN!", 400, 10, 20, Color.Maroon);
DrawFPS(10, 10);
EndDrawing();
@ -150,7 +150,7 @@ public class SolarSystem
int rings = 16;
int slices = 16;
Rlgl.Begin(DrawMode.TRIANGLES);
Rlgl.Begin(DrawMode.Triangles);
Rlgl.Color4ub(color.R, color.G, color.B, color.A);
for (int i = 0; i < (rings + 2); i++)

View File

@ -34,7 +34,7 @@ public class WavingCubes
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 70.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Specify the amount of blocks in each direction
const int numBlocks = 15;
@ -61,7 +61,7 @@ public class WavingCubes
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);

View File

@ -33,12 +33,12 @@ public class YawPitchRoll
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 30.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Model loading
Model model = LoadModel("resources/models/obj/plane.obj");
Texture2D texture = LoadTexture("resources/models/obj/plane_diffuse.png");
model.Materials[0].Maps[(int)MaterialMapIndex.MATERIAL_MAP_DIFFUSE].Texture = texture;
model.Materials[0].Maps[(int)MaterialMapIndex.Diffuse].Texture = texture;
float pitch = 0.0f;
float roll = 0.0f;
@ -53,11 +53,11 @@ public class YawPitchRoll
//----------------------------------------------------------------------------------
// Plane roll (x-axis) controls
if (IsKeyDown(KeyboardKey.KEY_DOWN))
if (IsKeyDown(KeyboardKey.Down))
{
pitch += 0.6f;
}
else if (IsKeyDown(KeyboardKey.KEY_UP))
else if (IsKeyDown(KeyboardKey.Up))
{
pitch -= 0.6f;
}
@ -74,11 +74,11 @@ public class YawPitchRoll
}
// Plane yaw (y-axis) controls
if (IsKeyDown(KeyboardKey.KEY_S))
if (IsKeyDown(KeyboardKey.S))
{
yaw += 1.0f;
}
else if (IsKeyDown(KeyboardKey.KEY_A))
else if (IsKeyDown(KeyboardKey.A))
{
yaw -= 1.0f;
}
@ -95,11 +95,11 @@ public class YawPitchRoll
}
// Plane pitch (z-axis) controls
if (IsKeyDown(KeyboardKey.KEY_LEFT))
if (IsKeyDown(KeyboardKey.Left))
{
roll += 1.0f;
}
else if (IsKeyDown(KeyboardKey.KEY_RIGHT))
else if (IsKeyDown(KeyboardKey.Right))
{
roll -= 1.0f;
}
@ -122,30 +122,30 @@ public class YawPitchRoll
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Draw 3D model (recomended to draw 3D always before 2D)
BeginMode3D(camera);
// Draw 3d model with texture
DrawModel(model, new Vector3(0.0f, -8.0f, 0.0f), 1.0f, Color.WHITE);
DrawModel(model, new Vector3(0.0f, -8.0f, 0.0f), 1.0f, Color.White);
DrawGrid(10, 10.0f);
EndMode3D();
// Draw controls info
DrawRectangle(30, 370, 260, 70, Fade(Color.GREEN, 0.5f));
DrawRectangleLines(30, 370, 260, 70, Fade(Color.DARKGREEN, 0.5f));
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 380, 10, Color.DARKGRAY);
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, 400, 10, Color.DARKGRAY);
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 420, 10, Color.DARKGRAY);
DrawRectangle(30, 370, 260, 70, Fade(Color.Green, 0.5f));
DrawRectangleLines(30, 370, 260, 70, Fade(Color.DarkGreen, 0.5f));
DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 380, 10, Color.DarkGray);
DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, 400, 10, Color.DarkGray);
DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 420, 10, Color.DarkGray);
DrawText(
"(c) WWI Plane Model created by GiaHanLam",
screenWidth - 240,
screenHeight - 20,
10,
Color.DARKGRAY
Color.DarkGray
);
EndDrawing();

View File

@ -43,7 +43,7 @@ public class BasicLighting
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - basic lighting");
// Define the camera to look into our 3d world
@ -52,7 +52,7 @@ public class BasicLighting
camera.Target = new Vector3(0.0f, 0.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Load plane model from a generated mesh
Model model = LoadModelFromMesh(GenMeshPlane(10.0f, 10.0f, 3, 3));
@ -64,12 +64,12 @@ public class BasicLighting
);
// Get some required shader loactions
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.Locs[(int)ShaderLocationIndex.VectorView] = GetShaderLocation(shader, "viewPos");
// ambient light level
int ambientLoc = GetShaderLocation(shader, "ambient");
float[] ambient = new[] { 0.1f, 0.1f, 0.1f, 1.0f };
Raylib.SetShaderValue(shader, ambientLoc, ambient, ShaderUniformDataType.SHADER_UNIFORM_VEC4);
Raylib.SetShaderValue(shader, ambientLoc, ambient, ShaderUniformDataType.Vec4);
// Assign out lighting shader to model
model.Materials[0].Shader = shader;
@ -82,7 +82,7 @@ public class BasicLighting
LightType.Point,
new Vector3(-2, 1, -2),
Vector3.Zero,
Color.YELLOW,
Color.Yellow,
shader
);
lights[1] = Rlights.CreateLight(
@ -90,7 +90,7 @@ public class BasicLighting
LightType.Point,
new Vector3(2, 1, 2),
Vector3.Zero,
Color.RED,
Color.Red,
shader
);
lights[2] = Rlights.CreateLight(
@ -98,7 +98,7 @@ public class BasicLighting
LightType.Point,
new Vector3(-2, 1, 2),
Vector3.Zero,
Color.GREEN,
Color.Green,
shader
);
lights[3] = Rlights.CreateLight(
@ -106,7 +106,7 @@ public class BasicLighting
LightType.Point,
new Vector3(2, 1, -2),
Vector3.Zero,
Color.BLUE,
Color.Blue,
shader
);
@ -118,21 +118,21 @@ public class BasicLighting
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
if (IsKeyPressed(KeyboardKey.KEY_Y))
if (IsKeyPressed(KeyboardKey.Y))
{
lights[0].Enabled = !lights[0].Enabled;
}
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
lights[1].Enabled = !lights[1].Enabled;
}
if (IsKeyPressed(KeyboardKey.KEY_G))
if (IsKeyPressed(KeyboardKey.G))
{
lights[2].Enabled = !lights[2].Enabled;
}
if (IsKeyPressed(KeyboardKey.KEY_B))
if (IsKeyPressed(KeyboardKey.B))
{
lights[3].Enabled = !lights[3].Enabled;
}
@ -146,57 +146,57 @@ public class BasicLighting
// Update the light shader with the camera view position
Raylib.SetShaderValue(
shader,
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW],
shader.Locs[(int)ShaderLocationIndex.VectorView],
camera.Position,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
ShaderUniformDataType.Vec3
);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, Vector3.Zero, 1.0f, Color.WHITE);
DrawModel(cube, Vector3.Zero, 1.0f, Color.WHITE);
DrawModel(model, Vector3.Zero, 1.0f, Color.White);
DrawModel(cube, Vector3.Zero, 1.0f, Color.White);
// Draw markers to show where the lights are
if (lights[0].Enabled)
{
DrawSphereEx(lights[0].Position, 0.2f, 8, 8, Color.YELLOW);
DrawSphereEx(lights[0].Position, 0.2f, 8, 8, Color.Yellow);
}
else
{
DrawSphereWires(lights[0].Position, 0.2f, 8, 8, ColorAlpha(Color.YELLOW, 0.3f));
DrawSphereWires(lights[0].Position, 0.2f, 8, 8, ColorAlpha(Color.Yellow, 0.3f));
}
if (lights[1].Enabled)
{
DrawSphereEx(lights[1].Position, 0.2f, 8, 8, Color.RED);
DrawSphereEx(lights[1].Position, 0.2f, 8, 8, Color.Red);
}
else
{
DrawSphereWires(lights[1].Position, 0.2f, 8, 8, ColorAlpha(Color.RED, 0.3f));
DrawSphereWires(lights[1].Position, 0.2f, 8, 8, ColorAlpha(Color.Red, 0.3f));
}
if (lights[2].Enabled)
{
DrawSphereEx(lights[2].Position, 0.2f, 8, 8, Color.GREEN);
DrawSphereEx(lights[2].Position, 0.2f, 8, 8, Color.Green);
}
else
{
DrawSphereWires(lights[2].Position, 0.2f, 8, 8, ColorAlpha(Color.GREEN, 0.3f));
DrawSphereWires(lights[2].Position, 0.2f, 8, 8, ColorAlpha(Color.Green, 0.3f));
}
if (lights[3].Enabled)
{
DrawSphereEx(lights[3].Position, 0.2f, 8, 8, Color.BLUE);
DrawSphereEx(lights[3].Position, 0.2f, 8, 8, Color.Blue);
}
else
{
DrawSphereWires(lights[3].Position, 0.2f, 8, 8, ColorAlpha(Color.BLUE, 0.3f));
DrawSphereWires(lights[3].Position, 0.2f, 8, 8, ColorAlpha(Color.Blue, 0.3f));
}
DrawGrid(10, 1.0f);
@ -204,7 +204,7 @@ public class BasicLighting
EndMode3D();
DrawFPS(10, 10);
DrawText("Use keys [Y][R][G][B] to toggle lights", 10, 40, 20, Color.DARKGRAY);
DrawText("Use keys [Y][R][G][B] to toggle lights", 10, 40, 20, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class CustomUniform
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable");
@ -41,13 +41,13 @@ public class CustomUniform
camera.Target = new Vector3(0.0f, 1.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Model model = LoadModel("resources/models/obj/barracks.obj");
Texture2D texture = LoadTexture("resources/models/obj/barracks_diffuse.png");
// Set model diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 position = new(0.0f, 0.0f, 0.0f);
@ -78,28 +78,28 @@ public class CustomUniform
swirlCenter[1] = screenHeight - mousePosition.Y;
// Send new value to the shader to be used on drawing
Raylib.SetShaderValue(shader, swirlCenterLoc, swirlCenter, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, swirlCenterLoc, swirlCenter, ShaderUniformDataType.Vec2);
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Enable drawing to texture
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, position, 0.5f, Color.WHITE);
DrawModel(model, position, 0.5f, Color.White);
DrawGrid(10, 1.0f);
EndMode3D();
DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, Color.RED);
DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, Color.Red);
// End drawing to texture (now we have a texture available for next passes)
EndTextureMode();
@ -111,7 +111,7 @@ public class CustomUniform
target.Texture,
new Rectangle(0, 0, target.Texture.Width, -target.Texture.Height),
new Vector2(0, 0),
Color.WHITE
Color.White
);
EndShaderMode();
@ -121,7 +121,7 @@ public class CustomUniform
screenWidth - 220,
screenHeight - 20,
10,
Color.GRAY
Color.Gray
);
DrawFPS(10, 10);

View File

@ -61,17 +61,17 @@ public class Eratosthenes
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Enable drawing to texture
BeginTextureMode(target);
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
// Draw a rectangle in shader mode to be used as shader canvas
// NOTE: Rectangle uses font white character texture coordinates,
// so shader can not be applied here directly because input vertexTexCoord
// do not represent full screen coordinates (space where want to apply shader)
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.BLACK);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.Black);
// End drawing to texture (now we have a blank texture available for the shader)
EndTextureMode();
@ -82,7 +82,7 @@ public class Eratosthenes
target.Texture,
new Rectangle(0, 0, target.Texture.Width, -target.Texture.Height),
new Vector2(0.0f, 0.0f),
Color.WHITE
Color.White
);
EndShaderMode();

View File

@ -42,7 +42,7 @@ public class Fog
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - fog");
// Define the camera to look into our 3d world
@ -51,7 +51,7 @@ public class Fog
camera.Target = new Vector3(0.0f, 0.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Load models and texture
Model modelA = LoadModelFromMesh(GenMeshTorus(0.4f, 1.0f, 16, 32));
@ -60,14 +60,14 @@ public class Fog
Texture2D texture = LoadTexture("resources/texel_checker.png");
// Assign texture to default model material
Raylib.SetMaterialTexture(ref modelA, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref modelB, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref modelC, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref modelA, 0, MaterialMapIndex.Albedo, ref texture);
Raylib.SetMaterialTexture(ref modelB, 0, MaterialMapIndex.Albedo, ref texture);
Raylib.SetMaterialTexture(ref modelC, 0, MaterialMapIndex.Albedo, ref texture);
// Load shader and set up some uniforms
Shader shader = LoadShader("resources/shaders/glsl330/lighting.vs", "resources/shaders/glsl330/fog.fs");
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(shader, "matModel");
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
shader.Locs[(int)ShaderLocationIndex.MatrixModel] = GetShaderLocation(shader, "matModel");
shader.Locs[(int)ShaderLocationIndex.VectorView] = GetShaderLocation(shader, "viewPos");
// Ambient light level
int ambientLoc = GetShaderLocation(shader, "ambient");
@ -75,12 +75,12 @@ public class Fog
shader,
ambientLoc,
new float[] { 0.2f, 0.2f, 0.2f, 1.0f },
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
float fogDensity = 0.15f;
int fogDensityLoc = GetShaderLocation(shader, "fogDensity");
Raylib.SetShaderValue(shader, fogDensityLoc, fogDensity, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, fogDensityLoc, fogDensity, ShaderUniformDataType.Float);
// NOTE: All models share the same shader
Raylib.SetMaterialShader(ref modelA, 0, ref shader);
@ -88,7 +88,7 @@ public class Fog
Raylib.SetMaterialShader(ref modelC, 0, ref shader);
// Using just 1 point lights
Rlights.CreateLight(0, LightType.Point, new Vector3(0, 2, 6), Vector3.Zero, Color.WHITE, shader);
Rlights.CreateLight(0, LightType.Point, new Vector3(0, 2, 6), Vector3.Zero, Color.White, shader);
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -98,9 +98,9 @@ public class Fog
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
if (IsKeyDown(KeyboardKey.KEY_UP))
if (IsKeyDown(KeyboardKey.Up))
{
fogDensity += 0.001f;
if (fogDensity > 1.0f)
@ -109,7 +109,7 @@ public class Fog
}
}
if (IsKeyDown(KeyboardKey.KEY_DOWN))
if (IsKeyDown(KeyboardKey.Down))
{
fogDensity -= 0.001f;
if (fogDensity < 0.0f)
@ -118,7 +118,7 @@ public class Fog
}
}
Raylib.SetShaderValue(shader, fogDensityLoc, fogDensity, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, fogDensityLoc, fogDensity, ShaderUniformDataType.Float);
// Rotate the torus
modelA.Transform = MatrixMultiply(modelA.Transform, MatrixRotateX(-0.025f));
@ -127,27 +127,27 @@ public class Fog
// Update the light shader with the camera view position
Raylib.SetShaderValue(
shader,
shader.Locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW],
shader.Locs[(int)ShaderLocationIndex.VectorView],
camera.Position,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
ShaderUniformDataType.Vec3
);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.GRAY);
ClearBackground(Color.Gray);
BeginMode3D(camera);
// Draw the three models
DrawModel(modelA, Vector3.Zero, 1.0f, Color.WHITE);
DrawModel(modelB, new Vector3(-2.6f, 0, 0), 1.0f, Color.WHITE);
DrawModel(modelC, new Vector3(2.6f, 0, 0), 1.0f, Color.WHITE);
DrawModel(modelA, Vector3.Zero, 1.0f, Color.White);
DrawModel(modelB, new Vector3(-2.6f, 0, 0), 1.0f, Color.White);
DrawModel(modelC, new Vector3(2.6f, 0, 0), 1.0f, Color.White);
for (int i = -20; i < 20; i += 2)
{
DrawModel(modelA, new Vector3(i, 0, 2), 1.0f, Color.WHITE);
DrawModel(modelA, new Vector3(i, 0, 2), 1.0f, Color.White);
}
EndMode3D();
@ -157,7 +157,7 @@ public class Fog
10,
10,
20,
Color.RAYWHITE
Color.RayWhite
);
EndDrawing();

View File

@ -41,7 +41,7 @@ public class HotReloading
int timeLoc = GetShaderLocation(shader, "time");
float[] resolution = new[] { (float)screenWidth, (float)screenHeight };
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.Vec2);
float totalTime = 0.0f;
bool shaderAutoReloading = false;
@ -59,11 +59,11 @@ public class HotReloading
float[] mousePos = new[] { mouse.X, mouse.Y };
// Set shader required uniform values
Raylib.SetShaderValue(shader, timeLoc, totalTime, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, mouseLoc, mousePos, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, timeLoc, totalTime, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, mouseLoc, mousePos, ShaderUniformDataType.Vec2);
// Hot shader reloading
if (shaderAutoReloading || (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)))
if (shaderAutoReloading || (IsMouseButtonPressed(MouseButton.Left)))
{
long currentFragShaderModTime = GetFileModTime(fragShaderFileName);
@ -89,7 +89,7 @@ public class HotReloading
shader,
resolutionLoc,
resolution,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
}
@ -97,7 +97,7 @@ public class HotReloading
}
}
if (IsKeyPressed(KeyboardKey.KEY_A))
if (IsKeyPressed(KeyboardKey.A))
{
shaderAutoReloading = !shaderAutoReloading;
}
@ -106,18 +106,18 @@ public class HotReloading
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// We only draw a white full-screen rectangle, frame is generated in shader
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.WHITE);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.White);
EndShaderMode();
string info = $"PRESS [A] to TOGGLE SHADER AUTOLOADING: {(shaderAutoReloading ? "AUTO" : "MANUAL")}";
DrawText(info, 10, 10, 10, shaderAutoReloading ? Color.RED : Color.BLACK);
DrawText(info, 10, 10, 10, shaderAutoReloading ? Color.Red : Color.Black);
if (!shaderAutoReloading)
{
DrawText("MOUSE CLICK to SHADER RE-LOADING", 10, 30, 10, Color.BLACK);
DrawText("MOUSE CLICK to SHADER RE-LOADING", 10, 30, 10, Color.Black);
}
// DrawText($"Shader last modification: ", 10, 430, 10, Color.BLACK);

View File

@ -60,7 +60,7 @@ public class HybridRender
shdrRaymarch,
marchLocs.ScreenCenter,
screenCenter,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
// Use customized function to create writable depth texture buffer
@ -72,7 +72,7 @@ public class HybridRender
camera.Target = new Vector3(0.0f, 0.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Camera FOV is pre-calculated in the camera Distance.
float camDist = 1.0f / (MathF.Tan(camera.FovY * 0.5f * Raylib.DEG2RAD));
@ -85,41 +85,41 @@ public class HybridRender
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
// Update Camera Postion in the ray march shader.
SetShaderValue(
shdrRaymarch,
marchLocs.CamPos,
camera.Position,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
ShaderUniformDataType.Vec3
);
// Update Camera Looking Vector. Vector length determines FOV.
Vector3 camDir = Vector3.Normalize(camera.Target - camera.Position) * camDist;
SetShaderValue(shdrRaymarch, marchLocs.CamDir, camDir, ShaderUniformDataType.SHADER_UNIFORM_VEC3);
SetShaderValue(shdrRaymarch, marchLocs.CamDir, camDir, ShaderUniformDataType.Vec3);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
// Draw into our custom render texture (framebuffer)
BeginTextureMode(target);
ClearBackground(Color.WHITE);
ClearBackground(Color.White);
// Raymarch Scene
// Manually enable Depth Test to handle multiple rendering methods.
Rlgl.EnableDepthTest();
BeginShaderMode(shdrRaymarch);
DrawRectangleRec(new Rectangle(0, 0, screenWidth, screenHeight), Color.WHITE);
DrawRectangleRec(new Rectangle(0, 0, screenWidth, screenHeight), Color.White);
EndShaderMode();
// Rasterize Scene
BeginMode3D(camera);
BeginShaderMode(shdrRaster);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.RED);
DrawCubeV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.PURPLE);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.DARKGREEN);
DrawCubeV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.YELLOW);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Red);
DrawCubeV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Purple);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.DarkGreen);
DrawCubeV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Yellow);
DrawGrid(10, 1.0f);
EndShaderMode();
EndMode3D();
@ -128,13 +128,13 @@ public class HybridRender
// Draw custom render texture
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTextureRec(
target.Texture,
new Rectangle(0, 0, screenWidth, -screenHeight),
Vector2.Zero,
Color.WHITE
Color.White
);
DrawFPS(10, 10);
@ -171,48 +171,48 @@ public class HybridRender
null,
width,
height,
PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
PixelFormat.UncompressedR8G8B8A8,
1
);
target.Texture.Width = width;
target.Texture.Height = height;
target.Texture.Format = PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
target.Texture.Format = PixelFormat.UncompressedR8G8B8A8;
target.Texture.Mipmaps = 1;
// Create depth texture buffer (instead of raylib default renderbuffer)
target.Depth.Id = Rlgl.LoadTextureDepth(width, height, false);
target.Depth.Width = width;
target.Depth.Height = height;
target.Depth.Format = PixelFormat.PIXELFORMAT_COMPRESSED_PVRT_RGBA;
target.Depth.Format = PixelFormat.CompressedPvrtRgba;
target.Depth.Mipmaps = 1;
// Attach color texture and depth texture to FBO
Rlgl.FramebufferAttach(
target.Id,
target.Texture.Id,
FramebufferAttachType.RL_ATTACHMENT_COLOR_CHANNEL0,
FramebufferAttachTextureType.RL_ATTACHMENT_TEXTURE2D,
FramebufferAttachType.ColorChannel0,
FramebufferAttachTextureType.Texture2D,
0
);
Rlgl.FramebufferAttach(
target.Id,
target.Depth.Id,
FramebufferAttachType.RL_ATTACHMENT_DEPTH,
FramebufferAttachTextureType.RL_ATTACHMENT_TEXTURE2D,
FramebufferAttachType.Depth,
FramebufferAttachTextureType.Texture2D,
0
);
// Check if fbo is complete with attachments (valid)
if (Rlgl.FramebufferComplete(target.Id))
{
TraceLog(TraceLogLevel.LOG_INFO, $"FBO: [ID {target.Id}] Framebuffer object created successfully");
TraceLog(TraceLogLevel.Info, $"FBO: [ID {target.Id}] Framebuffer object created successfully");
}
Rlgl.DisableFramebuffer();
}
else
{
TraceLog(TraceLogLevel.LOG_WARNING, "FBO: Framebuffer object can not be created");
TraceLog(TraceLogLevel.Warning, "FBO: Framebuffer object can not be created");
}
return target;

View File

@ -69,12 +69,12 @@ public class JuliaSet
shader,
GetShaderLocation(shader, "screenDims"),
screenDims,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, zoomLoc, zoomLoc, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, offsetLoc, offset, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.Vec2);
Raylib.SetShaderValue(shader, zoomLoc, zoomLoc, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, offsetLoc, offset, ShaderUniformDataType.Vec2);
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
@ -95,80 +95,80 @@ public class JuliaSet
// Update
//----------------------------------------------------------------------------------
// Press [1 - 6] to reset c to a point of interest
if (IsKeyPressed(KeyboardKey.KEY_ONE) ||
IsKeyPressed(KeyboardKey.KEY_TWO) ||
IsKeyPressed(KeyboardKey.KEY_THREE) ||
IsKeyPressed(KeyboardKey.KEY_FOUR) ||
IsKeyPressed(KeyboardKey.KEY_FIVE) ||
IsKeyPressed(KeyboardKey.KEY_SIX))
if (IsKeyPressed(KeyboardKey.One) ||
IsKeyPressed(KeyboardKey.Two) ||
IsKeyPressed(KeyboardKey.Three) ||
IsKeyPressed(KeyboardKey.Four) ||
IsKeyPressed(KeyboardKey.Five) ||
IsKeyPressed(KeyboardKey.Six))
{
if (IsKeyPressed(KeyboardKey.KEY_ONE))
if (IsKeyPressed(KeyboardKey.One))
{
c[0] = PointsOfInterest[0][0];
c[1] = PointsOfInterest[0][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_TWO))
else if (IsKeyPressed(KeyboardKey.Two))
{
c[0] = PointsOfInterest[1][0];
c[1] = PointsOfInterest[1][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_THREE))
else if (IsKeyPressed(KeyboardKey.Three))
{
c[0] = PointsOfInterest[2][0];
c[1] = PointsOfInterest[2][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_FOUR))
else if (IsKeyPressed(KeyboardKey.Four))
{
c[0] = PointsOfInterest[3][0];
c[1] = PointsOfInterest[3][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_FIVE))
else if (IsKeyPressed(KeyboardKey.Five))
{
c[0] = PointsOfInterest[4][0];
c[1] = PointsOfInterest[4][1];
}
else if (IsKeyPressed(KeyboardKey.KEY_SIX))
else if (IsKeyPressed(KeyboardKey.Six))
{
c[0] = PointsOfInterest[5][0];
c[1] = PointsOfInterest[5][1];
}
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.Vec2);
}
// Pause animation (c change)
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
pause = !pause;
}
// Toggle whether or not to show controls
if (IsKeyPressed(KeyboardKey.KEY_F1))
if (IsKeyPressed(KeyboardKey.F1))
{
showControls = !showControls;
}
if (!pause)
{
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
incrementSpeed++;
}
else if (IsKeyPressed(KeyboardKey.KEY_LEFT))
else if (IsKeyPressed(KeyboardKey.Left))
{
incrementSpeed--;
}
// TODO: The idea is to zoom and move around with mouse
// Probably offset movement should be proportional to zoom level
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON) || IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left) || IsMouseButtonDown(MouseButton.Right))
{
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left))
{
zoom += zoom * 0.003f;
}
if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON))
if (IsMouseButtonDown(MouseButton.Right))
{
zoom -= zoom * 0.003f;
}
@ -187,48 +187,48 @@ public class JuliaSet
offsetSpeed = new Vector2(0.0f, 0.0f);
}
Raylib.SetShaderValue(shader, zoomLoc, zoom, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, offsetLoc, offset, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, zoomLoc, zoom, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, offsetLoc, offset, ShaderUniformDataType.Vec2);
// Increment c value with time
float amount = GetFrameTime() * incrementSpeed * 0.0005f;
c[0] += amount;
c[1] += amount;
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, cLoc, c, ShaderUniformDataType.Vec2);
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
// Using a render texture to draw Julia set
// Enable drawing to texture
BeginTextureMode(target);
ClearBackground(Color.BLACK);
ClearBackground(Color.Black);
// Draw a rectangle in shader mode to be used as shader canvas
// NOTE: Rectangle uses font Color.white character texture coordinates,
// so shader can not be applied here directly because input vertexTexCoord
// do not represent full screen coordinates (space where want to apply shader)
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.BLACK);
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Color.Black);
EndTextureMode();
// Draw the saved texture and rendered julia set with shader
// NOTE: We do not invert texture on Y, already considered inside shader
BeginShaderMode(shader);
DrawTexture(target.Texture, 0, 0, Color.WHITE);
DrawTexture(target.Texture, 0, 0, Color.White);
EndShaderMode();
if (showControls)
{
DrawText("Press Mouse buttons right/left to zoom in/out and move", 10, 15, 10, Color.RAYWHITE);
DrawText("Press KEY_F1 to toggle these controls", 10, 30, 10, Color.RAYWHITE);
DrawText("Press KEYS [1 - 6] to change point of interest", 10, 45, 10, Color.RAYWHITE);
DrawText("Press KEY_LEFT | KEY_RIGHT to change speed", 10, 60, 10, Color.RAYWHITE);
DrawText("Press KEY_SPACE to pause movement animation", 10, 75, 10, Color.RAYWHITE);
DrawText("Press Mouse buttons right/left to zoom in/out and move", 10, 15, 10, Color.RayWhite);
DrawText("Press KEY_F1 to toggle these controls", 10, 30, 10, Color.RayWhite);
DrawText("Press KEYS [1 - 6] to change point of interest", 10, 45, 10, Color.RayWhite);
DrawText("Press KEY_LEFT | KEY_RIGHT to change speed", 10, 60, 10, Color.RayWhite);
DrawText("Press KEY_SPACE to pause movement animation", 10, 75, 10, Color.RayWhite);
}
EndDrawing();

View File

@ -30,7 +30,7 @@ public class MeshInstancing
const int fps = 60;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - rlgl mesh instanced");
// Speed of jump animation
@ -55,7 +55,7 @@ public class MeshInstancing
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Number of instances to display
const int instances = 10000;
@ -97,9 +97,9 @@ public class MeshInstancing
unsafe
{
int* locs = (int*)shader.Locs;
locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_MVP] = GetShaderLocation(shader, "mvp");
locs[(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(shader, "viewPos");
locs[(int)ShaderLocationIndex.SHADER_LOC_MATRIX_MODEL] = GetShaderLocationAttrib(
locs[(int)ShaderLocationIndex.MatrixMvp] = GetShaderLocation(shader, "mvp");
locs[(int)ShaderLocationIndex.VectorView] = GetShaderLocation(shader, "viewPos");
locs[(int)ShaderLocationIndex.MatrixModel] = GetShaderLocationAttrib(
shader,
"instanceTransform"
);
@ -111,7 +111,7 @@ public class MeshInstancing
shader,
ambientLoc,
new float[] { 0.2f, 0.2f, 0.2f, 1.0f },
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
Rlights.CreateLight(
@ -119,7 +119,7 @@ public class MeshInstancing
LightType.Directorional,
new Vector3(50, 50, 0),
Vector3.Zero,
Color.WHITE,
Color.White,
shader
);
@ -127,7 +127,7 @@ public class MeshInstancing
material.Shader = shader;
unsafe
{
material.Maps[(int)MaterialMapIndex.MATERIAL_MAP_DIFFUSE].Color = Color.RED;
material.Maps[(int)MaterialMapIndex.Diffuse].Color = Color.Red;
}
int textPositionY = 300;
@ -143,77 +143,77 @@ public class MeshInstancing
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
textPositionY = 300;
framesCounter += 1;
if (IsKeyDown(KeyboardKey.KEY_UP))
if (IsKeyDown(KeyboardKey.Up))
{
amp += 0.5f;
}
if (IsKeyDown(KeyboardKey.KEY_DOWN))
if (IsKeyDown(KeyboardKey.Down))
{
amp = (amp <= 1) ? 1.0f : (amp - 1.0f);
}
if (IsKeyDown(KeyboardKey.KEY_LEFT))
if (IsKeyDown(KeyboardKey.Left))
{
variance = (variance <= 0.0f) ? 0.0f : (variance - 0.01f);
}
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
variance = (variance >= 1.0f) ? 1.0f : (variance + 0.01f);
}
if (IsKeyDown(KeyboardKey.KEY_ONE))
if (IsKeyDown(KeyboardKey.One))
{
groups = 1;
}
if (IsKeyDown(KeyboardKey.KEY_TWO))
if (IsKeyDown(KeyboardKey.Two))
{
groups = 2;
}
if (IsKeyDown(KeyboardKey.KEY_THREE))
if (IsKeyDown(KeyboardKey.Three))
{
groups = 3;
}
if (IsKeyDown(KeyboardKey.KEY_FOUR))
if (IsKeyDown(KeyboardKey.Four))
{
groups = 4;
}
if (IsKeyDown(KeyboardKey.KEY_FIVE))
if (IsKeyDown(KeyboardKey.Five))
{
groups = 5;
}
if (IsKeyDown(KeyboardKey.KEY_SIX))
if (IsKeyDown(KeyboardKey.Six))
{
groups = 6;
}
if (IsKeyDown(KeyboardKey.KEY_SEVEN))
if (IsKeyDown(KeyboardKey.Seven))
{
groups = 7;
}
if (IsKeyDown(KeyboardKey.KEY_EIGHT))
if (IsKeyDown(KeyboardKey.Eight))
{
groups = 8;
}
if (IsKeyDown(KeyboardKey.KEY_NINE))
if (IsKeyDown(KeyboardKey.Nine))
{
groups = 9;
}
if (IsKeyDown(KeyboardKey.KEY_W))
if (IsKeyDown(KeyboardKey.W))
{
groups = 7;
amp = 25;
@ -221,22 +221,22 @@ public class MeshInstancing
variance = 0.70f;
}
if (IsKeyDown(KeyboardKey.KEY_EQUAL))
if (IsKeyDown(KeyboardKey.Equal))
{
speed = (speed <= (int)(fps * 0.25f)) ? (int)(fps * 0.25f) : (int)(speed * 0.95f);
}
if (IsKeyDown(KeyboardKey.KEY_KP_ADD))
if (IsKeyDown(KeyboardKey.KpAdd))
{
speed = (speed <= (int)(fps * 0.25f)) ? (int)(fps * 0.25f) : (int)(speed * 0.95f);
}
if (IsKeyDown(KeyboardKey.KEY_MINUS))
if (IsKeyDown(KeyboardKey.Minus))
{
speed = (int)MathF.Max(speed * 1.02f, speed + 1);
}
if (IsKeyDown(KeyboardKey.KEY_KP_SUBTRACT))
if (IsKeyDown(KeyboardKey.KpSubtract))
{
speed = (int)MathF.Max(speed * 1.02f, speed + 1);
}
@ -245,9 +245,9 @@ public class MeshInstancing
float[] cameraPos = { camera.Position.X, camera.Position.Y, camera.Position.Z };
Raylib.SetShaderValue(
shader,
(int)ShaderLocationIndex.SHADER_LOC_VECTOR_VIEW,
(int)ShaderLocationIndex.VectorView,
cameraPos,
ShaderUniformDataType.SHADER_UNIFORM_VEC3
ShaderUniformDataType.Vec3
);
// Apply per-instance transformations
@ -273,42 +273,42 @@ public class MeshInstancing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawMeshInstanced(cube, material, transforms, instances);
EndMode3D();
DrawText("A CUBE OF DANCING CUBES!", 490, 10, 20, Color.MAROON);
DrawText("PRESS KEYS:", 10, textPositionY, 20, Color.BLACK);
DrawText("A CUBE OF DANCING CUBES!", 490, 10, 20, Color.Maroon);
DrawText("PRESS KEYS:", 10, textPositionY, 20, Color.Black);
DrawText("1 - 9", 10, textPositionY += 25, 10, Color.BLACK);
DrawText(": Number of groups", 50, textPositionY, 10, Color.BLACK);
DrawText($": {groups}", 160, textPositionY, 10, Color.BLACK);
DrawText("1 - 9", 10, textPositionY += 25, 10, Color.Black);
DrawText(": Number of groups", 50, textPositionY, 10, Color.Black);
DrawText($": {groups}", 160, textPositionY, 10, Color.Black);
DrawText("UP", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": increase amplitude", 50, textPositionY, 10, Color.BLACK);
DrawText($": {amp}%.2f", 160, textPositionY, 10, Color.BLACK);
DrawText("UP", 10, textPositionY += 15, 10, Color.Black);
DrawText(": increase amplitude", 50, textPositionY, 10, Color.Black);
DrawText($": {amp}%.2f", 160, textPositionY, 10, Color.Black);
DrawText("DOWN", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": decrease amplitude", 50, textPositionY, 10, Color.BLACK);
DrawText("DOWN", 10, textPositionY += 15, 10, Color.Black);
DrawText(": decrease amplitude", 50, textPositionY, 10, Color.Black);
DrawText("LEFT", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": decrease variance", 50, textPositionY, 10, Color.BLACK);
DrawText($": {variance}.2f", 160, textPositionY, 10, Color.BLACK);
DrawText("LEFT", 10, textPositionY += 15, 10, Color.Black);
DrawText(": decrease variance", 50, textPositionY, 10, Color.Black);
DrawText($": {variance}.2f", 160, textPositionY, 10, Color.Black);
DrawText("RIGHT", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": increase variance", 50, textPositionY, 10, Color.BLACK);
DrawText("RIGHT", 10, textPositionY += 15, 10, Color.Black);
DrawText(": increase variance", 50, textPositionY, 10, Color.Black);
DrawText("+/=", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": increase speed", 50, textPositionY, 10, Color.BLACK);
DrawText($": {speed} = {((float)fps / speed)} loops/sec", 160, textPositionY, 10, Color.BLACK);
DrawText("+/=", 10, textPositionY += 15, 10, Color.Black);
DrawText(": increase speed", 50, textPositionY, 10, Color.Black);
DrawText($": {speed} = {((float)fps / speed)} loops/sec", 160, textPositionY, 10, Color.Black);
DrawText("-", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": decrease speed", 50, textPositionY, 10, Color.BLACK);
DrawText("-", 10, textPositionY += 15, 10, Color.Black);
DrawText(": decrease speed", 50, textPositionY, 10, Color.Black);
DrawText("W", 10, textPositionY += 15, 10, Color.BLACK);
DrawText(": Wild setup!", 50, textPositionY, 10, Color.BLACK);
DrawText("W", 10, textPositionY += 15, 10, Color.Black);
DrawText(": Wild setup!", 50, textPositionY, 10, Color.Black);
DrawFPS(10, 10);

View File

@ -31,7 +31,7 @@ public class ModelShader
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
@ -41,7 +41,7 @@ public class ModelShader
camera.Target = new Vector3(0.0f, 1.0f, -1.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Model model = LoadModel("resources/models/obj/watermill.obj");
Texture2D texture = LoadTexture("resources/models/obj/watermill_diffuse.png");
@ -49,7 +49,7 @@ public class ModelShader
"resources/shaders/glsl330/grayscale.fs");
Raylib.SetMaterialShader(ref model, 0, ref shader);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 position = new(0.0f, 0.0f, 0.0f);
@ -61,17 +61,17 @@ public class ModelShader
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, position, 0.2f, Color.WHITE);
DrawModel(model, position, 0.2f, Color.White);
DrawGrid(10, 1.0f);
@ -82,11 +82,11 @@ public class ModelShader
screenWidth - 210,
screenHeight - 20,
10,
Color.GRAY
Color.Gray
);
DrawText($"Camera3D position: ({camera.Position})", 600, 20, 10, Color.BLACK);
DrawText($"Camera3D target: ({camera.Position})", 600, 40, 10, Color.GRAY);
DrawText($"Camera3D position: ({camera.Position})", 600, 20, 10, Color.Black);
DrawText($"Camera3D target: ({camera.Position})", 600, 40, 10, Color.Gray);
DrawFPS(10, 10);

View File

@ -56,11 +56,11 @@ public class MultiSample2d
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
if (IsKeyDown(KeyboardKey.Right))
{
dividerValue += 0.01f;
}
else if (IsKeyDown(KeyboardKey.KEY_LEFT))
else if (IsKeyDown(KeyboardKey.Left))
{
dividerValue -= 0.01f;
}
@ -74,13 +74,13 @@ public class MultiSample2d
dividerValue = 1.0f;
}
Raylib.SetShaderValue(shader, dividerLoc, dividerValue, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, dividerLoc, dividerValue, ShaderUniformDataType.Float);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginShaderMode(shader);
@ -91,12 +91,12 @@ public class MultiSample2d
// We are drawing texRed using default sampler2D texture0 but
// an additional texture units is enabled for texBlue (sampler2D texture1)
DrawTexture(texRed, 0, 0, Color.WHITE);
DrawTexture(texRed, 0, 0, Color.White);
EndShaderMode();
int y = GetScreenHeight() - 40;
DrawText("Use KEY_LEFT/KEY_RIGHT to move texture mixing in shader!", 80, y, 20, Color.RAYWHITE);
DrawText("Use KEY_LEFT/KEY_RIGHT to move texture mixing in shader!", 80, y, 20, Color.RayWhite);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -99,11 +99,11 @@ public class PaletteSwitch
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
currentPalette++;
}
else if (IsKeyPressed(KeyboardKey.KEY_LEFT))
else if (IsKeyPressed(KeyboardKey.Left))
{
currentPalette--;
}
@ -123,7 +123,7 @@ public class PaletteSwitch
shader,
paletteLoc,
Palettes[currentPalette],
ShaderUniformDataType.SHADER_UNIFORM_IVEC3,
ShaderUniformDataType.IVec3,
ColorsPerPalette
);
//----------------------------------------------------------------------------------
@ -131,7 +131,7 @@ public class PaletteSwitch
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginShaderMode(shader);
@ -144,9 +144,9 @@ public class PaletteSwitch
EndShaderMode();
DrawText("< >", 10, 10, 30, Color.DARKBLUE);
DrawText("CURRENT PALETTE:", 60, 15, 20, Color.RAYWHITE);
DrawText(PaletteText[currentPalette], 300, 15, 20, Color.RED);
DrawText("< >", 10, 10, 30, Color.DarkBlue);
DrawText("CURRENT PALETTE:", 60, 15, 20, Color.RayWhite);
DrawText(PaletteText[currentPalette], 300, 15, 20, Color.Red);
DrawFPS(700, 15);

View File

@ -67,7 +67,7 @@ public class PostProcessing
const int screenHeight = 450;
// Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
// Define the camera to look into our 3d world
@ -76,13 +76,13 @@ public class PostProcessing
camera.Target = new Vector3(0.0f, 1.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
Model model = LoadModel("resources/models/obj/church.obj");
Texture2D texture = LoadTexture("resources/models/obj/church_diffuse.png");
// Set model diffuse texture
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.MATERIAL_MAP_ALBEDO, ref texture);
Raylib.SetMaterialTexture(ref model, 0, MaterialMapIndex.Albedo, ref texture);
Vector3 position = new(0.0f, 0.0f, 0.0f);
@ -119,13 +119,13 @@ public class PostProcessing
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
currentShader++;
}
else if (IsKeyPressed(KeyboardKey.KEY_LEFT))
else if (IsKeyPressed(KeyboardKey.Left))
{
currentShader--;
}
@ -143,15 +143,15 @@ public class PostProcessing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Enable drawing to texture
BeginTextureMode(target);
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginMode3D(camera);
DrawModel(model, position, 0.1f, Color.WHITE);
DrawModel(model, position, 0.1f, Color.White);
DrawGrid(10, 1.0f);
@ -168,18 +168,18 @@ public class PostProcessing
target.Texture,
new Rectangle(0, 0, target.Texture.Width, -target.Texture.Height),
new Vector2(0, 0),
Color.WHITE
Color.White
);
EndShaderMode();
DrawRectangle(0, 9, 580, 30, ColorAlpha(Color.LIGHTGRAY, 0.7f));
DrawRectangle(0, 9, 580, 30, ColorAlpha(Color.LightGray, 0.7f));
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, Color.GRAY);
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, Color.Gray);
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, Color.BLACK);
DrawText(postproShaderText[currentShader], 330, 15, 20, Color.RED);
DrawText("< >", 540, 10, 30, Color.DARKBLUE);
DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, Color.Black);
DrawText(postproShaderText[currentShader], 330, 15, 20, Color.Red);
DrawText("< >", 540, 10, 30, Color.DarkBlue);
DrawFPS(700, 15);

View File

@ -33,7 +33,7 @@ public class Raymarching
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
SetConfigFlags(ResizableWindow);
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - raymarching shapes");
Camera3D camera = new();
@ -53,7 +53,7 @@ public class Raymarching
int resolutionLoc = GetShaderLocation(shader, "resolution");
float[] resolution = { (float)screenWidth, (float)screenHeight };
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.Vec2);
float runTime = 0.0f;
@ -70,31 +70,31 @@ public class Raymarching
screenWidth = GetScreenWidth();
screenHeight = GetScreenHeight();
resolution = new float[] { (float)screenWidth, (float)screenHeight };
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.SHADER_UNIFORM_VEC2);
Raylib.SetShaderValue(shader, resolutionLoc, resolution, ShaderUniformDataType.Vec2);
}
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_FREE);
UpdateCamera(ref camera, CameraMode.Free);
float deltaTime = GetFrameTime();
runTime += deltaTime;
// Set shader required uniform values
Raylib.SetShaderValue(shader, viewEyeLoc, camera.Position, ShaderUniformDataType.SHADER_UNIFORM_VEC3);
Raylib.SetShaderValue(shader, viewCenterLoc, camera.Target, ShaderUniformDataType.SHADER_UNIFORM_VEC3);
Raylib.SetShaderValue(shader, runTimeLoc, runTime, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, viewEyeLoc, camera.Position, ShaderUniformDataType.Vec3);
Raylib.SetShaderValue(shader, viewCenterLoc, camera.Target, ShaderUniformDataType.Vec3);
Raylib.SetShaderValue(shader, runTimeLoc, runTime, ShaderUniformDataType.Float);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// We only draw a white full-screen rectangle,
// frame is generated in shader using raymarching
BeginShaderMode(shader);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.WHITE);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.White);
EndShaderMode();
DrawText(
@ -102,7 +102,7 @@ public class Raymarching
screenWidth - 280,
screenHeight - 20,
10,
Color.BLACK
Color.Black
);
EndDrawing();

View File

@ -54,54 +54,54 @@ public class ShapesTextures
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Start drawing with default shader
DrawText("USING DEFAULT SHADER", 20, 40, 10, Color.RED);
DrawText("USING DEFAULT SHADER", 20, 40, 10, Color.Red);
DrawCircle(80, 120, 35, Color.DARKBLUE);
DrawCircleGradient(80, 220, 60, Color.GREEN, Color.SKYBLUE);
DrawCircleLines(80, 340, 80, Color.DARKBLUE);
DrawCircle(80, 120, 35, Color.DarkBlue);
DrawCircleGradient(80, 220, 60, Color.Green, Color.SkyBlue);
DrawCircleLines(80, 340, 80, Color.DarkBlue);
// Activate our custom shader to be applied on next shapes/textures drawings
BeginShaderMode(shader);
DrawText("USING CUSTOM SHADER", 190, 40, 10, Color.RED);
DrawText("USING CUSTOM SHADER", 190, 40, 10, Color.Red);
DrawRectangle(250 - 60, 90, 120, 60, Color.RED);
DrawRectangleGradientH(250 - 90, 170, 180, 130, Color.MAROON, Color.GOLD);
DrawRectangleLines(250 - 40, 320, 80, 60, Color.ORANGE);
DrawRectangle(250 - 60, 90, 120, 60, Color.Red);
DrawRectangleGradientH(250 - 90, 170, 180, 130, Color.Maroon, Color.Gold);
DrawRectangleLines(250 - 40, 320, 80, 60, Color.Orange);
// Activate our default shader for next drawings
EndShaderMode();
DrawText("USING DEFAULT SHADER", 370, 40, 10, Color.RED);
DrawText("USING DEFAULT SHADER", 370, 40, 10, Color.Red);
DrawTriangle(
new Vector2(430, 80),
new Vector2(430 - 60, 150),
new Vector2(430 + 60, 150), Color.VIOLET
new Vector2(430 + 60, 150), Color.Violet
);
DrawTriangleLines(
new Vector2(430, 160),
new Vector2(430 - 20, 230),
new Vector2(430 + 20, 230), Color.DARKBLUE
new Vector2(430 + 20, 230), Color.DarkBlue
);
DrawPoly(new Vector2(430, 320), 6, 80, 0, Color.BROWN);
DrawPoly(new Vector2(430, 320), 6, 80, 0, Color.Brown);
// Activate our custom shader to be applied on next shapes/textures drawings
BeginShaderMode(shader);
// Using custom shader
DrawTexture(fudesumi, 500, -30, Color.WHITE);
DrawTexture(fudesumi, 500, -30, Color.White);
// Activate our default shader for next drawings
EndShaderMode();
DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, Color.GRAY);
DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -41,7 +41,7 @@ public class SimpleMask
camera.Target = new Vector3(0.0f, 0.0f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
// Define our three models to show the shader on
Mesh torus = GenMeshTorus(.3f, 1, 16, 32);
@ -62,11 +62,11 @@ public class SimpleMask
Material* materials = model1.Materials;
MaterialMap* maps = materials[0].Maps;
model1.Materials[0].Maps[(int)MaterialMapIndex.MATERIAL_MAP_ALBEDO].Texture = texDiffuse;
model1.Materials[0].Maps[(int)MaterialMapIndex.Albedo].Texture = texDiffuse;
materials = model2.Materials;
maps = materials[0].Maps;
maps[(int)MaterialMapIndex.MATERIAL_MAP_ALBEDO].Texture = texDiffuse;
maps[(int)MaterialMapIndex.Albedo].Texture = texDiffuse;
// Using MAP_EMISSION as a spare slot to use for 2nd texture
// NOTE: Don't use MAP_IRRADIANCE, MAP_PREFILTER or MAP_CUBEMAP
@ -75,14 +75,14 @@ public class SimpleMask
materials = model1.Materials;
maps = (MaterialMap*)materials[0].Maps;
maps[(int)MaterialMapIndex.MATERIAL_MAP_EMISSION].Texture = texMask;
maps[(int)MaterialMapIndex.Emission].Texture = texMask;
materials = model2.Materials;
maps = (MaterialMap*)materials[0].Maps;
maps[(int)MaterialMapIndex.MATERIAL_MAP_EMISSION].Texture = texMask;
maps[(int)MaterialMapIndex.Emission].Texture = texMask;
int* locs = shader.Locs;
locs[(int)ShaderLocationIndex.SHADER_LOC_MAP_EMISSION] = GetShaderLocation(shader, "mask");
locs[(int)ShaderLocationIndex.MapEmission] = GetShaderLocation(shader, "mask");
// Frame is incremented each frame to animate the shader
int shaderFrame = GetShaderLocation(shader, "framesCounter");
@ -113,31 +113,31 @@ public class SimpleMask
rotation.Z -= 0.0025f;
// Send frames counter to shader for animation
Raylib.SetShaderValue(shader, shaderFrame, framesCounter, ShaderUniformDataType.SHADER_UNIFORM_INT);
Raylib.SetShaderValue(shader, shaderFrame, framesCounter, ShaderUniformDataType.Int);
// Rotate one of the models
model1.Transform = MatrixRotateXYZ(rotation);
UpdateCamera(ref camera, CameraMode.CAMERA_CUSTOM);
UpdateCamera(ref camera, CameraMode.Custom);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.DARKBLUE);
ClearBackground(Color.DarkBlue);
BeginMode3D(camera);
DrawModel(model1, new Vector3(0.5f, 0, 0), 1, Color.WHITE);
DrawModelEx(model2, new Vector3(-.5f, 0, 0), new Vector3(1, 1, 0), 50, new Vector3(1, 1, 1), Color.WHITE);
DrawModel(model3, new Vector3(0, 0, -1.5f), 1, Color.WHITE);
DrawModel(model1, new Vector3(0.5f, 0, 0), 1, Color.White);
DrawModelEx(model2, new Vector3(-.5f, 0, 0), new Vector3(1, 1, 0), 50, new Vector3(1, 1, 1), Color.White);
DrawModel(model3, new Vector3(0, 0, -1.5f), 1, Color.White);
DrawGrid(10, 1.0f);
EndMode3D();
string frameText = $"Frame: {framesCounter}";
DrawRectangle(16, 698, MeasureText(frameText, 20) + 8, 42, Color.BLUE);
DrawText(frameText, 20, 700, 20, Color.WHITE);
DrawRectangle(16, 698, MeasureText(frameText, 20) + 8, 42, Color.Blue);
DrawText(frameText, 20, 700, 20, Color.White);
DrawFPS(10, 10);

View File

@ -111,7 +111,7 @@ public class Spotlight
// a pitch Color.black half and a dimly lit half.
int wLoc = GetShaderLocation(shdrSpot, "screenWidth");
float sw = (float)GetScreenWidth();
Raylib.SetShaderValue(shdrSpot, wLoc, sw, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shdrSpot, wLoc, sw, ShaderUniformDataType.Float);
// Randomise the locations and velocities of the spotlights
// and initialise the shader locations
@ -134,19 +134,19 @@ public class Spotlight
shdrSpot,
spots[i].posLoc,
spots[i].pos,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(
shdrSpot,
spots[i].innerLoc,
spots[i].inner,
ShaderUniformDataType.SHADER_UNIFORM_FLOAT
ShaderUniformDataType.Float
);
Raylib.SetShaderValue(
shdrSpot,
spots[i].radiusLoc,
spots[i].radius,
ShaderUniformDataType.SHADER_UNIFORM_FLOAT
ShaderUniformDataType.Float
);
}
@ -205,20 +205,20 @@ public class Spotlight
shdrSpot,
spots[i].posLoc,
spots[i].pos,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
}
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.DARKBLUE);
ClearBackground(Color.DarkBlue);
// Draw stars and bobs
for (int n = 0; n < MaxStars; n++)
{
// MathF.Single pixel is just too small these days!
DrawRectangle((int)stars[n].pos.X, (int)stars[n].pos.Y, 2, 2, Color.WHITE);
DrawRectangle((int)stars[n].pos.X, (int)stars[n].pos.Y, 2, 2, Color.White);
}
for (int i = 0; i < 16; i++)
@ -227,7 +227,7 @@ public class Spotlight
texRay,
(int)((screenWidth / 2.0) + MathF.Cos((frameCounter + i * 8) / 51.45f) * (screenWidth / 2.2) - 32),
(int)((screenHeight / 2.0) + MathF.Sin((frameCounter + i * 8) / 17.87f) * (screenHeight / 4.2)),
Color.WHITE
Color.White
);
}
@ -236,14 +236,14 @@ public class Spotlight
// Instead of a blank rectangle you could render a render texture of the full screen used to do screen
// scaling (slight adjustment to shader would be required to actually pay attention to the colour!)
DrawRectangle(0, 0, screenWidth, screenHeight, Color.WHITE);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.White);
EndShaderMode();
DrawFPS(10, 10);
DrawText("Move the mouse!", 10, 30, 20, Color.GREEN);
DrawText("Pitch Color.Black", (int)(screenWidth * 0.2f), screenHeight / 2, 20, Color.GREEN);
DrawText("Dark", (int)(screenWidth * 0.66f), screenHeight / 2, 20, Color.GREEN);
DrawText("Move the mouse!", 10, 30, 20, Color.Green);
DrawText("Pitch Color.Black", (int)(screenWidth * 0.2f), screenHeight / 2, 20, Color.Green);
DrawText("Dark", (int)(screenWidth * 0.66f), screenHeight / 2, 20, Color.Green);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ public class TextureDrawing
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");
// Load blank texture to fill on shader
Image imBlank = GenImageColor(1024, 1024, Color.BLANK);
Image imBlank = GenImageColor(1024, 1024, Color.Blank);
Texture2D texture = LoadTextureFromImage(imBlank);
UnloadImage(imBlank);
@ -40,7 +40,7 @@ public class TextureDrawing
float time = 0.0f;
int timeLoc = GetShaderLocation(shader, "uTime");
Raylib.SetShaderValue(shader, timeLoc, time, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, timeLoc, time, ShaderUniformDataType.Float);
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -51,24 +51,24 @@ public class TextureDrawing
// Update
//----------------------------------------------------------------------------------
time = (float)GetTime();
Raylib.SetShaderValue(shader, timeLoc, time, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, timeLoc, time, ShaderUniformDataType.Float);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Enable our custom shader for next shapes/textures drawings
BeginShaderMode(shader);
// Drawing blank texture, all magic happens on shader
DrawTexture(texture, 0, 0, Color.WHITE);
DrawTexture(texture, 0, 0, Color.White);
// Disable our custom shader, return to default shader
EndShaderMode();
DrawText("BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, Color.MAROON);
DrawText("BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, Color.Maroon);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -49,19 +49,19 @@ public class TextureOutline
shdrOutline,
outlineSizeLoc,
outlineSize,
ShaderUniformDataType.SHADER_UNIFORM_FLOAT
ShaderUniformDataType.Float
);
Raylib.SetShaderValue(
shdrOutline,
outlineColorLoc,
outlineColor,
ShaderUniformDataType.SHADER_UNIFORM_VEC4
ShaderUniformDataType.Vec4
);
Raylib.SetShaderValue(
shdrOutline,
textureSizeLoc,
textureSize,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
SetTargetFPS(60);
@ -82,7 +82,7 @@ public class TextureOutline
shdrOutline,
outlineSizeLoc,
outlineSize,
ShaderUniformDataType.SHADER_UNIFORM_FLOAT
ShaderUniformDataType.Float
);
//----------------------------------------------------------------------------------
@ -90,15 +90,15 @@ public class TextureOutline
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginShaderMode(shdrOutline);
DrawTexture(texture, GetScreenWidth() / 2 - texture.Width / 2, -30, Color.WHITE);
DrawTexture(texture, GetScreenWidth() / 2 - texture.Width / 2, -30, Color.White);
EndShaderMode();
DrawText("Shader-based\ntexture\noutline", 10, 10, 20, Color.GRAY);
DrawText("Shader-based\ntexture\noutline", 10, 10, 20, Color.Gray);
DrawText($"Outline size: {outlineSize} px", 10, 120, 20, Color.MAROON);
DrawText($"Outline size: {outlineSize} px", 10, 120, 20, Color.Maroon);
DrawFPS(710, 10);

View File

@ -62,14 +62,14 @@ public class TextureWaves
shader,
GetShaderLocation(shader, "size"),
screenSize,
ShaderUniformDataType.SHADER_UNIFORM_VEC2
ShaderUniformDataType.Vec2
);
Raylib.SetShaderValue(shader, freqXLoc, freqX, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, freqYLoc, freqY, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, ampXLoc, ampX, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, ampYLoc, ampY, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, speedXLoc, speedX, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, speedYLoc, speedY, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, freqXLoc, freqX, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, freqYLoc, freqY, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, ampXLoc, ampX, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, ampYLoc, ampY, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, speedXLoc, speedX, ShaderUniformDataType.Float);
Raylib.SetShaderValue(shader, speedYLoc, speedY, ShaderUniformDataType.Float);
float seconds = 0.0f;
@ -83,18 +83,18 @@ public class TextureWaves
//----------------------------------------------------------------------------------
seconds += GetFrameTime();
Raylib.SetShaderValue(shader, secondsLoc, seconds, ShaderUniformDataType.SHADER_UNIFORM_FLOAT);
Raylib.SetShaderValue(shader, secondsLoc, seconds, ShaderUniformDataType.Float);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
BeginShaderMode(shader);
DrawTexture(texture, 0, 0, Color.WHITE);
DrawTexture(texture, texture.Width, 0, Color.WHITE);
DrawTexture(texture, 0, 0, Color.White);
DrawTexture(texture, texture.Width, 0, Color.White);
EndShaderMode();

View File

@ -43,27 +43,27 @@ public class WriteDepth
camera.Target = new Vector3(0.0f, 0.5f, 0.0f);
camera.Up = new Vector3(0.0f, 1.0f, 0.0f);
camera.FovY = 45.0f;
camera.Projection = CameraProjection.CAMERA_PERSPECTIVE;
camera.Projection = CameraProjection.Perspective;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
UpdateCamera(ref camera, CameraMode.CAMERA_ORBITAL);
UpdateCamera(ref camera, CameraMode.Orbital);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
// Draw into our custom render texture (framebuffer)
BeginTextureMode(target);
ClearBackground(Color.WHITE);
ClearBackground(Color.White);
BeginMode3D(camera);
BeginShaderMode(shader);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.RED);
DrawCubeV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.PURPLE);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.DARKGREEN);
DrawCubeV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.YELLOW);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Red);
DrawCubeV(new Vector3(0.0f, 0.5f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Purple);
DrawCubeWiresV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.DarkGreen);
DrawCubeV(new Vector3(0.0f, 0.5f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), Color.Yellow);
DrawGrid(10, 1.0f);
EndShaderMode();
@ -72,13 +72,13 @@ public class WriteDepth
// Draw custom render texture
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTextureRec(
target.Texture,
new Rectangle(0, 0, screenWidth, -screenHeight),
Vector2.Zero,
Color.WHITE
Color.White
);
DrawFPS(10, 10);
@ -113,48 +113,48 @@ public class WriteDepth
null,
width,
height,
PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
PixelFormat.UncompressedR8G8B8A8,
1
);
target.Texture.Width = width;
target.Texture.Height = height;
target.Texture.Format = PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
target.Texture.Format = PixelFormat.UncompressedR8G8B8A8;
target.Texture.Mipmaps = 1;
// Create depth texture buffer (instead of raylib default renderbuffer)
target.Depth.Id = Rlgl.LoadTextureDepth(width, height, false);
target.Depth.Width = width;
target.Depth.Height = height;
target.Depth.Format = PixelFormat.PIXELFORMAT_COMPRESSED_PVRT_RGBA;
target.Depth.Format = PixelFormat.CompressedPvrtRgba;
target.Depth.Mipmaps = 1;
// Attach color texture and depth texture to FBO
Rlgl.FramebufferAttach(
target.Id,
target.Texture.Id,
FramebufferAttachType.RL_ATTACHMENT_COLOR_CHANNEL0,
FramebufferAttachTextureType.RL_ATTACHMENT_TEXTURE2D,
FramebufferAttachType.ColorChannel0,
FramebufferAttachTextureType.Texture2D,
0
);
Rlgl.FramebufferAttach(
target.Id,
target.Depth.Id,
FramebufferAttachType.RL_ATTACHMENT_DEPTH,
FramebufferAttachTextureType.RL_ATTACHMENT_TEXTURE2D,
FramebufferAttachType.Depth,
FramebufferAttachTextureType.Texture2D,
0
);
// Check if fbo is complete with attachments (valid)
if (Rlgl.FramebufferComplete(target.Id))
{
TraceLog(TraceLogLevel.LOG_INFO, $"FBO: [ID {target.Id}] Framebuffer object created successfully");
TraceLog(TraceLogLevel.Info, $"FBO: [ID {target.Id}] Framebuffer object created successfully");
}
Rlgl.DisableFramebuffer();
}
else
{
TraceLog(TraceLogLevel.LOG_WARNING, "FBO: Framebuffer object can not be created");
TraceLog(TraceLogLevel.Warning, "FBO: Framebuffer object can not be created");
}
return target;

View File

@ -39,33 +39,33 @@ public class BasicShapes
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("some basic shapes available on raylib", 20, 20, 20, Color.DARKGRAY);
DrawText("some basic shapes available on raylib", 20, 20, 20, Color.DarkGray);
DrawLine(18, 42, screenWidth - 18, 42, Color.BLACK);
DrawLine(18, 42, screenWidth - 18, 42, Color.Black);
DrawCircle(screenWidth / 4, 120, 35, Color.DARKBLUE);
DrawCircleGradient(screenWidth / 4, 220, 60, Color.GREEN, Color.SKYBLUE);
DrawCircleLines(screenWidth / 4, 340, 80, Color.DARKBLUE);
DrawCircle(screenWidth / 4, 120, 35, Color.DarkBlue);
DrawCircleGradient(screenWidth / 4, 220, 60, Color.Green, Color.SkyBlue);
DrawCircleLines(screenWidth / 4, 340, 80, Color.DarkBlue);
DrawRectangle(screenWidth / 4 * 2 - 60, 100, 120, 60, Color.RED);
DrawRectangleGradientH(screenWidth / 4 * 2 - 90, 170, 180, 130, Color.MAROON, Color.GOLD);
DrawRectangleLines(screenWidth / 4 * 2 - 40, 320, 80, 60, Color.ORANGE);
DrawRectangle(screenWidth / 4 * 2 - 60, 100, 120, 60, Color.Red);
DrawRectangleGradientH(screenWidth / 4 * 2 - 90, 170, 180, 130, Color.Maroon, Color.Gold);
DrawRectangleLines(screenWidth / 4 * 2 - 40, 320, 80, 60, Color.Orange);
DrawTriangle(
new Vector2(screenWidth / 4 * 3, 80),
new Vector2(screenWidth / 4 * 3 - 60, 150),
new Vector2(screenWidth / 4 * 3 + 60, 150), Color.VIOLET
new Vector2(screenWidth / 4 * 3 + 60, 150), Color.Violet
);
DrawTriangleLines(
new Vector2(screenWidth / 4 * 3, 160),
new Vector2(screenWidth / 4 * 3 - 20, 230),
new Vector2(screenWidth / 4 * 3 + 20, 230), Color.DARKBLUE
new Vector2(screenWidth / 4 * 3 + 20, 230), Color.DarkBlue
);
DrawPoly(new Vector2(screenWidth / 4 * 3, 320), 6, 80, 0, Color.BROWN);
DrawPoly(new Vector2(screenWidth / 4 * 3, 320), 6, 80, 0, Color.Brown);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -40,7 +40,7 @@ public class BouncingBall
{
// Update
//-----------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
pause = !pause;
}
@ -69,15 +69,15 @@ public class BouncingBall
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawCircleV(ballPosition, ballRadius, Color.MAROON);
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, Color.LIGHTGRAY);
DrawCircleV(ballPosition, ballRadius, Color.Maroon);
DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, Color.LightGray);
// On pause, we draw a blinking message
if (pause && ((framesCounter / 30) % 2) == 0)
{
DrawText("PAUSED", 350, 200, 30, Color.GRAY);
DrawText("PAUSED", 350, 200, 30, Color.Gray);
}
DrawFPS(10, 10);

View File

@ -91,7 +91,7 @@ public class CollisionArea
}
// Pause Box A movement
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
pause = !pause;
}
@ -100,26 +100,26 @@ public class CollisionArea
// Draw
//-----------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawRectangle(0, 0, screenWidth, screenUpperLimit, collision ? Color.RED : Color.BLACK);
DrawRectangle(0, 0, screenWidth, screenUpperLimit, collision ? Color.Red : Color.Black);
DrawRectangleRec(boxA, Color.GOLD);
DrawRectangleRec(boxB, Color.BLUE);
DrawRectangleRec(boxA, Color.Gold);
DrawRectangleRec(boxB, Color.Blue);
if (collision)
{
// Draw collision area
DrawRectangleRec(boxCollision, Color.LIME);
DrawRectangleRec(boxCollision, Color.Lime);
// Draw collision message
int cx = GetScreenWidth() / 2 - MeasureText("COLLISION!", 20) / 2;
int cy = screenUpperLimit / 2 - 10;
DrawText("COLLISION!", cx, cy, 20, Color.BLACK);
DrawText("COLLISION!", cx, cy, 20, Color.Black);
// Draw collision area
string text = $"Collision Area: {(int)boxCollision.Width * (int)boxCollision.Height}";
DrawText(text, GetScreenWidth() / 2 - 100, screenUpperLimit + 10, 20, Color.BLACK);
DrawText(text, GetScreenWidth() / 2 - 100, screenUpperLimit + 10, 20, Color.Black);
}
DrawFPS(10, 10);

View File

@ -27,27 +27,27 @@ public class ColorsPalette
Color[] colors = new[]
{
Color.DARKGRAY,
Color.MAROON,
Color.ORANGE,
Color.DARKGREEN,
Color.DARKBLUE,
Color.DARKPURPLE,
Color.DARKBROWN,
Color.GRAY,
Color.RED,
Color.GOLD,
Color.LIME,
Color.BLUE,
Color.VIOLET,
Color.BROWN,
Color.LIGHTGRAY,
Color.PINK,
Color.YELLOW,
Color.GREEN,
Color.SKYBLUE,
Color.PURPLE,
Color.BEIGE
Color.DarkGray,
Color.Maroon,
Color.Orange,
Color.DarkGreen,
Color.DarkBlue,
Color.DarkPurple,
Color.DarkBrown,
Color.Gray,
Color.Red,
Color.Gold,
Color.Lime,
Color.Blue,
Color.Violet,
Color.Brown,
Color.LightGray,
Color.Pink,
Color.Yellow,
Color.Green,
Color.SkyBlue,
Color.Purple,
Color.Beige
};
string[] colorNames = new[]
@ -118,15 +118,15 @@ public class ColorsPalette
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("raylib colors palette", 28, 42, 20, Color.BLACK);
DrawText("raylib colors palette", 28, 42, 20, Color.Black);
DrawText(
"press SPACE to see all colors",
GetScreenWidth() - 180,
GetScreenHeight() - 40,
10,
Color.GRAY
Color.Gray
);
// Draw all rectangles
@ -134,16 +134,16 @@ public class ColorsPalette
{
DrawRectangleRec(colorsRecs[i], ColorAlpha(colors[i], colorState[i] != 0 ? 0.6f : 1.0f));
if (IsKeyDown(KeyboardKey.KEY_SPACE) || colorState[i] != 0)
if (IsKeyDown(KeyboardKey.Space) || colorState[i] != 0)
{
DrawRectangle(
(int)colorsRecs[i].X,
(int)(colorsRecs[i].Y + colorsRecs[i].Height - 26),
(int)colorsRecs[i].Width,
20,
Color.BLACK
Color.Black
);
DrawRectangleLinesEx(colorsRecs[i], 6, ColorAlpha(Color.BLACK, 0.3f));
DrawRectangleLinesEx(colorsRecs[i], 6, ColorAlpha(Color.Black, 0.3f));
DrawText(
colorNames[i],
(int)(colorsRecs[i].X + colorsRecs[i].Width - MeasureText(colorNames[i], 10) - 12),

View File

@ -50,19 +50,19 @@ public class DrawCircleSector
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawLine(500, 0, 500, GetScreenHeight(), ColorAlpha(Color.LIGHTGRAY, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), ColorAlpha(Color.LIGHTGRAY, 0.3f));
DrawLine(500, 0, 500, GetScreenHeight(), ColorAlpha(Color.LightGray, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), ColorAlpha(Color.LightGray, 0.3f));
DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, ColorAlpha(Color.MAROON, 0.3f));
DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, ColorAlpha(Color.Maroon, 0.3f));
DrawCircleSectorLines(
center,
outerRadius,
startAngle,
endAngle,
segments,
ColorAlpha(Color.MAROON, 0.6f)
ColorAlpha(Color.Maroon, 0.6f)
);
// Draw GUI controls
@ -75,7 +75,7 @@ public class DrawCircleSector
//------------------------------------------------------------------------------
minSegments = (int)MathF.Ceiling((endAngle - startAngle) / 90);
Color color = (segments >= minSegments) ? Color.MAROON : Color.DARKGRAY;
Color color = (segments >= minSegments) ? Color.Maroon : Color.DarkGray;
DrawText($"MODE: {((segments >= minSegments) ? "MANUAL" : "AUTO")}", 600, 270, 10, color);
DrawFPS(10, 10);

View File

@ -55,22 +55,22 @@ public class DrawRectangleRounded
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawLine(560, 0, 560, GetScreenHeight(), ColorAlpha(Color.LIGHTGRAY, 0.6f));
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), ColorAlpha(Color.LIGHTGRAY, 0.3f));
DrawLine(560, 0, 560, GetScreenHeight(), ColorAlpha(Color.LightGray, 0.6f));
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), ColorAlpha(Color.LightGray, 0.3f));
if (drawRect)
{
DrawRectangleRec(rec, ColorAlpha(Color.GOLD, 0.6f));
DrawRectangleRec(rec, ColorAlpha(Color.Gold, 0.6f));
}
if (drawRoundedRect)
{
DrawRectangleRounded(rec, roundness, segments, ColorAlpha(Color.MAROON, 0.2f));
DrawRectangleRounded(rec, roundness, segments, ColorAlpha(Color.Maroon, 0.2f));
}
if (drawRoundedLines)
{
DrawRectangleRoundedLines(rec, roundness, segments, (float)lineThick, ColorAlpha(Color.MAROON, 0.4f));
DrawRectangleRoundedLines(rec, roundness, segments, (float)lineThick, ColorAlpha(Color.Maroon, 0.4f));
}
// Draw GUI controls
@ -87,7 +87,7 @@ public class DrawRectangleRounded
//------------------------------------------------------------------------------
string text = $"MODE: {((segments >= 4) ? "MANUAL" : "AUTO")}";
DrawText(text, 640, 280, 10, (segments >= 4) ? Color.MAROON : Color.DARKGRAY);
DrawText(text, 640, 280, 10, (segments >= 4) ? Color.Maroon : Color.DarkGray);
DrawFPS(10, 10);
EndDrawing();

View File

@ -56,10 +56,10 @@ public class DrawRing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawLine(500, 0, 500, GetScreenHeight(), ColorAlpha(Color.LIGHTGRAY, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), ColorAlpha(Color.LIGHTGRAY, 0.3f));
DrawLine(500, 0, 500, GetScreenHeight(), ColorAlpha(Color.LightGray, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), ColorAlpha(Color.LightGray, 0.3f));
if (drawRing)
{
@ -70,7 +70,7 @@ public class DrawRing
startAngle,
endAngle,
segments,
ColorAlpha(Color.MAROON, 0.3f)
ColorAlpha(Color.Maroon, 0.3f)
);
}
if (drawRingLines)
@ -82,7 +82,7 @@ public class DrawRing
startAngle,
endAngle,
segments,
ColorAlpha(Color.BLACK, 0.4f)
ColorAlpha(Color.Black, 0.4f)
);
}
if (drawCircleLines)
@ -93,7 +93,7 @@ public class DrawRing
startAngle,
endAngle,
segments,
ColorAlpha(Color.BLACK, 0.4f)
ColorAlpha(Color.Black, 0.4f)
);
}
@ -113,7 +113,7 @@ public class DrawRing
//------------------------------------------------------------------------------
minSegments = (int)MathF.Ceiling((endAngle - startAngle) / 90);
Color color = (segments >= minSegments) ? Color.MAROON : Color.DARKGRAY;
Color color = (segments >= minSegments) ? Color.Maroon : Color.DarkGray;
DrawText($"MODE: {((segments >= minSegments) ? "MANUAL" : "AUTO")}", 600, 270, 10, color);
DrawFPS(10, 10);

View File

@ -79,7 +79,7 @@ public class EasingsBallAnim
// Reset state to play again
else if (state == 3)
{
if (IsKeyPressed(KeyboardKey.KEY_ENTER))
if (IsKeyPressed(KeyboardKey.Enter))
{
// Reset required variables to play again
ballPositionX = -100;
@ -89,7 +89,7 @@ public class EasingsBallAnim
}
}
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
framesCounter = 0;
}
@ -98,18 +98,18 @@ public class EasingsBallAnim
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (state >= 2)
{
DrawRectangle(0, 0, screenWidth, screenHeight, Color.GREEN);
DrawRectangle(0, 0, screenWidth, screenHeight, Color.Green);
}
DrawCircle(ballPositionX, 200, ballRadius, ColorAlpha(Color.RED, 1.0f - ballAlpha));
DrawCircle(ballPositionX, 200, ballRadius, ColorAlpha(Color.Red, 1.0f - ballAlpha));
if (state == 3)
{
DrawText("PRESS [ENTER] TO PLAY AGAIN!", 240, 200, 20, Color.BLACK);
DrawText("PRESS [ENTER] TO PLAY AGAIN!", 240, 200, 20, Color.Black);
}
EndDrawing();

View File

@ -108,7 +108,7 @@ public class EasingsBoxAnim
}
// Reset animation at any moment
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
rec = new Rectangle(GetScreenWidth() / 2, -100, 100, 100);
rotation = 0.0f;
@ -121,15 +121,15 @@ public class EasingsBoxAnim
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawRectanglePro(
rec,
new Vector2(rec.Width / 2, rec.Height / 2),
rotation,
ColorAlpha(Color.BLACK, alpha)
ColorAlpha(Color.Black, alpha)
);
DrawText("PRESS [SPACE] TO RESET BOX ANIMATION!", 10, GetScreenHeight() - 25, 20, Color.LIGHTGRAY);
DrawText("PRESS [SPACE] TO RESET BOX ANIMATION!", 10, GetScreenHeight() - 25, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -90,7 +90,7 @@ public class EasingsRectangleArray
rotation = Easings.EaseLinearIn(framesCounter, 0.0f, 360.0f, PlayTimeInFrames);
}
}
else if ((state == 1) && IsKeyPressed(KeyboardKey.KEY_SPACE))
else if ((state == 1) && IsKeyPressed(KeyboardKey.Space))
{
// When animation has finished, press space to restart
framesCounter = 0;
@ -108,7 +108,7 @@ public class EasingsRectangleArray
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (state == 0)
{
@ -118,13 +118,13 @@ public class EasingsRectangleArray
recs[i],
new Vector2(recs[i].Width / 2, recs[i].Height / 2),
rotation,
Color.RED
Color.Red
);
}
}
else if (state == 1)
{
DrawText("PRESS [SPACE] TO PLAY AGAIN!", 240, 200, 20, Color.GRAY);
DrawText("PRESS [SPACE] TO PLAY AGAIN!", 240, 200, 20, Color.Gray);
}
EndDrawing();

View File

@ -82,15 +82,15 @@ public class FollowingEyes
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawCircleV(scleraLeftPosition, scleraRadius, Color.LIGHTGRAY);
DrawCircleV(irisLeftPosition, irisRadius, Color.BROWN);
DrawCircleV(irisLeftPosition, 10, Color.BLACK);
DrawCircleV(scleraLeftPosition, scleraRadius, Color.LightGray);
DrawCircleV(irisLeftPosition, irisRadius, Color.Brown);
DrawCircleV(irisLeftPosition, 10, Color.Black);
DrawCircleV(scleraRightPosition, scleraRadius, Color.LIGHTGRAY);
DrawCircleV(irisRightPosition, irisRadius, Color.DARKGREEN);
DrawCircleV(irisRightPosition, 10, Color.BLACK);
DrawCircleV(scleraRightPosition, scleraRadius, Color.LightGray);
DrawCircleV(irisRightPosition, irisRadius, Color.DarkGreen);
DrawCircleV(irisRightPosition, 10, Color.Black);
DrawFPS(10, 10);

View File

@ -23,7 +23,7 @@ public class LinesBezier
const int screenWidth = 800;
const int screenHeight = 450;
SetConfigFlags(ConfigFlags.FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlags.Msaa4xHint);
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines");
Vector2 start = new(0, 0);
@ -37,11 +37,11 @@ public class LinesBezier
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left))
{
start = GetMousePosition();
}
else if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON))
else if (IsMouseButtonDown(MouseButton.Right))
{
end = GetMousePosition();
}
@ -50,10 +50,10 @@ public class LinesBezier
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, Color.GRAY);
DrawLineBezier(start, end, 2.0f, Color.RED);
DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, Color.Gray);
DrawLineBezier(start, end, 2.0f, Color.Red);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -113,7 +113,7 @@ public class LogoRaylibAnim
// State 4: Reset and Replay
else if (state == 4)
{
if (IsKeyPressed(KeyboardKey.KEY_R))
if (IsKeyPressed(KeyboardKey.R))
{
framesCounter = 0;
lettersCount = 0;
@ -134,7 +134,7 @@ public class LogoRaylibAnim
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (state == 0)
{
@ -165,7 +165,7 @@ public class LogoRaylibAnim
DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, outlineFade);
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, outlineFade);
Color whiteFade = ColorAlpha(Color.RAYWHITE, alpha);
Color whiteFade = ColorAlpha(Color.RayWhite, alpha);
DrawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224, whiteFade);
Color label = ColorAlpha(new Color(155, 79, 151, 255), alpha);
@ -176,7 +176,7 @@ public class LogoRaylibAnim
}
else if (state == 4)
{
DrawText("[R] REPLAY", 340, 200, 20, Color.GRAY);
DrawText("[R] REPLAY", 340, 200, 20, Color.Gray);
}
EndDrawing();

View File

@ -38,14 +38,14 @@ public class LogoRaylibShape
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawRectangle(screenWidth / 2 - 128, screenHeight / 2 - 128, 256, 256, new Color(139, 71, 135, 255));
DrawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224, Color.RAYWHITE);
DrawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224, Color.RayWhite);
DrawText("raylib", screenWidth / 2 - 44, screenHeight / 2 + 28, 50, new Color(155, 79, 151, 255));
DrawText("cs", screenWidth / 2 - 44, screenHeight / 2 + 58, 50, new Color(155, 79, 151, 255));
DrawText("this is NOT a texture!", 350, 370, 10, Color.GRAY);
DrawText("this is NOT a texture!", 350, 370, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -56,7 +56,7 @@ public class RectangleScaling
CheckCollisionPointRec(mousePosition, area))
{
mouseScaleReady = true;
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
mouseScaleMode = true;
}
@ -82,7 +82,7 @@ public class RectangleScaling
rec.Height = MOUSE_SCALE_MARK_SIZE;
}
if (IsMouseButtonReleased(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonReleased(MouseButton.Left))
{
mouseScaleMode = false;
}
@ -92,19 +92,19 @@ public class RectangleScaling
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, Color.GRAY);
DrawRectangleRec(rec, ColorAlpha(Color.GREEN, 0.5f));
DrawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, Color.Gray);
DrawRectangleRec(rec, ColorAlpha(Color.Green, 0.5f));
if (mouseScaleReady)
{
DrawRectangleLinesEx(rec, 1, Color.RED);
DrawRectangleLinesEx(rec, 1, Color.Red);
DrawTriangle(
new Vector2(rec.X + rec.Width - MOUSE_SCALE_MARK_SIZE, rec.Y + rec.Height),
new Vector2(rec.X + rec.Width, rec.Y + rec.Height),
new Vector2(rec.X + rec.Width, rec.Y + rec.Height - MOUSE_SCALE_MARK_SIZE),
Color.RED
Color.Red
);
}

View File

@ -67,15 +67,15 @@ public static class Rlights
shader,
light.EnabledLoc,
light.Enabled ? 1 : 0,
ShaderUniformDataType.SHADER_UNIFORM_INT
ShaderUniformDataType.Int
);
Raylib.SetShaderValue(shader, light.TypeLoc, (int)light.Type, ShaderUniformDataType.SHADER_UNIFORM_INT);
Raylib.SetShaderValue(shader, light.TypeLoc, (int)light.Type, ShaderUniformDataType.Int);
// Send to shader light target position values
Raylib.SetShaderValue(shader, light.PosLoc, light.Position, ShaderUniformDataType.SHADER_UNIFORM_VEC3);
Raylib.SetShaderValue(shader, light.PosLoc, light.Position, ShaderUniformDataType.Vec3);
// Send to shader light target position values
Raylib.SetShaderValue(shader, light.TargetLoc, light.Target, ShaderUniformDataType.SHADER_UNIFORM_VEC3);
Raylib.SetShaderValue(shader, light.TargetLoc, light.Target, ShaderUniformDataType.Vec3);
// Send to shader light color values
float[] color = new[]
@ -85,6 +85,6 @@ public static class Rlights
(float)light.Color.B / (float)255,
(float)light.Color.A / (float)255
};
Raylib.SetShaderValue(shader, light.ColorLoc, color, ShaderUniformDataType.SHADER_UNIFORM_VEC4);
Raylib.SetShaderValue(shader, light.ColorLoc, color, ShaderUniformDataType.Vec4);
}
}

View File

@ -52,7 +52,7 @@ class CodepointsLoading
);
// Set bilinear scale filter for better font scaling
SetTextureFilter(font.Texture, TextureFilter.TEXTURE_FILTER_BILINEAR);
SetTextureFilter(font.Texture, TextureFilter.Bilinear);
bool showFontAtlas = false;
@ -64,7 +64,7 @@ class CodepointsLoading
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
showFontAtlas = !showFontAtlas;
}
@ -74,31 +74,31 @@ class CodepointsLoading
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawRectangle(0, 0, GetScreenWidth(), 70, Color.BLACK);
DrawText($"Total codepoints contained in provided text: {codepoints.Count}", 10, 10, 20, Color.GREEN);
DrawRectangle(0, 0, GetScreenWidth(), 70, Color.Black);
DrawText($"Total codepoints contained in provided text: {codepoints.Count}", 10, 10, 20, Color.Green);
DrawText(
$"Total codepoints required for font atlas (duplicates excluded): {codepointsNoDuplicates.Length}",
10,
40,
20,
Color.GREEN
Color.Green
);
if (showFontAtlas)
{
// Draw generated font texture atlas containing provided codepoints
DrawTexture(font.Texture, 150, 100, Color.BLACK);
DrawRectangleLines(150, 100, font.Texture.Width, font.Texture.Height, Color.BLACK);
DrawTexture(font.Texture, 150, 100, Color.Black);
DrawRectangleLines(150, 100, font.Texture.Width, font.Texture.Height, Color.Black);
}
else
{
// Draw provided text with laoded font, containing all required codepoint glyphs
DrawTextEx(font, text, new Vector2(160, 110), 48, 5, Color.BLACK);
DrawTextEx(font, text, new Vector2(160, 110), 48, 5, Color.Black);
}
DrawText("Press SPACE to toggle font atlas view!", 10, GetScreenHeight() - 30, 20, Color.GRAY);
DrawText("Press SPACE to toggle font atlas view!", 10, GetScreenHeight() - 30, 20, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -45,8 +45,8 @@ public class FontFilters
Vector2 textSize = new(0.0f, 0.0f);
// Setup texture scaling filter
SetTextureFilter(font.Texture, TextureFilter.TEXTURE_FILTER_POINT);
TextureFilter currentFontFilter = TextureFilter.TEXTURE_FILTER_POINT;
SetTextureFilter(font.Texture, TextureFilter.Point);
TextureFilter currentFontFilter = TextureFilter.Point;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -59,30 +59,30 @@ public class FontFilters
fontSize += GetMouseWheelMove() * 4.0f;
// Choose font texture filter method
if (IsKeyPressed(KeyboardKey.KEY_ONE))
if (IsKeyPressed(KeyboardKey.One))
{
SetTextureFilter(font.Texture, TextureFilter.TEXTURE_FILTER_POINT);
currentFontFilter = TextureFilter.TEXTURE_FILTER_POINT;
SetTextureFilter(font.Texture, TextureFilter.Point);
currentFontFilter = TextureFilter.Point;
}
else if (IsKeyPressed(KeyboardKey.KEY_TWO))
else if (IsKeyPressed(KeyboardKey.Two))
{
SetTextureFilter(font.Texture, TextureFilter.TEXTURE_FILTER_BILINEAR);
currentFontFilter = TextureFilter.TEXTURE_FILTER_BILINEAR;
SetTextureFilter(font.Texture, TextureFilter.Bilinear);
currentFontFilter = TextureFilter.Bilinear;
}
else if (IsKeyPressed(KeyboardKey.KEY_THREE))
else if (IsKeyPressed(KeyboardKey.Three))
{
// NOTE: Trilinear filter won't be noticed on 2D drawing
SetTextureFilter(font.Texture, TextureFilter.TEXTURE_FILTER_TRILINEAR);
currentFontFilter = TextureFilter.TEXTURE_FILTER_TRILINEAR;
SetTextureFilter(font.Texture, TextureFilter.Trilinear);
currentFontFilter = TextureFilter.Trilinear;
}
textSize = MeasureTextEx(font, msg, fontSize, 0);
if (IsKeyDown(KeyboardKey.KEY_LEFT))
if (IsKeyDown(KeyboardKey.Left))
{
fontPosition.X -= 10;
}
else if (IsKeyDown(KeyboardKey.KEY_RIGHT))
else if (IsKeyDown(KeyboardKey.Right))
{
fontPosition.X += 10;
}
@ -104,29 +104,29 @@ public class FontFilters
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Use mouse wheel to change font size", 20, 20, 10, Color.GRAY);
DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, Color.GRAY);
DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, Color.GRAY);
DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, Color.DARKGRAY);
DrawText("Use mouse wheel to change font size", 20, 20, 10, Color.Gray);
DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, Color.Gray);
DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, Color.Gray);
DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, Color.DarkGray);
DrawTextEx(font, msg, fontPosition, fontSize, 0, Color.BLACK);
DrawTextEx(font, msg, fontPosition, fontSize, 0, Color.Black);
DrawRectangle(0, screenHeight - 80, screenWidth, 80, Color.LIGHTGRAY);
DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, Color.GRAY);
DrawRectangle(0, screenHeight - 80, screenWidth, 80, Color.LightGray);
DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, Color.Gray);
if (currentFontFilter == TextureFilter.TEXTURE_FILTER_POINT)
if (currentFontFilter == TextureFilter.Point)
{
DrawText("POINT", 570, 400, 20, Color.BLACK);
DrawText("POINT", 570, 400, 20, Color.Black);
}
else if (currentFontFilter == TextureFilter.TEXTURE_FILTER_POINT)
else if (currentFontFilter == TextureFilter.Point)
{
DrawText("BILINEAR", 570, 400, 20, Color.BLACK);
DrawText("BILINEAR", 570, 400, 20, Color.Black);
}
else if (currentFontFilter == TextureFilter.TEXTURE_FILTER_TRILINEAR)
else if (currentFontFilter == TextureFilter.Trilinear)
{
DrawText("TRILINEAR", 570, 400, 20, Color.BLACK);
DrawText("TRILINEAR", 570, 400, 20, Color.Black);
}
EndDrawing();

View File

@ -57,7 +57,7 @@ public class FontLoading
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.KEY_SPACE))
if (IsKeyDown(KeyboardKey.Space))
{
useTtf = true;
}
@ -70,19 +70,19 @@ public class FontLoading
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("Hold SPACE to use TTF generated font", 20, 20, 20, Color.LIGHTGRAY);
DrawText("Hold SPACE to use TTF generated font", 20, 20, 20, Color.LightGray);
if (!useTtf)
{
DrawTextEx(fontBm, msg, new Vector2(20.0f, 100.0f), fontBm.BaseSize, 2, Color.MAROON);
DrawText("Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, Color.GRAY);
DrawTextEx(fontBm, msg, new Vector2(20.0f, 100.0f), fontBm.BaseSize, 2, Color.Maroon);
DrawText("Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, Color.Gray);
}
else
{
DrawTextEx(fontTtf, msg, new Vector2(20.0f, 100.0f), fontTtf.BaseSize, 2, Color.LIME);
DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, Color.GRAY);
DrawTextEx(fontTtf, msg, new Vector2(20.0f, 100.0f), fontTtf.BaseSize, 2, Color.Lime);
DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, Color.Gray);
}
EndDrawing();

View File

@ -41,7 +41,7 @@ public class FontSdf
// Loading font data from memory data
// Parameters > font size: 16, no chars array provided (0), chars count: 95 (autogenerate chars array)
fontDefault.Glyphs = LoadFontData(fileData, (int)fileSize, 16, null, 95, FontType.FONT_DEFAULT);
fontDefault.Glyphs = LoadFontData(fileData, (int)fileSize, 16, null, 95, FontType.Default);
// Parameters > chars count: 95, font size: 16, chars padding in image: 4 px, pack method: 0 (default)
Image atlas = GenImageFontAtlas(fontDefault.Glyphs, &fontDefault.Recs, 95, 16, 4, 0);
fontDefault.Texture = LoadTextureFromImage(atlas);
@ -52,7 +52,7 @@ public class FontSdf
fontSDF.BaseSize = 16;
fontSDF.GlyphCount = 95;
// Parameters > font size: 16, no chars array provided (0), chars count: 0 (defaults to 95)
fontSDF.Glyphs = LoadFontData(fileData, (int)fileSize, 16, null, 0, FontType.FONT_SDF);
fontSDF.Glyphs = LoadFontData(fileData, (int)fileSize, 16, null, 0, FontType.Sdf);
// Parameters > chars count: 95, font size: 16, chars padding in image: 0 px, pack method: 1 (Skyline algorythm)
atlas = GenImageFontAtlas(fontSDF.Glyphs, &fontSDF.Recs, 95, 16, 0, 1);
fontSDF.Texture = LoadTextureFromImage(atlas);
@ -64,7 +64,7 @@ public class FontSdf
// Load SDF required shader (we use default vertex shader)
Shader shader = LoadShader(null, "resources/shaders/glsl330/sdf.fs");
// Required for SDF font
SetTextureFilter(fontSDF.Texture, TextureFilter.TEXTURE_FILTER_BILINEAR);
SetTextureFilter(fontSDF.Texture, TextureFilter.Bilinear);
Vector2 fontPosition = new(40, screenHeight / 2 - 50);
Vector2 textSize = new(0.0f);
@ -87,7 +87,7 @@ public class FontSdf
fontSize = 6;
}
if (IsKeyDown(KeyboardKey.KEY_SPACE))
if (IsKeyDown(KeyboardKey.Space))
{
currentFont = 1;
}
@ -112,37 +112,37 @@ public class FontSdf
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (currentFont == 1)
{
// NOTE: SDF fonts require a custom SDf shader to compute fragment color
BeginShaderMode(shader);
DrawTextEx(fontSDF, msg, fontPosition, fontSize, 0, Color.BLACK);
DrawTextEx(fontSDF, msg, fontPosition, fontSize, 0, Color.Black);
EndShaderMode();
DrawTexture(fontSDF.Texture, 10, 10, Color.BLACK);
DrawTexture(fontSDF.Texture, 10, 10, Color.Black);
}
else
{
DrawTextEx(fontDefault, msg, fontPosition, fontSize, 0, Color.BLACK);
DrawTexture(fontDefault.Texture, 10, 10, Color.BLACK);
DrawTextEx(fontDefault, msg, fontPosition, fontSize, 0, Color.Black);
DrawTexture(fontDefault.Texture, 10, 10, Color.Black);
}
if (currentFont == 1)
{
DrawText("SDF!", 320, 20, 80, Color.RED);
DrawText("SDF!", 320, 20, 80, Color.Red);
}
else
{
DrawText("default font", 315, 40, 30, Color.GRAY);
DrawText("default font", 315, 40, 30, Color.Gray);
}
DrawText("FONT SIZE: 16.0", GetScreenWidth() - 240, 20, 20, Color.DARKGRAY);
DrawText($"RENDER SIZE: {fontSize:2F}", GetScreenWidth() - 240, 50, 20, Color.DARKGRAY);
DrawText("Use MOUSE WHEEL to SCALE TEXT!", GetScreenWidth() - 240, 90, 10, Color.DARKGRAY);
DrawText("FONT SIZE: 16.0", GetScreenWidth() - 240, 20, 20, Color.DarkGray);
DrawText($"RENDER SIZE: {fontSize:2F}", GetScreenWidth() - 240, 50, 20, Color.DarkGray);
DrawText("Use MOUSE WHEEL to SCALE TEXT!", GetScreenWidth() - 240, 90, 10, Color.DarkGray);
DrawText("PRESS SPACE to USE SDF FONT VERSION!", 340, GetScreenHeight() - 30, 20, Color.MAROON);
DrawText("PRESS SPACE to USE SDF FONT VERSION!", 340, GetScreenHeight() - 30, 20, Color.Maroon);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -72,11 +72,11 @@ public class FontSpritefont
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTextEx(font1, msg1, fontPosition1, font1.BaseSize, -3, Color.WHITE);
DrawTextEx(font2, msg2, fontPosition2, font2.BaseSize, -2, Color.WHITE);
DrawTextEx(font3, msg3, fontPosition3, font3.BaseSize, 2, Color.WHITE);
DrawTextEx(font1, msg1, fontPosition1, font1.BaseSize, -3, Color.White);
DrawTextEx(font2, msg2, fontPosition2, font2.BaseSize, -2, Color.White);
DrawTextEx(font3, msg3, fontPosition3, font3.BaseSize, 2, Color.White);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -42,12 +42,12 @@ public class FormatText
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText($"Score: {score}", 200, 80, 20, Color.RED);
DrawText($"HiScore: {hiscore}", 200, 120, 20, Color.GREEN);
DrawText($"Lives: {lives}", 200, 160, 40, Color.BLUE);
DrawText($"Elapsed Time: {GetFrameTime() * 1000} ms", 200, 220, 20, Color.BLACK);
DrawText($"Score: {score}", 200, 80, 20, Color.Red);
DrawText($"HiScore: {hiscore}", 200, 120, 20, Color.Green);
DrawText($"Lives: {lives}", 200, 160, 40, Color.Blue);
DrawText($"Elapsed Time: {GetFrameTime() * 1000} ms", 200, 220, 20, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -55,7 +55,7 @@ public class InputBox
if (mouseOnText)
{
// Set the window's cursor to the I-Beam
SetMouseCursor(MouseCursor.MOUSE_CURSOR_IBEAM);
SetMouseCursor(MouseCursor.IBeam);
// Check if more characters have been pressed on the same frame
int key = GetCharPressed();
@ -73,7 +73,7 @@ public class InputBox
key = GetCharPressed();
}
if (IsKeyPressed(KeyboardKey.KEY_BACKSPACE))
if (IsKeyPressed(KeyboardKey.Backspace))
{
letterCount -= 1;
if (letterCount < 0)
@ -85,7 +85,7 @@ public class InputBox
}
else
{
SetMouseCursor(MouseCursor.MOUSE_CURSOR_DEFAULT);
SetMouseCursor(MouseCursor.Default);
}
if (mouseOnText)
@ -101,10 +101,10 @@ public class InputBox
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, Color.GRAY);
DrawRectangleRec(textBox, Color.LIGHTGRAY);
DrawText("PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, Color.Gray);
DrawRectangleRec(textBox, Color.LightGray);
if (mouseOnText)
{
@ -113,7 +113,7 @@ public class InputBox
(int)textBox.Y,
(int)textBox.Width,
(int)textBox.Height,
Color.RED
Color.Red
);
}
else
@ -123,12 +123,12 @@ public class InputBox
(int)textBox.Y,
(int)textBox.Width,
(int)textBox.Height,
Color.DARKGRAY
Color.DarkGray
);
}
DrawText(new string(name), (int)textBox.X + 5, (int)textBox.Y + 8, 40, Color.MAROON);
DrawText($"INPUT CHARS: {letterCount}/{MaxInputChars}", 315, 250, 20, Color.DARKGRAY);
DrawText(new string(name), (int)textBox.X + 5, (int)textBox.Y + 8, 40, Color.Maroon);
DrawText($"INPUT CHARS: {letterCount}/{MaxInputChars}", 315, 250, 20, Color.DarkGray);
if (mouseOnText)
{
@ -142,13 +142,13 @@ public class InputBox
(int)textBox.X + 8 + MeasureText(new string(name), 40),
(int)textBox.Y + 12,
40,
Color.MAROON
Color.Maroon
);
}
}
else
{
DrawText("Press BACKSPACE to delete chars...", 230, 300, 20, Color.GRAY);
DrawText("Press BACKSPACE to delete chars...", 230, 300, 20, Color.Gray);
}
}

View File

@ -69,14 +69,14 @@ public class RaylibFonts
positions[7].Y -= 8;
Color[] colors = new Color[MaxFonts] {
Color.MAROON,
Color.ORANGE,
Color.DARKGREEN,
Color.DARKBLUE,
Color.DARKPURPLE,
Color.LIME,
Color.GOLD,
Color.RED
Color.Maroon,
Color.Orange,
Color.DarkGreen,
Color.DarkBlue,
Color.DarkPurple,
Color.Lime,
Color.Gold,
Color.Red
};
//--------------------------------------------------------------------------------------
@ -91,10 +91,10 @@ public class RaylibFonts
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("free fonts included with raylib", 250, 20, 20, Color.DARKGRAY);
DrawLine(220, 50, 590, 50, Color.DARKGRAY);
DrawText("free fonts included with raylib", 250, 20, 20, Color.DarkGray);
DrawLine(220, 50, 590, 50, Color.DarkGray);
for (int i = 0; i < MaxFonts; i++)
{

View File

@ -37,7 +37,7 @@ public class RectangleBounds
const int maxHeight = screenHeight - 160;
Vector2 lastMouse = new(0.0f, 0.0f);
Color borderColor = Color.MAROON;
Color borderColor = Color.Maroon;
Font font = GetFontDefault();
SetTargetFPS(60);
@ -48,7 +48,7 @@ public class RectangleBounds
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
wordWrap = !wordWrap;
}
@ -58,17 +58,17 @@ public class RectangleBounds
// Check if the mouse is inside the container and toggle border color
if (CheckCollisionPointRec(mouse, container))
{
borderColor = ColorAlpha(Color.MAROON, 0.4f);
borderColor = ColorAlpha(Color.Maroon, 0.4f);
}
else if (!resizing)
{
borderColor = Color.MAROON;
borderColor = Color.Maroon;
}
// Container resizing logic
if (resizing)
{
if (IsMouseButtonReleased(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonReleased(MouseButton.Left))
{
resizing = false;
}
@ -82,7 +82,7 @@ public class RectangleBounds
else
{
// Check if we're resizing
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON) && CheckCollisionPointRec(mouse, resizer))
if (IsMouseButtonDown(MouseButton.Left) && CheckCollisionPointRec(mouse, resizer))
{
resizing = true;
}
@ -98,7 +98,7 @@ public class RectangleBounds
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Draw container border
DrawRectangleLinesEx(container, 3, borderColor);
@ -111,28 +111,28 @@ public class RectangleBounds
20.0f,
2.0f,
wordWrap,
Color.GRAY
Color.Gray
);
DrawRectangleRec(resizer, borderColor);
// Draw bottom info
DrawRectangle(0, screenHeight - 54, screenWidth, 54, Color.GRAY);
DrawRectangleRec(new Rectangle(382, screenHeight - 34, 12, 12), Color.MAROON);
DrawRectangle(0, screenHeight - 54, screenWidth, 54, Color.Gray);
DrawRectangleRec(new Rectangle(382, screenHeight - 34, 12, 12), Color.Maroon);
DrawText("Word Wrap: ", 313, screenHeight - 115, 20, Color.BLACK);
DrawText("Word Wrap: ", 313, screenHeight - 115, 20, Color.Black);
if (wordWrap)
{
DrawText("ON", 447, screenHeight - 115, 20, Color.RED);
DrawText("ON", 447, screenHeight - 115, 20, Color.Red);
}
else
{
DrawText("OFF", 447, screenHeight - 115, 20, Color.BLACK);
DrawText("OFF", 447, screenHeight - 115, 20, Color.Black);
}
DrawText("Press [SPACE] to toggle word wrap", 218, screenHeight - 86, 20, Color.GRAY);
DrawText("Click hold & drag the to resize the container", 155, screenHeight - 38, 20, Color.RAYWHITE);
DrawText("Press [SPACE] to toggle word wrap", 218, screenHeight - 86, 20, Color.Gray);
DrawText("Click hold & drag the to resize the container", 155, screenHeight - 38, 20, Color.RayWhite);
EndDrawing();
//----------------------------------------------------------------------------------
@ -157,7 +157,7 @@ public class RectangleBounds
Color tint
)
{
DrawTextBoxedSelectable(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, Color.WHITE, Color.WHITE);
DrawTextBoxedSelectable(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, Color.White, Color.White);
}
// Draw text using font inside rectangle limits with support for text selection

View File

@ -35,7 +35,7 @@ public class WritingAnim
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.KEY_SPACE))
if (IsKeyDown(KeyboardKey.Space))
{
framesCounter += 8;
}
@ -44,7 +44,7 @@ public class WritingAnim
framesCounter += 1;
}
if (IsKeyPressed(KeyboardKey.KEY_ENTER))
if (IsKeyPressed(KeyboardKey.Enter))
{
framesCounter = 0;
}
@ -53,12 +53,12 @@ public class WritingAnim
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText(message.SubText(0, framesCounter / 10), 210, 160, 20, Color.MAROON);
DrawText(message.SubText(0, framesCounter / 10), 210, 160, 20, Color.Maroon);
DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, Color.LIGHTGRAY);
DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, Color.LIGHTGRAY);
DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, Color.LightGray);
DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, Color.LightGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -69,34 +69,34 @@ public class BackgroundScrolling
// Draw background image twice
// NOTE: Texture is scaled twice its size
DrawTextureEx(background, new Vector2(scrollingBack, 20), 0.0f, 2.0f, Color.WHITE);
DrawTextureEx(background, new Vector2(scrollingBack, 20), 0.0f, 2.0f, Color.White);
DrawTextureEx(
background,
new Vector2(background.Width * 2 + scrollingBack, 20),
0.0f,
2.0f,
Color.WHITE
Color.White
);
// Draw midground image twice
DrawTextureEx(midground, new Vector2(scrollingMid, 20), 0.0f, 2.0f, Color.WHITE);
DrawTextureEx(midground, new Vector2(midground.Width * 2 + scrollingMid, 20), 0.0f, 2.0f, Color.WHITE);
DrawTextureEx(midground, new Vector2(scrollingMid, 20), 0.0f, 2.0f, Color.White);
DrawTextureEx(midground, new Vector2(midground.Width * 2 + scrollingMid, 20), 0.0f, 2.0f, Color.White);
// Draw foreground image twice
DrawTextureEx(foreground, new Vector2(scrollingFore, 70), 0.0f, 2.0f, Color.WHITE);
DrawTextureEx(foreground, new Vector2(scrollingFore, 70), 0.0f, 2.0f, Color.White);
DrawTextureEx(
foreground,
new Vector2(foreground.Width * 2 + scrollingFore, 70),
0.0f,
2.0f,
Color.WHITE
Color.White
);
DrawText("BACKGROUND SCROLLING & PARALLAX", 10, 10, 20, Color.RED);
DrawText("BACKGROUND SCROLLING & PARALLAX", 10, 10, 20, Color.Red);
int x = screenWidth - 330;
int y = screenHeight - 20;
DrawText("(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", x, y, 10, Color.RAYWHITE);
DrawText("(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", x, y, 10, Color.RayWhite);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -47,7 +47,7 @@ public class BlendModes
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
if ((int)blendMode >= (blendCountMax - 1))
{
@ -63,42 +63,42 @@ public class BlendModes
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
int bgX = screenWidth / 2 - bgTexture.Width / 2;
int bgY = screenHeight / 2 - bgTexture.Height / 2;
DrawTexture(bgTexture, bgX, bgY, Color.WHITE);
DrawTexture(bgTexture, bgX, bgY, Color.White);
// Apply the blend mode and then draw the foreground texture
BeginBlendMode(blendMode);
int fgX = screenWidth / 2 - fgTexture.Width / 2;
int fgY = screenHeight / 2 - fgTexture.Height / 2;
DrawTexture(fgTexture, fgX, fgY, Color.WHITE);
DrawTexture(fgTexture, fgX, fgY, Color.White);
EndBlendMode();
// Draw the texts
DrawText("Press SPACE to change blend modes.", 310, 350, 10, Color.GRAY);
DrawText("Press SPACE to change blend modes.", 310, 350, 10, Color.Gray);
switch (blendMode)
{
case BlendMode.BLEND_ALPHA:
DrawText("Current: BLEND_ALPHA", (screenWidth / 2) - 60, 370, 10, Color.GRAY);
case BlendMode.Alpha:
DrawText("Current: BLEND_ALPHA", (screenWidth / 2) - 60, 370, 10, Color.Gray);
break;
case BlendMode.BLEND_ADDITIVE:
DrawText("Current: BLEND_ADDITIVE", (screenWidth / 2) - 60, 370, 10, Color.GRAY);
case BlendMode.Additive:
DrawText("Current: BLEND_ADDITIVE", (screenWidth / 2) - 60, 370, 10, Color.Gray);
break;
case BlendMode.BLEND_MULTIPLIED:
DrawText("Current: BLEND_MULTIPLIED", (screenWidth / 2) - 60, 370, 10, Color.GRAY);
case BlendMode.Multiplied:
DrawText("Current: BLEND_MULTIPLIED", (screenWidth / 2) - 60, 370, 10, Color.Gray);
break;
case BlendMode.BLEND_ADD_COLORS:
DrawText("Current: BLEND_ADD_COLORS", (screenWidth / 2) - 60, 370, 10, Color.GRAY);
case BlendMode.AddColors:
DrawText("Current: BLEND_ADD_COLORS", (screenWidth / 2) - 60, 370, 10, Color.Gray);
break;
default:
break;
}
string text = "(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)";
DrawText(text, screenWidth - 330, screenHeight - 20, 10, Color.GRAY);
DrawText(text, screenWidth - 330, screenHeight - 20, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -53,7 +53,7 @@ public class Bunnymark
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonDown(MouseButton.Left))
{
// Create more bunnies
for (int i = 0; i < 100; i++)
@ -98,7 +98,7 @@ public class Bunnymark
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
for (int i = 0; i < bunniesCount; i++)
{
@ -111,9 +111,9 @@ public class Bunnymark
DrawTexture(texBunny, (int)bunnies[i].Position.X, (int)bunnies[i].Position.Y, bunnies[i].Color);
}
DrawRectangle(0, 0, screenWidth, 40, Color.BLACK);
DrawText($"bunnies: {bunniesCount}", 120, 10, 20, Color.GREEN);
DrawText($"batched draw calls: {1 + bunniesCount / MAX_BATCH_ELEMENTS}", 320, 10, 20, Color.MAROON);
DrawRectangle(0, 0, screenWidth, 40, Color.Black);
DrawText($"bunnies: {bunniesCount}", 120, 10, 20, Color.Green);
DrawText($"batched draw calls: {1 + bunniesCount / MAX_BATCH_ELEMENTS}", 320, 10, 20, Color.Maroon);
DrawFPS(10, 10);

View File

@ -27,14 +27,14 @@ public class DrawTiled
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(ConfigFlags.FLAG_WINDOW_RESIZABLE);
SetConfigFlags(ConfigFlags.ResizableWindow);
InitWindow(screenWidth, screenHeight, "raylib [textures] example - Draw part of a texture tiled");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texPattern = LoadTexture("resources/patterns.png");
// Makes the texture smoother when upscaled
SetTextureFilter(texPattern, TextureFilter.TEXTURE_FILTER_TRILINEAR);
SetTextureFilter(texPattern, TextureFilter.Trilinear);
// Coordinates for all patterns inside the texture
Rectangle[] recPattern = new[] {
@ -49,16 +49,16 @@ public class DrawTiled
// Setup colors
Color[] colors = new[]
{
Color.BLACK,
Color.MAROON,
Color.ORANGE,
Color.BLUE,
Color.PURPLE,
Color.BEIGE,
Color.LIME,
Color.RED,
Color.DARKGRAY,
Color.SKYBLUE
Color.Black,
Color.Maroon,
Color.Orange,
Color.Blue,
Color.Purple,
Color.Beige,
Color.Lime,
Color.Red,
Color.DarkGray,
Color.SkyBlue
};
Rectangle[] colorRec = new Rectangle[colors.Length];
@ -96,7 +96,7 @@ public class DrawTiled
screenHeight = GetScreenHeight();
// Handle mouse
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.Left))
{
Vector2 mouse = GetMousePosition();
@ -130,11 +130,11 @@ public class DrawTiled
// Handle keys
// Change scale
if (IsKeyPressed(KeyboardKey.KEY_UP))
if (IsKeyPressed(KeyboardKey.Up))
{
scale += 0.25f;
}
if (IsKeyPressed(KeyboardKey.KEY_DOWN))
if (IsKeyPressed(KeyboardKey.Down))
{
scale -= 0.25f;
}
@ -148,17 +148,17 @@ public class DrawTiled
}
// Change rotation
if (IsKeyPressed(KeyboardKey.KEY_LEFT))
if (IsKeyPressed(KeyboardKey.Left))
{
rotation -= 25.0f;
}
if (IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsKeyPressed(KeyboardKey.Right))
{
rotation += 25.0f;
}
// Reset
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
if (IsKeyPressed(KeyboardKey.Space))
{
rotation = 0.0f;
scale = 1.0f;
@ -168,7 +168,7 @@ public class DrawTiled
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
// Draw the tiled area
Rectangle source = recPattern[activePattern];
@ -181,39 +181,39 @@ public class DrawTiled
DrawTextureTiled(texPattern, source, dest, Vector2.Zero, rotation, scale, colors[activeCol]);
// Draw options
Color color = ColorAlpha(Color.LIGHTGRAY, 0.5f);
Color color = ColorAlpha(Color.LightGray, 0.5f);
DrawRectangle(MarginSize, MarginSize, OptWidth - MarginSize, screenHeight - 2 * MarginSize, color);
DrawText("Select Pattern", 2 + MarginSize, 30 + MarginSize, 10, Color.BLACK);
DrawTexture(texPattern, 2 + MarginSize, 40 + MarginSize, Color.BLACK);
DrawText("Select Pattern", 2 + MarginSize, 30 + MarginSize, 10, Color.Black);
DrawTexture(texPattern, 2 + MarginSize, 40 + MarginSize, Color.Black);
DrawRectangle(
2 + MarginSize + (int)recPattern[activePattern].X,
40 + MarginSize + (int)recPattern[activePattern].Y,
(int)recPattern[activePattern].Width,
(int)recPattern[activePattern].Height,
ColorAlpha(Color.DARKBLUE, 0.3f)
ColorAlpha(Color.DarkBlue, 0.3f)
);
DrawText("Select Color", 2 + MarginSize, 10 + 256 + MarginSize, 10, Color.BLACK);
DrawText("Select Color", 2 + MarginSize, 10 + 256 + MarginSize, 10, Color.Black);
for (int i = 0; i < colors.Length; i++)
{
DrawRectangleRec(colorRec[i], colors[i]);
if (activeCol == i)
{
DrawRectangleLinesEx(colorRec[i], 3, ColorAlpha(Color.WHITE, 0.5f));
DrawRectangleLinesEx(colorRec[i], 3, ColorAlpha(Color.White, 0.5f));
}
}
DrawText("Scale (UP/DOWN to change)", 2 + MarginSize, 80 + 256 + MarginSize, 10, Color.BLACK);
DrawText($"{scale}x", 2 + MarginSize, 92 + 256 + MarginSize, 20, Color.BLACK);
DrawText("Scale (UP/DOWN to change)", 2 + MarginSize, 80 + 256 + MarginSize, 10, Color.Black);
DrawText($"{scale}x", 2 + MarginSize, 92 + 256 + MarginSize, 20, Color.Black);
DrawText("Rotation (LEFT/RIGHT to change)", 2 + MarginSize, 122 + 256 + MarginSize, 10, Color.BLACK);
DrawText($"{rotation} degrees", 2 + MarginSize, 134 + 256 + MarginSize, 20, Color.BLACK);
DrawText("Rotation (LEFT/RIGHT to change)", 2 + MarginSize, 122 + 256 + MarginSize, 10, Color.Black);
DrawText($"{rotation} degrees", 2 + MarginSize, 134 + 256 + MarginSize, 20, Color.Black);
DrawText("Press [SPACE] to reset", 2 + MarginSize, 164 + 256 + MarginSize, 10, Color.DARKBLUE);
DrawText("Press [SPACE] to reset", 2 + MarginSize, 164 + 256 + MarginSize, 10, Color.DarkBlue);
// Draw FPS
DrawText($"{GetFPS()}", 2 + MarginSize, 2 + MarginSize, 20, Color.BLACK);
DrawText($"{GetFPS()}", 2 + MarginSize, 2 + MarginSize, 20, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------
}

View File

@ -38,13 +38,13 @@ public class ImageDrawing
// Draw one image over the other with a scaling of 1.5f
Rectangle src = new(0, 0, cat.Width, cat.Height);
ImageDraw(ref parrots, cat, src, new Rectangle(30, 40, cat.Width * 1.5f, cat.Height * 1.5f), Color.WHITE);
ImageDraw(ref parrots, cat, src, new Rectangle(30, 40, cat.Width * 1.5f, cat.Height * 1.5f), Color.White);
ImageCrop(ref parrots, new Rectangle(0, 50, parrots.Width, parrots.Height - 100));
// Draw on the image with a few image draw methods
ImageDrawPixel(ref parrots, 10, 10, Color.RAYWHITE);
ImageDrawCircle(ref parrots, 10, 10, 5, Color.RAYWHITE);
ImageDrawRectangle(ref parrots, 5, 20, 10, 10, Color.RAYWHITE);
ImageDrawPixel(ref parrots, 10, 10, Color.RayWhite);
ImageDrawCircle(ref parrots, 10, 10, 5, Color.RayWhite);
ImageDrawRectangle(ref parrots, 5, 20, 10, 10, Color.RayWhite);
UnloadImage(cat);
@ -52,7 +52,7 @@ public class ImageDrawing
Font font = LoadFont("resources/fonts/custom_jupiter_crash.png");
// Draw over image using custom font
ImageDrawTextEx(ref parrots, font, "PARROTS & CAT", new Vector2(300, 230), font.BaseSize, -2, Color.WHITE);
ImageDrawTextEx(ref parrots, font, "PARROTS & CAT", new Vector2(300, 230), font.BaseSize, -2, Color.White);
// Unload custom spritefont (already drawn used on image)
UnloadFont(font);
@ -74,17 +74,17 @@ public class ImageDrawing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
int x = screenWidth / 2 - texture.Width / 2;
int y = screenHeight / 2 - texture.Height / 2;
DrawTexture(texture, x, y - 40, Color.WHITE);
DrawRectangleLines(x, y - 40, texture.Width, texture.Height, Color.DARKGRAY);
DrawTexture(texture, x, y - 40, Color.White);
DrawRectangleLines(x, y - 40, texture.Width, texture.Height, Color.DarkGray);
DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, Color.DARKGRAY);
DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, Color.DarkGray);
string text = "Source images have been cropped, scaled, flipped and copied one over the other.";
DrawText(text, 90, 370, 10, Color.DARKGRAY);
DrawText(text, 90, 370, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -26,10 +26,10 @@ public class ImageGeneration
InitWindow(screenWidth, screenHeight, "raylib [textures] example - procedural images generation");
Image verticalGradient = GenImageGradientLinear(screenWidth, screenHeight, 0, Color.RED, Color.BLUE);
Image horizontalGradient = GenImageGradientLinear(screenWidth, screenHeight, 90, Color.RED, Color.BLUE);
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, Color.WHITE, Color.BLACK);
Image isChecked = GenImageChecked(screenWidth, screenHeight, 32, 32, Color.RED, Color.BLUE);
Image verticalGradient = GenImageGradientLinear(screenWidth, screenHeight, 0, Color.Red, Color.Blue);
Image horizontalGradient = GenImageGradientLinear(screenWidth, screenHeight, 90, Color.Red, Color.Blue);
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, Color.White, Color.Black);
Image isChecked = GenImageChecked(screenWidth, screenHeight, 32, 32, Color.Red, Color.Blue);
Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f);
Image cellular = GenImageCellular(screenWidth, screenHeight, 32);
@ -58,7 +58,7 @@ public class ImageGeneration
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON) || IsKeyPressed(KeyboardKey.KEY_RIGHT))
if (IsMouseButtonPressed(MouseButton.Left) || IsKeyPressed(KeyboardKey.Right))
{
// Cycle between the textures
currentTexture = (currentTexture + 1) % NumTextures;
@ -68,33 +68,33 @@ public class ImageGeneration
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTexture(textures[currentTexture], 0, 0, Color.WHITE);
DrawTexture(textures[currentTexture], 0, 0, Color.White);
DrawRectangle(30, 400, 325, 30, ColorAlpha(Color.SKYBLUE, 0.5f));
DrawRectangleLines(30, 400, 325, 30, ColorAlpha(Color.WHITE, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, Color.WHITE);
DrawRectangle(30, 400, 325, 30, ColorAlpha(Color.SkyBlue, 0.5f));
DrawRectangleLines(30, 400, 325, 30, ColorAlpha(Color.White, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, Color.White);
switch (currentTexture)
{
case 0:
DrawText("VERTICAL GRADIENT", 560, 10, 20, Color.RAYWHITE);
DrawText("VERTICAL GRADIENT", 560, 10, 20, Color.RayWhite);
break;
case 1:
DrawText("HORIZONTAL GRADIENT", 540, 10, 20, Color.RAYWHITE);
DrawText("HORIZONTAL GRADIENT", 540, 10, 20, Color.RayWhite);
break;
case 2:
DrawText("RADIAL GRADIENT", 580, 10, 20, Color.LIGHTGRAY);
DrawText("RADIAL GRADIENT", 580, 10, 20, Color.LightGray);
break;
case 3:
DrawText("CHECKED", 680, 10, 20, Color.RAYWHITE);
DrawText("CHECKED", 680, 10, 20, Color.RayWhite);
break;
case 4:
DrawText("Color.WHITE NOISE", 640, 10, 20, Color.RED);
DrawText("Color.WHITE NOISE", 640, 10, 20, Color.Red);
break;
case 5:
DrawText("CELLULAR", 670, 10, 20, Color.RAYWHITE);
DrawText("CELLULAR", 670, 10, 20, Color.RayWhite);
break;
default:
break;

View File

@ -45,16 +45,16 @@ public class ImageLoading
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawTexture(
texture,
screenWidth / 2 - texture.Width / 2,
screenHeight / 2 - texture.Height / 2,
Color.WHITE
Color.White
);
DrawText("this IS a texture loaded from an image!", 300, 370, 10, Color.GRAY);
DrawText("this IS a texture loaded from an image!", 300, 370, 10, Color.Gray);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -55,7 +55,7 @@ public class ImageProcessing
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Image imageOrigin = LoadImage("resources/parrots.png");
ImageFormat(ref imageOrigin, PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
ImageFormat(ref imageOrigin, PixelFormat.UncompressedR8G8B8A8);
Texture2D texture = LoadTextureFromImage(imageOrigin);
Image imageCopy = ImageCopy(imageOrigin);
@ -87,7 +87,7 @@ public class ImageProcessing
{
mouseHoverRec = i;
if (IsMouseButtonReleased(MouseButton.MOUSE_LEFT_BUTTON))
if (IsMouseButtonReleased(MouseButton.Left))
{
currentProcess = (ImageProcess)i;
textureReload = true;
@ -101,7 +101,7 @@ public class ImageProcessing
}
// Keyboard toggle group logic
if (IsKeyPressed(KeyboardKey.KEY_DOWN))
if (IsKeyPressed(KeyboardKey.Down))
{
currentProcess++;
if ((int)currentProcess > (NumProcesses - 1))
@ -111,7 +111,7 @@ public class ImageProcessing
textureReload = true;
}
else if (IsKeyPressed(KeyboardKey.KEY_UP))
else if (IsKeyPressed(KeyboardKey.Up))
{
currentProcess--;
if (currentProcess < 0)
@ -136,7 +136,7 @@ public class ImageProcessing
ImageColorGrayscale(ref imageCopy);
break;
case ImageProcess.ColorTint:
ImageColorTint(ref imageCopy, Color.GREEN);
ImageColorTint(ref imageCopy, Color.Green);
break;
case ImageProcess.ColorInvert:
ImageColorInvert(ref imageCopy);
@ -172,20 +172,20 @@ public class ImageProcessing
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
DrawText("IMAGE PROCESSING:", 40, 30, 10, Color.DARKGRAY);
DrawText("IMAGE PROCESSING:", 40, 30, 10, Color.DarkGray);
// Draw rectangles
for (int i = 0; i < NumProcesses; i++)
{
DrawRectangleRec(toggleRecs[i], (i == (int)currentProcess) ? Color.SKYBLUE : Color.LIGHTGRAY);
DrawRectangleRec(toggleRecs[i], (i == (int)currentProcess) ? Color.SkyBlue : Color.LightGray);
DrawRectangleLines(
(int)toggleRecs[i].X,
(int)toggleRecs[i].Y,
(int)toggleRecs[i].Width,
(int)toggleRecs[i].Height,
(i == (int)currentProcess) ? Color.BLUE : Color.GRAY
(i == (int)currentProcess) ? Color.Blue : Color.Gray
);
int labelX = (int)(toggleRecs[i].X + toggleRecs[i].Width / 2);
@ -194,14 +194,14 @@ public class ImageProcessing
(int)(labelX - MeasureText(processText[i], 10) / 2),
(int)toggleRecs[i].Y + 11,
10,
(i == (int)currentProcess) ? Color.DARKBLUE : Color.DARKGRAY
(i == (int)currentProcess) ? Color.DarkBlue : Color.DarkGray
);
}
int x = screenWidth - texture.Width - 60;
int y = screenHeight / 2 - texture.Height / 2;
DrawTexture(texture, x, y, Color.WHITE);
DrawRectangleLines(x, y, texture.Width, texture.Height, Color.BLACK);
DrawTexture(texture, x, y, Color.White);
DrawRectangleLines(x, y, texture.Width, texture.Height, Color.Black);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -38,7 +38,7 @@ public class ImageText
new Vector2(20, 20),
font.BaseSize,
0,
Color.WHITE
Color.White
);
// Image converted to texture, uploaded to GPU memory (VRAM)
@ -60,7 +60,7 @@ public class ImageText
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.KEY_SPACE))
if (IsKeyDown(KeyboardKey.Space))
{
showFont = true;
}
@ -73,23 +73,23 @@ public class ImageText
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color.RAYWHITE);
ClearBackground(Color.RayWhite);
if (!showFont)
{
// Draw texture with text already drawn inside
DrawTextureV(texture, position, Color.WHITE);
DrawTextureV(texture, position, Color.White);
// Draw text directly using sprite font
Vector2 textPosition = new(position.X + 20, position.Y + 20 + 280);
DrawTextEx(font, "[Parrots font drawing]", textPosition, font.BaseSize, 0, Color.WHITE);
DrawTextEx(font, "[Parrots font drawing]", textPosition, font.BaseSize, 0, Color.White);
}
else
{
DrawTexture(font.Texture, screenWidth / 2 - font.Texture.Width / 2, 50, Color.BLACK);
DrawTexture(font.Texture, screenWidth / 2 - font.Texture.Width / 2, 50, Color.Black);
}
DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, Color.DARKGRAY);
DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, Color.DarkGray);
EndDrawing();
//----------------------------------------------------------------------------------

Some files were not shown because too many files have changed in this diff Show More