2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-05 11:19:39 -04:00

Initial example update

- Updating examples with new changes.
This commit is contained in:
ChrisDill 2019-02-11 11:30:02 +00:00
parent f4ef94d63f
commit a01efa4a09
45 changed files with 419 additions and 389 deletions

View File

@ -34,7 +34,7 @@ public partial class audio_module_playing
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
@ -74,14 +74,14 @@ public partial class audio_module_playing
UpdateMusicStream(xm); // Update music buffer with new stream data
// Restart music playing (stop and play)
if (IsKeyPressed(KEY_SPACE))
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
{
StopMusicStream(xm);
PlayMusicStream(xm);
}
// Pause/Resume music playing
if (IsKeyPressed(KEY_P))
if (IsKeyPressed(KeyboardKey.KEY_P))
{
pause = !pause;

View File

@ -46,14 +46,14 @@ public partial class audio_music_stream
UpdateMusicStream(music); // Update music buffer with new stream data
// Restart music playing (stop and play)
if (IsKeyPressed(KEY_SPACE))
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
{
StopMusicStream(music);
PlayMusicStream(music);
}
// Pause/Resume music playing
if (IsKeyPressed(KEY_P))
if (IsKeyPressed(KeyboardKey.KEY_P))
{
pause = !pause;

View File

@ -39,8 +39,8 @@ public partial class audio_sound_loading
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE)) PlaySound(fxWav); // Play WAV sound
if (IsKeyPressed(KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound
if (IsKeyPressed(KeyboardKey.KEY_SPACE)) PlaySound(fxWav); // Play WAV sound
if (IsKeyPressed(KeyboardKey.KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound
//----------------------------------------------------------------------------------
// Draw

View File

@ -58,12 +58,12 @@ public partial class core_2d_camera
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KEY_RIGHT))
if (IsKeyDown(KeyboardKey.KEY_RIGHT))
{
player.x += 2; // Player movement
camera.offset.x -= 2; // Camera3D displacement with player movement
}
else if (IsKeyDown(KEY_LEFT))
else if (IsKeyDown(KeyboardKey.KEY_LEFT))
{
player.x -= 2; // Player movement
camera.offset.x += 2; // Camera3D displacement with player movement
@ -73,8 +73,8 @@ public partial class core_2d_camera
camera.target = new Vector2( player.x + 20, player.y + 20 );
// Camera3D rotation controls
if (IsKeyDown(KEY_A)) camera.rotation--;
else if (IsKeyDown(KEY_S)) camera.rotation++;
if (IsKeyDown(KeyboardKey.KEY_A)) camera.rotation--;
else if (IsKeyDown(KeyboardKey.KEY_S)) camera.rotation++;
// Limit camera rotation to 80 degrees (-40 to 40)
if (camera.rotation > 40) camera.rotation = 40;
@ -87,7 +87,7 @@ public partial class core_2d_camera
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
// Camera3D reset (zoom and rotation)
if (IsKeyPressed((int)KEY_R))
if (IsKeyPressed(KeyboardKey.KEY_R))
{
camera.zoom = 1.0f;
camera.rotation = 0.0f;

View File

@ -48,7 +48,7 @@ public partial class core_3d_camera_first_person
colors[i] = new Color( GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 );
}
SetCameraMode(camera, (int)CAMERA_FIRST_PERSON); // Set a first person camera mode
SetCameraMode(camera, CameraMode.CAMERA_FIRST_PERSON); // Set a first person camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@ public partial class core_3d_camera_free
Vector3 cubePosition = new Vector3( 0.0f, 0.0f, 0.0f );
SetCameraMode(camera, (int)CAMERA_FREE); // Set a free camera mode
SetCameraMode(camera, CameraMode.CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -48,7 +48,7 @@ public partial class core_3d_camera_free
//----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera
if (IsKeyDown('Z')) camera.target = new Vector3( 0.0f, 0.0f, 0.0f );
if (IsKeyDown(KeyboardKey.KEY_Z)) camera.target = new Vector3( 0.0f, 0.0f, 0.0f );
//----------------------------------------------------------------------------------
// Draw

View File

@ -41,7 +41,7 @@ public partial class core_3d_picking
bool collision = false;
SetCameraMode(camera, (int)CAMERA_FREE); // Set a free camera mode
SetCameraMode(camera, CameraMode.CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -53,7 +53,7 @@ public partial class core_3d_picking
//----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
{
ray = GetMouseRay(GetMousePosition(), camera);

View File

@ -59,7 +59,7 @@ public partial class core_color_select
{
colors[i].a = 120;
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) selected[i] = !selected[i];
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) selected[i] = !selected[i];
}
else colors[i].a = 255;
}

View File

@ -1,6 +1,10 @@
using Raylib;
using static Raylib.Raylib;
// using static Raylib.Gamepad;
using static Raylib.GamepadNumber;
using static Raylib.GamepadPS3Axis;
using static Raylib.GamepadPS3Button;
using static Raylib.GamepadXbox360Axis;
using static Raylib.GamepadXbox360Button;
public partial class core_input_gamepad
{
@ -35,7 +39,7 @@ public partial class core_input_gamepad
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
@ -68,45 +72,45 @@ public partial class core_input_gamepad
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
// Draw buttons: xbox home
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_HOME)) DrawCircle(394, 89, 19, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_HOME)) DrawCircle(394, 89, 19, RED);
// Draw buttons: basic
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_START)) DrawCircle(436, 150, 9, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_SELECT)) DrawCircle(352, 150, 9, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_X)) DrawCircle(501, 151, 15, BLUE);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_A)) DrawCircle(536, 187, 15, LIME);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_B)) DrawCircle(572, 151, 15, MAROON);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_Y)) DrawCircle(536, 115, 15, GOLD);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_START)) DrawCircle(436, 150, 9, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_SELECT)) DrawCircle(352, 150, 9, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_X)) DrawCircle(501, 151, 15, BLUE);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_A)) DrawCircle(536, 187, 15, LIME);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_B)) DrawCircle(572, 151, 15, MAROON);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_Y)) DrawCircle(536, 115, 15, GOLD);
// Draw buttons: d-pad
DrawRectangle(317, 202, 19, 71, BLACK);
DrawRectangle(293, 228, 69, 19, BLACK);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_UP)) DrawRectangle(317, 202, 19, 26, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_LEFT)) DrawRectangle(292, 228, 25, 19, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_UP)) DrawRectangle(317, 202, 19, 26, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_LEFT)) DrawRectangle(292, 228, 25, 19, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED);
// Draw buttons: left-right back
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_LB)) DrawCircle(259, 61, 20, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_RB)) DrawCircle(536, 61, 20, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_LB)) DrawCircle(259, 61, 20, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_BUTTON_RB)) DrawCircle(536, 61, 20, RED);
// Draw axis: left joystick
DrawCircle(259, 152, 39, BLACK);
DrawCircle(259, 152, 34, LIGHTGRAY);
DrawCircle(259 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_X) * 20),
152 - (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_Y) * 20), 25, BLACK);
DrawCircle(259 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_LEFT_X) * 20),
152 - (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_LEFT_Y) * 20), 25, BLACK);
// Draw axis: right joystick
DrawCircle(461, 237, 38, BLACK);
DrawCircle(461, 237, 33, LIGHTGRAY);
DrawCircle(461 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RIGHT_X) * 20),
237 - (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RIGHT_Y) * 20), 25, BLACK);
DrawCircle(461 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_RIGHT_X) * 20),
237 - (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_RIGHT_Y) * 20), 25, BLACK);
// Draw axis: left-right triggers
DrawRectangle(170, 30, 15, 70, GRAY);
DrawRectangle(604, 30, 15, 70, GRAY);
DrawRectangle(170, 30, 15, (int)(((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LT)) / 2.0f) * 70), RED);
DrawRectangle(604, 30, 15, (int)(((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RT)) / 2.0f) * 70), RED);
DrawRectangle(170, 30, 15, (int)(((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_LT)) / 2.0f) * 70), RED);
DrawRectangle(604, 30, 15, (int)(((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_XBOX_AXIS_RT)) / 2.0f) * 70), RED);
//DrawText(string.Format("Xbox axis LT: {0:00.00}", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LT)), 10, 40, 10, BLACK);
//DrawText(string.Format("Xbox axis RT: {0:00.00}", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RT)), 10, 60, 10, BLACK);
@ -116,46 +120,46 @@ public partial class core_input_gamepad
DrawTexture(texPs3Pad, 0, 0, DARKGRAY);
// Draw buttons: ps
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_PS)) DrawCircle(396, 222, 13, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_PS)) DrawCircle(396, 222, 13, RED);
// Draw buttons: basic
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_SELECT)) DrawRectangle(328, 170, 32, 13, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_START)) DrawTriangle(new Vector2(436, 168), new Vector2(436, 185), new Vector2(
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_SELECT)) DrawRectangle(328, 170, 32, 13, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_START)) DrawTriangle(new Vector2(436, 168), new Vector2(436, 185), new Vector2(
464, 177 ), RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_TRIANGLE)) DrawCircle(557, 144, 13, LIME);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_CIRCLE)) DrawCircle(586, 173, 13, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_CROSS)) DrawCircle(557, 203, 13, VIOLET);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_SQUARE)) DrawCircle(527, 173, 13, PINK);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_TRIANGLE)) DrawCircle(557, 144, 13, LIME);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_CIRCLE)) DrawCircle(586, 173, 13, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_CROSS)) DrawCircle(557, 203, 13, VIOLET);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_SQUARE)) DrawCircle(527, 173, 13, PINK);
// Draw buttons: d-pad
DrawRectangle(225, 132, 24, 84, BLACK);
DrawRectangle(195, 161, 84, 25, BLACK);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_UP)) DrawRectangle(225, 132, 24, 29, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_LEFT)) DrawRectangle(195, 161, 30, 25, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_UP)) DrawRectangle(225, 132, 24, 29, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_LEFT)) DrawRectangle(195, 161, 30, 25, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED);
// Draw buttons: left-right back buttons
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_L1)) DrawCircle(239, 82, 20, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_R1)) DrawCircle(557, 82, 20, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_L1)) DrawCircle(239, 82, 20, RED);
if (IsGamepadButtonDown(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_BUTTON_R1)) DrawCircle(557, 82, 20, RED);
// Draw axis: left joystick
DrawCircle(319, 255, 35, BLACK);
DrawCircle(319, 255, 31, LIGHTGRAY);
DrawCircle(319 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_LEFT_X) * 20),
255 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_LEFT_Y) * 20), 25, BLACK);
DrawCircle(319 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_LEFT_X) * 20),
255 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_LEFT_Y) * 20), 25, BLACK);
// Draw axis: right joystick
DrawCircle(475, 255, 35, BLACK);
DrawCircle(475, 255, 31, LIGHTGRAY);
DrawCircle(475 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_RIGHT_X) * 20),
255 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_RIGHT_Y) * 20), 25, BLACK);
DrawCircle(475 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_RIGHT_X) * 20),
255 + (int)(GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_RIGHT_Y) * 20), 25, BLACK);
// Draw axis: left-right triggers
DrawRectangle(169, 48, 15, 70, GRAY);
DrawRectangle(611, 48, 15, 70, GRAY);
DrawRectangle(169, 48, 15, (int)(((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_L2)) / 2.0f) * 70), RED);
DrawRectangle(611, 48, 15, (int)(((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_R2)) / 2.0f) * 70), RED);
DrawRectangle(169, 48, 15, (int)(((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_L2)) / 2.0f) * 70), RED);
DrawRectangle(611, 48, 15, (int)(((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, (int)GAMEPAD_PS3_AXIS_R2)) / 2.0f) * 70), RED);
}
else
{

View File

@ -34,10 +34,10 @@ public partial class core_input_keys
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f;
if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f;
if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f;
if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f;
if (IsKeyDown(KeyboardKey.KEY_RIGHT)) ballPosition.x += 2.0f;
if (IsKeyDown(KeyboardKey.KEY_LEFT)) ballPosition.x -= 2.0f;
if (IsKeyDown(KeyboardKey.KEY_UP)) ballPosition.y -= 2.0f;
if (IsKeyDown(KeyboardKey.KEY_DOWN)) ballPosition.y += 2.0f;
//----------------------------------------------------------------------------------
// Draw

View File

@ -37,9 +37,9 @@ public partial class core_input_mouse
//----------------------------------------------------------------------------------
ballPosition = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) ballColor = MAROON;
else if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
else if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
//----------------------------------------------------------------------------------
// Draw

View File

@ -39,18 +39,18 @@ public partial class core_storage_values
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_R))
if (IsKeyPressed(KeyboardKey.KEY_R))
{
score = GetRandomValue(1000, 2000);
hiscore = GetRandomValue(2000, 4000);
}
if (IsKeyPressed(KEY_ENTER))
if (IsKeyPressed(KeyboardKey.KEY_ENTER))
{
StorageSaveValue((int)StorageData.STORAGE_SCORE, score);
StorageSaveValue((int)StorageData.STORAGE_HISCORE, hiscore);
}
else if (IsKeyPressed(KEY_SPACE))
else if (IsKeyPressed(KeyboardKey.KEY_SPACE))
{
// NOTE: If requested position could not be found, value 0 is returned
score = StorageLoadValue((int)StorageData.STORAGE_SCORE);

View File

@ -29,7 +29,7 @@ public partial class core_vr_simulator
InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
// Init VR simulator (Oculus Rift CV1 parameters)
InitVrSimulator(GetVrDeviceInfo((int)HMD_OCULUS_RIFT_CV1));
InitVrSimulator(GetVrDeviceInfo(HMD_OCULUS_RIFT_CV1));
// Define the camera to look into our 3d world
Camera3D camera;
@ -41,7 +41,7 @@ public partial class core_vr_simulator
Vector3 cubePosition = new Vector3( 0.0f, 0.0f, 0.0f );
SetCameraMode(camera, (int)CAMERA_FIRST_PERSON); // Set first person camera mode
SetCameraMode(camera, CameraMode.CAMERA_FIRST_PERSON); // Set first person camera mode
SetTargetFPS(90); // Set our game to run at 90 frames-per-second
//--------------------------------------------------------------------------------------
@ -53,7 +53,7 @@ public partial class core_vr_simulator
//----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera (simulator mode)
if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode
if (IsKeyPressed(KeyboardKey.KEY_SPACE)) ToggleVrMode(); // Toggle VR mode
//----------------------------------------------------------------------------------
// Draw

View File

@ -38,7 +38,7 @@ public partial class core_world_screen
Vector2 cubeScreenPosition;
SetCameraMode(camera, (int)CAMERA_FREE); // Set a free camera mode
SetCameraMode(camera, CameraMode.CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -37,7 +37,7 @@ public partial class models_billboard
Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
Vector3 billPosition = new Vector3( 0.0f, 2.0f, 0.0f ); // Position where draw billboard
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -49,10 +49,10 @@ public partial class models_box_collisions
//----------------------------------------------------------------------------------
// Move player
if (IsKeyDown(KEY_RIGHT)) playerPosition.x += 0.2f;
else if (IsKeyDown(KEY_LEFT)) playerPosition.x -= 0.2f;
else if (IsKeyDown(KEY_DOWN)) playerPosition.z += 0.2f;
else if (IsKeyDown(KEY_UP)) playerPosition.z -= 0.2f;
if (IsKeyDown(KeyboardKey.KEY_RIGHT)) playerPosition.x += 0.2f;
else if (IsKeyDown(KeyboardKey.KEY_LEFT)) playerPosition.x -= 0.2f;
else if (IsKeyDown(KeyboardKey.KEY_DOWN)) playerPosition.z += 0.2f;
else if (IsKeyDown(KeyboardKey.KEY_UP)) playerPosition.z -= 0.2f;
collision = false;

View File

@ -43,7 +43,7 @@ public partial class models_cubicmap
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -40,7 +40,7 @@ public partial class models_heightmap
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -1,250 +1,273 @@
using Raylib;
using static Raylib.Raylib;
public enum LightType
{
LIGHT_DIRECTIONAL,
public enum LightType
{
LIGHT_DIRECTIONAL,
LIGHT_POINT
};
//TODO: move the light system out into it's own class file, rlights.h original
//also make it work properly
public struct Light
{
public bool enabled;
public LightType type;
public Vector3 position;
public Vector3 target;
public Color color;
public int enabledLoc;
public int typeLoc;
public int posLoc;
public int targetLoc;
public int colorLoc;
};
//TODO: move the light system out into it's own class file, rlights.h original
//also make it work properly
public struct Light
{
public bool enabled;
public LightType type;
public Vector3 position;
public Vector3 target;
public Color color;
public int enabledLoc;
public int typeLoc;
public int posLoc;
public int targetLoc;
public int colorLoc;
}
public partial class models_material_pbr
{
/******************************************************************************************* * * raylib [models] example - PBR material * * This example has been created using raylib 1.8 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2017 Ramon Santamaria (@raysan5) * ********************************************************************************************/
public const int CUBEMAP_SIZE = 512;
public const int IRRADIANCE_SIZE = 32;
public const int PREFILTERED_SIZE = 256;
public const int BRDF_SIZE = 512;
public const int MAX_LIGHTS = 4;
public static int lightsCount = 0;
public const float LIGHT_DISTANCE = 3.5f;
public const float LIGHT_HEIGHT = 1.0f;
// PBR material loading
//private static Material LoadMaterialPBR(Color albedo, float metalness, float roughness);
public unsafe static int Main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
// Define the camera to look into our 3d world
Camera3D camera = new Camera3D(new Vector3(4.0f, 4.0f, 4.0f), new Vector3(0.0f, 0.5f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), 45.0f, 0);
// Load model and PBR material
Model model = LoadModel("resources/pbr/trooper.obj");
MeshTangents(ref model.mesh);
model.material = LoadMaterialPBR(new Color(255, 255, 255, 255), 1.0f, 1.0f);
// Define lights attributes
// NOTE: Shader is passed to every light on creation to define shader bindings internally
Light[] lights = new Light[]
{
CreateLight(LightType.LIGHT_POINT, new Vector3( LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color( 255, 0, 0, 255 ), model.material.shader),
CreateLight(LightType.LIGHT_POINT, new Vector3( 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color( 0, 255, 0, 255 ), model.material.shader),
CreateLight(LightType.LIGHT_POINT, new Vector3( -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ),new Color( 0, 0, 255, 255 ), model.material.shader), CreateLight(LightType.LIGHT_DIRECTIONAL, new Vector3(0.0f, LIGHT_HEIGHT * 2.0f, -LIGHT_DISTANCE ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color(255, 0, 255, 255 ), model.material.shader)
};
SetCameraMode(camera, (int)CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera
// Send to material PBR shader camera view position
float[] cameraPos = { camera.position.x, camera.position.y, camera.position.z };
SetShaderValue(model.material.shader, model.material.shader.locs[(int)ShaderLocationIndex.LOC_VECTOR_VIEW], cameraPos, 3);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
DrawGrid(10, 1.0f);
EndMode3D();
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadModel(model); // Unload skybox model
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0; }
// Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps)
// NOTE: PBR shader is loaded inside this function
unsafe public static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
{
Material mat = new Material(); // NOTE: All maps textures are set to { 0 )
string PATH_PBR_VS = "resources/shaders/pbr.vs";
string PATH_PBR_FS = "resources/shaders/pbr.fs";
mat.shader = LoadShader(PATH_PBR_VS, PATH_PBR_FS);
// Get required locations points for PBR material
// NOTE: Those location names must be available and used in the shader code
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_ALBEDO] = GetShaderLocation(mat.shader, "albedo.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_OCCLUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
//mat.shader.locs[LOC_MAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
//mat.shader.locs[LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_PREFILTER] = GetShaderLocation(mat.shader, "prefilterMap");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT");
// Set view matrix location
mat.shader.locs[(int)ShaderLocationIndex.LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view"); //TODO: figure out why this is the one run warning we get, and it may be all that's needed to fix lights.
mat.shader.locs[(int)ShaderLocationIndex.LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
// Set PBR standard maps
mat.maps[(int)TexmapIndex.MAP_ALBEDO].texture = LoadTexture("resources/pbr/trooper_albedo.png");
mat.maps[(int)TexmapIndex.MAP_NORMAL].texture = LoadTexture("resources/pbr/trooper_normals.png");
mat.maps[(int)TexmapIndex.MAP_METALNESS].texture = LoadTexture("resources/pbr/trooper_metalness.png");
mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].texture = LoadTexture("resources/pbr/trooper_roughness.png");
mat.maps[(int)TexmapIndex.MAP_OCCLUSION].texture = LoadTexture("resources/pbr/trooper_ao.png");
// Set environment maps
const string PATH_CUBEMAP_VS = "resources/shaders/cubemap.vs"; // Path to equirectangular to cubemap vertex shader
const string PATH_CUBEMAP_FS = "resources/shaders/cubemap.fs"; // Path to equirectangular to cubemap fragment shader
const string PATH_SKYBOX_VS = "resources/shaders/skybox.vs"; // Path to skybox vertex shader
const string PATH_IRRADIANCE_FS = "resources/shaders/irradiance.fs"; // Path to irradiance (GI) calculation fragment shader
const string PATH_PREFILTER_FS = "resources/shaders/prefilter.fs"; // Path to reflection prefilter calculation fragment shader
const string PATH_BRDF_VS = "resources/shaders/brdf.vs"; // Path to bidirectional reflectance distribution function vertex shader
const string PATH_BRDF_FS = "resources/shaders/brdf.fs"; // Path to bidirectional reflectance distribution function fragment shader
Shader shdrCubemap = LoadShader(PATH_CUBEMAP_VS, PATH_CUBEMAP_FS);
Shader shdrIrradiance = LoadShader(PATH_SKYBOX_VS, PATH_IRRADIANCE_FS);
Shader shdrPrefilter = LoadShader(PATH_SKYBOX_VS, PATH_PREFILTER_FS);
Shader shdrBRDF = LoadShader(PATH_BRDF_VS, PATH_BRDF_FS);
// Setup required shader locations
SetShaderValuei(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), new int[] { 0 }, 1); SetShaderValuei(shdrIrradiance, GetShaderLocation(shdrIrradiance, "environmentMap"), new int[] { 0 }, 1); SetShaderValuei(shdrPrefilter, GetShaderLocation(shdrPrefilter, "environmentMap"), new int[] { 0 }, 1);
Texture2D texHDR = LoadTexture("resources/dresden_square.hdr");
Texture2D cubemap = GenTextureCubemap(shdrCubemap, texHDR, CUBEMAP_SIZE);
mat.maps[(int)TexmapIndex.MAP_IRRADIANCE].texture = GenTextureIrradiance(shdrIrradiance, cubemap, IRRADIANCE_SIZE);
mat.maps[(int)TexmapIndex.MAP_PREFILTER].texture = GenTexturePrefilter(shdrPrefilter, cubemap, PREFILTERED_SIZE);
mat.maps[(int)TexmapIndex.MAP_BRDF].texture = GenTextureBRDF(shdrBRDF, cubemap, BRDF_SIZE);
UnloadTexture(cubemap);
UnloadTexture(texHDR);
// Unload already used shaders (to create specific textures)
UnloadShader(shdrCubemap);
UnloadShader(shdrIrradiance);
UnloadShader(shdrPrefilter);
UnloadShader(shdrBRDF);
// Set textures filtering for better quality
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_ALBEDO].texture, (int)TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_NORMAL].texture, (int)TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_METALNESS].texture, (int)TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].texture, (int)TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_OCCLUSION].texture, (int)TextureFilterMode.FILTER_BILINEAR);
// Enable sample usage in shader for assigned textures
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "albedo.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "normals.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "metalness.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "roughness.useSampler"), new int[] { 1 }, 1); SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "occlusion.useSampler"), new int[] { 1 }, 1);
int renderModeLoc = GetShaderLocation(mat.shader, "renderMode");
SetShaderValuei(mat.shader, renderModeLoc, new int[] { 0 }, 1);
// Set up material properties color
mat.maps[(int)TexmapIndex.MAP_ALBEDO].color = albedo; mat.maps[(int)TexmapIndex.MAP_NORMAL].color = new Color(128, 128, 255, 255);
mat.maps[(int)TexmapIndex.MAP_METALNESS].value = metalness; mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].value = roughness; mat.maps[(int)TexmapIndex.MAP_OCCLUSION].value = 1.0f; mat.maps[(int)TexmapIndex.MAP_EMISSION].value = 0.5f; mat.maps[(int)TexmapIndex.MAP_HEIGHT].value = 0.5f;
return mat;
}
public static Light CreateLight(LightType type, Vector3 pos, Vector3 targ, Color color, Shader shader)
{
Light light = new Light();
if (lightsCount < MAX_LIGHTS)
{
light.enabled = true;
light.type = type;
light.position = pos;
light.target = targ;
light.color = color;
string enabledName = $"lights[{lightsCount}].enabled\0";
string typeName = $"lights[{lightsCount}].type\0";
string posName = $"lights[{lightsCount}].position\0";
string targetName = $"lights[{lightsCount}].target\0";
string colorName = $"lights[{lightsCount}].color\0";
light.enabledLoc = GetShaderLocation(shader, enabledName);
light.typeLoc = GetShaderLocation(shader, typeName);
light.posLoc = GetShaderLocation(shader, posName);
light.targetLoc = GetShaderLocation(shader, targetName);
light.colorLoc = GetShaderLocation(shader, colorName);
UpdateLightValues(shader, light);
lightsCount++;
}
return light;
}
public static void UpdateLightValues(Shader shader, Light light)
{
// Send to shader light enabled state and type
SetShaderValuei(shader, light.enabledLoc, new int[] { light.enabled ? 1 : 0 }, 1);
SetShaderValuei(shader, light.typeLoc, new int[] { (int)light.type }, 1);
// Send to shader light position values
float[] position = { light.position.x, light.position.y, light.position.z };
SetShaderValue(shader, light.posLoc, position, 3);
// Send to shader light target position values
float[] target = { light.target.x, light.target.y, light.target.z };
SetShaderValue(shader, light.targetLoc, target, 3);
// Send to shader light color values
float[] diff = { light.color.r / 255, light.color.g / 255, light.color.b / 255, light.color.a / 255 };
SetShaderValue(shader, light.colorLoc, diff, 4);
}
}
{
/*******************************************************************************************
*
* raylib [models] example - PBR material
*
* This example has been created using raylib 1.8 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
public const int CUBEMAP_SIZE = 512;
public const int IRRADIANCE_SIZE = 32;
public const int PREFILTERED_SIZE = 256;
public const int BRDF_SIZE = 512;
public const int MAX_LIGHTS = 4;
public static int lightsCount = 0;
public const float LIGHT_DISTANCE = 3.5f;
public const float LIGHT_HEIGHT = 1.0f;
// PBR material loading
//private static Material LoadMaterialPBR(Color albedo, float metalness, float roughness);
public unsafe static int Main()
{
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");
// Define the camera to look into our 3d world
Camera3D camera = new Camera3D(new Vector3(4.0f, 4.0f, 4.0f), new Vector3(0.0f, 0.5f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), 45.0f, 0);
// Load model and PBR material
Model model = LoadModel("resources/pbr/trooper.obj");
MeshTangents(ref model.mesh);
model.material = LoadMaterialPBR(new Color(255, 255, 255, 255), 1.0f, 1.0f);
// Define lights attributes
// NOTE: Shader is passed to every light on creation to define shader bindings internally
Light[] lights = new Light[]
{
CreateLight(LightType.LIGHT_POINT, new Vector3( LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color( 255, 0, 0, 255 ), model.material.shader),
CreateLight(LightType.LIGHT_POINT, new Vector3( 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color( 0, 255, 0, 255 ), model.material.shader),
CreateLight(LightType.LIGHT_POINT, new Vector3( -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f ), new Vector3( 0.0f, 0.0f, 0.0f ),new Color( 0, 0, 255, 255 ), model.material.shader),
CreateLight(LightType.LIGHT_DIRECTIONAL, new Vector3(0.0f, LIGHT_HEIGHT * 2.0f, -LIGHT_DISTANCE ), new Vector3( 0.0f, 0.0f, 0.0f ), new Color(255, 0, 255, 255 ), model.material.shader)
};
SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera
// Send to material PBR shader camera view position
float[] cameraPos = { camera.position.x, camera.position.y, camera.position.z };
SetShaderValue(model.material.shader, model.material.shader.locs[(int)ShaderLocationIndex.LOC_VECTOR_VIEW], cameraPos, 3);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
DrawGrid(10, 1.0f);
EndMode3D();
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadModel(model); // Unload skybox model
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
// Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps)
// NOTE: PBR shader is loaded inside this function
unsafe public static Material LoadMaterialPBR(Color albedo, float metalness, float roughness)
{
Material mat = new Material(); // NOTE: All maps textures are set to { 0 )
string PATH_PBR_VS = "resources/shaders/pbr.vs";
string PATH_PBR_FS = "resources/shaders/pbr.fs";
mat.shader = LoadShader(PATH_PBR_VS, PATH_PBR_FS);
// Get required locations points for PBR material
// NOTE: Those location names must be available and used in the shader code
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_ALBEDO] = GetShaderLocation(mat.shader, "albedo.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_OCCLUSION] = GetShaderLocation(mat.shader, "occlusion.sampler");
//mat.shader.locs[LOC_MAP_EMISSION] = GetShaderLocation(mat.shader, "emission.sampler");
//mat.shader.locs[LOC_MAP_HEIGHT] = GetShaderLocation(mat.shader, "height.sampler");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_PREFILTER] = GetShaderLocation(mat.shader, "prefilterMap");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT");
// Set view matrix location
mat.shader.locs[(int)ShaderLocationIndex.LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel");
mat.shader.locs[(int)ShaderLocationIndex.LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view"); //TODO: figure out why this is the one run warning we get, and it may be all that's needed to fix lights.
mat.shader.locs[(int)ShaderLocationIndex.LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos");
// Set PBR standard maps
mat.maps[(int)TexmapIndex.MAP_ALBEDO].texture = LoadTexture("resources/pbr/trooper_albedo.png");
mat.maps[(int)TexmapIndex.MAP_NORMAL].texture = LoadTexture("resources/pbr/trooper_normals.png");
mat.maps[(int)TexmapIndex.MAP_METALNESS].texture = LoadTexture("resources/pbr/trooper_metalness.png");
mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].texture = LoadTexture("resources/pbr/trooper_roughness.png");
mat.maps[(int)TexmapIndex.MAP_OCCLUSION].texture = LoadTexture("resources/pbr/trooper_ao.png");
// Set environment maps
const string PATH_CUBEMAP_VS = "resources/shaders/cubemap.vs"; // Path to equirectangular to cubemap vertex shader
const string PATH_CUBEMAP_FS = "resources/shaders/cubemap.fs"; // Path to equirectangular to cubemap fragment shader
const string PATH_SKYBOX_VS = "resources/shaders/skybox.vs"; // Path to skybox vertex shader
const string PATH_IRRADIANCE_FS = "resources/shaders/irradiance.fs"; // Path to irradiance (GI) calculation fragment shader
const string PATH_PREFILTER_FS = "resources/shaders/prefilter.fs"; // Path to reflection prefilter calculation fragment shader
const string PATH_BRDF_VS = "resources/shaders/brdf.vs"; // Path to bidirectional reflectance distribution function vertex shader
const string PATH_BRDF_FS = "resources/shaders/brdf.fs"; // Path to bidirectional reflectance distribution function fragment shader
Shader shdrCubemap = LoadShader(PATH_CUBEMAP_VS, PATH_CUBEMAP_FS);
Shader shdrIrradiance = LoadShader(PATH_SKYBOX_VS, PATH_IRRADIANCE_FS);
Shader shdrPrefilter = LoadShader(PATH_SKYBOX_VS, PATH_PREFILTER_FS);
Shader shdrBRDF = LoadShader(PATH_BRDF_VS, PATH_BRDF_FS);
// Setup required shader locations
SetShaderValuei(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), new int[] { 0 }, 1);
SetShaderValuei(shdrIrradiance, GetShaderLocation(shdrIrradiance, "environmentMap"), new int[] { 0 }, 1);
SetShaderValuei(shdrPrefilter, GetShaderLocation(shdrPrefilter, "environmentMap"), new int[] { 0 }, 1);
Texture2D texHDR = LoadTexture("resources/dresden_square.hdr");
Texture2D cubemap = GenTextureCubemap(shdrCubemap, texHDR, CUBEMAP_SIZE);
mat.maps[(int)TexmapIndex.MAP_IRRADIANCE].texture = GenTextureIrradiance(shdrIrradiance, cubemap, IRRADIANCE_SIZE);
mat.maps[(int)TexmapIndex.MAP_PREFILTER].texture = GenTexturePrefilter(shdrPrefilter, cubemap, PREFILTERED_SIZE);
mat.maps[(int)TexmapIndex.MAP_BRDF].texture = GenTextureBRDF(shdrBRDF, cubemap, BRDF_SIZE);
UnloadTexture(cubemap);
UnloadTexture(texHDR);
// Unload already used shaders (to create specific textures)
UnloadShader(shdrCubemap);
UnloadShader(shdrIrradiance);
UnloadShader(shdrPrefilter);
UnloadShader(shdrBRDF);
// Set textures filtering for better quality
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_ALBEDO].texture, TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_NORMAL].texture, TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_METALNESS].texture, TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].texture, TextureFilterMode.FILTER_BILINEAR);
SetTextureFilter(mat.maps[(int)TexmapIndex.MAP_OCCLUSION].texture, TextureFilterMode.FILTER_BILINEAR);
// Enable sample usage in shader for assigned textures
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "albedo.useSampler"), new int[] { 1 }, 1);
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "normals.useSampler"), new int[] { 1 }, 1);
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "metalness.useSampler"), new int[] { 1 }, 1);
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "roughness.useSampler"), new int[] { 1 }, 1);
SetShaderValuei(mat.shader, GetShaderLocation(mat.shader, "occlusion.useSampler"), new int[] { 1 }, 1);
int renderModeLoc = GetShaderLocation(mat.shader, "renderMode");
SetShaderValuei(mat.shader, renderModeLoc, new int[] { 0 }, 1);
// Set up material properties color
mat.maps[(int)TexmapIndex.MAP_ALBEDO].color = albedo;
mat.maps[(int)TexmapIndex.MAP_NORMAL].color = new Color(128, 128, 255, 255);
mat.maps[(int)TexmapIndex.MAP_METALNESS].value = metalness;
mat.maps[(int)TexmapIndex.MAP_ROUGHNESS].value = roughness;
mat.maps[(int)TexmapIndex.MAP_OCCLUSION].value = 1.0f;
mat.maps[(int)TexmapIndex.MAP_EMISSION].value = 0.5f;
mat.maps[(int)TexmapIndex.MAP_HEIGHT].value = 0.5f;
return mat;
}
public static Light CreateLight(LightType type, Vector3 pos, Vector3 targ, Color color, Shader shader)
{
Light light = new Light();
if (lightsCount < MAX_LIGHTS)
{
light.enabled = true;
light.type = type;
light.position = pos;
light.target = targ;
light.color = color;
string enabledName = $"lights[{lightsCount}].enabled\0";
string typeName = $"lights[{lightsCount}].type\0";
string posName = $"lights[{lightsCount}].position\0";
string targetName = $"lights[{lightsCount}].target\0";
string colorName = $"lights[{lightsCount}].color\0";
light.enabledLoc = GetShaderLocation(shader, enabledName);
light.typeLoc = GetShaderLocation(shader, typeName);
light.posLoc = GetShaderLocation(shader, posName);
light.targetLoc = GetShaderLocation(shader, targetName);
light.colorLoc = GetShaderLocation(shader, colorName);
UpdateLightValues(shader, light);
lightsCount++;
}
return light;
}
public static void UpdateLightValues(Shader shader, Light light)
{
// Send to shader light enabled state and type
SetShaderValuei(shader, light.enabledLoc, new int[] { light.enabled ? 1 : 0 }, 1);
SetShaderValuei(shader, light.typeLoc, new int[] { (int)light.type }, 1);
// Send to shader light position values
float[] position = { light.position.x, light.position.y, light.position.z };
SetShaderValue(shader, light.posLoc, position, 3);
// Send to shader light target position values
float[] target = { light.target.x, light.target.y, light.target.z };
SetShaderValue(shader, light.targetLoc, target, 3);
// Send to shader light color values
float[] diff = { light.color.r / 255, light.color.g / 255, light.color.b / 255, light.color.a / 255 };
SetShaderValue(shader, light.colorLoc, diff, 4);
}
}

View File

@ -54,7 +54,7 @@ public partial class models_mesh_generation
int currentModel = 0;
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set a orbital camera mode
SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set a orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -66,7 +66,7 @@ public partial class models_mesh_generation
//----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update internal camera and our camera
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON))
{
currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures
}

View File

@ -56,7 +56,7 @@ public partial class models_mesh_picking
Vector3 bary = new Vector3( 0.0f, 0.0f, 0.0f );
SetCameraMode(camera, (int)CAMERA_FREE); // Set a free camera mode
SetCameraMode(camera, CameraMode.CAMERA_FREE); // Set a free camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second

View File

@ -42,7 +42,7 @@ public partial class models_orthographic_projection
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_SPACE))
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
{
if (camera.type == CAMERA_PERSPECTIVE)
{

View File

@ -52,7 +52,7 @@ public partial class models_skybox
UnloadTexture(texHDR); // Texture not required anymore, cubemap already generated
UnloadShader(shdrCubemap); // Unload cubemap generation shader, not required anymore
SetCameraMode(camera, (int)CAMERA_FIRST_PERSON); // Set a first person camera mode
SetCameraMode(camera, CameraMode.CAMERA_FIRST_PERSON); // Set a first person camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -70,8 +70,8 @@ public partial class models_yaw_pitch_roll
//----------------------------------------------------------------------------------
// Plane roll (x-axis) controls
if (IsKeyDown(KEY_LEFT)) roll += 1.0f;
else if (IsKeyDown(KEY_RIGHT)) roll -= 1.0f;
if (IsKeyDown(KeyboardKey.KEY_LEFT)) roll += 1.0f;
else if (IsKeyDown(KeyboardKey.KEY_RIGHT)) roll -= 1.0f;
else
{
if (roll > 0.0f) roll -= 0.5f;
@ -79,8 +79,8 @@ public partial class models_yaw_pitch_roll
}
// Plane yaw (y-axis) controls
if (IsKeyDown(KEY_S)) yaw += 1.0f;
else if (IsKeyDown(KEY_A)) yaw -= 1.0f;
if (IsKeyDown(KeyboardKey.KEY_S)) yaw += 1.0f;
else if (IsKeyDown(KeyboardKey.KEY_A)) yaw -= 1.0f;
else
{
if (yaw > 0.0f) yaw -= 0.5f;
@ -88,8 +88,8 @@ public partial class models_yaw_pitch_roll
}
// Plane pitch (z-axis) controls
if (IsKeyDown(KEY_DOWN)) pitch += 0.6f;
else if (IsKeyDown(KEY_UP)) pitch -= 0.6f;
if (IsKeyDown(KeyboardKey.KEY_DOWN)) pitch += 0.6f;
else if (IsKeyDown(KeyboardKey.KEY_UP)) pitch -= 0.6f;
else
{
if (pitch > 0.3f) pitch -= 0.3f;

View File

@ -47,7 +47,7 @@ public partial class bunnymark
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON))
{
// Create more bunnies
for (int i = 0; i < 100; i++)

View File

@ -29,7 +29,7 @@ public partial class physics_demo
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics demo");
// Physac logo drawing position
@ -75,15 +75,15 @@ public partial class physics_demo
}
// Reset physics input
if (IsKeyPressed('R'))
if (IsKeyPressed(KeyboardKey.KEY_R))
{
ResetPhysics();
needsReset = true;
}
// Physics body creation inputs
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) CreatePhysicsBodyPolygon(GetMousePosition(), GetRandomValue(20, 80), GetRandomValue(3, 8), 10);
else if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) CreatePhysicsBodyCircle(GetMousePosition(), GetRandomValue(10, 45), 10);
// Destroy falling physics bodies
int bodiesCount = GetPhysicsBodiesCount();

View File

@ -28,7 +28,7 @@ public partial class physics_friction
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics friction");
// Physac logo drawing position
@ -73,7 +73,7 @@ public partial class physics_friction
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed('R')) // Reset physics input
if (IsKeyPressed(KeyboardKey.KEY_R)) // Reset physics input
{
// Reset dynamic physics bodies position, velocity and rotation
bodyA.position = new Vector2( 35, screenHeight*0.6f );

View File

@ -30,7 +30,7 @@ public partial class physics_movement
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics movement");
// Physac logo drawing position
@ -68,7 +68,7 @@ public partial class physics_movement
//----------------------------------------------------------------------------------
RunPhysicsStep();
if (IsKeyPressed('R')) // Reset physics input
if (IsKeyPressed(KeyboardKey.KEY_R)) // Reset physics input
{
// Reset movement physics body position, velocity and rotation
body.position = new Vector2( screenWidth/2, screenHeight/2 );
@ -77,11 +77,11 @@ public partial class physics_movement
}
// Horizontal movement input
if (IsKeyDown(KEY_RIGHT)) body.velocity.x = VELOCITY;
else if (IsKeyDown(KEY_LEFT)) body.velocity.x = -VELOCITY;
if (IsKeyDown(KeyboardKey.KEY_RIGHT)) body.velocity.x = VELOCITY;
else if (IsKeyDown(KeyboardKey.KEY_LEFT)) body.velocity.x = -VELOCITY;
// Vertical movement input checking if player physics body is grounded
if (IsKeyDown(KEY_UP) && body.isGrounded) body.velocity.y = -VELOCITY*4;
if (IsKeyDown(KeyboardKey.KEY_UP) && body.isGrounded) body.velocity.y = -VELOCITY*4;
//----------------------------------------------------------------------------------
// Draw

View File

@ -28,7 +28,7 @@ public partial class physics_restitution
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics restitution");
// Physac logo drawing position
@ -61,7 +61,7 @@ public partial class physics_restitution
//----------------------------------------------------------------------------------
RunPhysicsStep();
if (IsKeyPressed('R')) // Reset physics input
if (IsKeyPressed(KeyboardKey.KEY_R)) // Reset physics input
{
// Reset circles physics bodies position and velocity
circleA.position = new Vector2( screenWidth*0.25f, screenHeight/2 );

View File

@ -28,7 +28,7 @@ public partial class physics_shatter
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Body shatter");
// Physac logo drawing position
@ -60,13 +60,13 @@ public partial class physics_shatter
CreatePhysicsBodyPolygon(new Vector2( screenWidth/2, screenHeight/2 ), GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
}
if (IsKeyPressed('R')) // Reset physics input
if (IsKeyPressed(KeyboardKey.KEY_R)) // Reset physics input
{
ResetPhysics();
needsReset = true;
}
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) // Physics shatter input
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) // Physics shatter input
{
// Note: some values need to be stored in variables due to asynchronous changes during main thread
int count = GetPhysicsBodiesCount();

View File

@ -32,7 +32,7 @@ public partial class shaders_custom_uniform
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable");
@ -63,7 +63,7 @@ public partial class shaders_custom_uniform
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
// Setup orbital camera
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -91,6 +91,7 @@ public partial class shaders_custom_uniform
ClearBackground(RAYWHITE);
BeginTextureMode(target); // Enable drawing to texture
ClearBackground(RAYWHITE);
BeginMode3D(camera);

View File

@ -32,7 +32,7 @@ public partial class shaders_model_shader
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
@ -54,7 +54,7 @@ public partial class shaders_model_shader
Vector3 position = new Vector3( 0.0f, 0.0f, 0.0f ); // Set model position
SetCameraMode(camera, (int)CAMERA_FREE); // Set an orbital camera mode
SetCameraMode(camera, CameraMode.CAMERA_FREE); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

View File

@ -70,7 +70,7 @@ public partial class shaders_postprocessing
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
@ -108,7 +108,7 @@ public partial class shaders_postprocessing
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
// Setup orbital camera
SetCameraMode(camera, (int)CAMERA_ORBITAL); // Set an orbital camera mode
SetCameraMode(camera, CameraMode.CAMERA_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -120,8 +120,8 @@ public partial class shaders_postprocessing
//----------------------------------------------------------------------------------
UpdateCamera(ref camera); // Update camera
if (IsKeyPressed(KEY_RIGHT)) currentShader++;
else if (IsKeyPressed(KEY_LEFT)) currentShader--;
if (IsKeyPressed(KeyboardKey.KEY_RIGHT)) currentShader++;
else if (IsKeyPressed(KeyboardKey.KEY_LEFT)) currentShader--;
if (currentShader >= MAX_POSTPRO_SHADERS) currentShader = 0;
else if (currentShader < 0) currentShader = MAX_POSTPRO_SHADERS - 1;
@ -134,8 +134,9 @@ public partial class shaders_postprocessing
ClearBackground(RAYWHITE);
BeginTextureMode(target); // Enable drawing to texture
ClearBackground(RAYWHITE);
BeginMode3D(camera);
BeginMode3D(camera);
DrawModel(model, position, 0.1f, WHITE); // Draw 3d model with texture

View File

@ -22,7 +22,7 @@ public partial class shapes_lines_bezier
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(ConfigFlag.FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines");
Vector2 start = new Vector2( 0, 0 );
@ -36,8 +36,8 @@ public partial class shapes_lines_bezier
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition();
else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition();
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON)) start = GetMousePosition();
else if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON)) end = GetMousePosition();
//----------------------------------------------------------------------------------
// Draw

View File

@ -95,7 +95,7 @@ public partial class shapes_logo_raylib_anim
}
else if (state == 4) // State 4: Reset and Replay
{
if (IsKeyPressed('R'))
if (IsKeyPressed(KeyboardKey.KEY_R))
{
framesCounter = 0;
lettersCount = 0;

View File

@ -55,7 +55,7 @@ public partial class text_font_sdf
// Load SDF required shader (we use default vertex shader)
Shader shader = LoadShader(null, "resources/shaders/sdf.fs");
SetTextureFilter(fontSDF.texture, (int)FILTER_BILINEAR); // Required for SDF font
SetTextureFilter(fontSDF.texture, TextureFilterMode.FILTER_BILINEAR); // Required for SDF font
Vector2 fontPosition = new Vector2( 40, screenHeight/2 - 50 );
Vector2 textSize = new Vector2( 0.0f );
@ -74,7 +74,7 @@ public partial class text_font_sdf
if (fontSize < 6) fontSize = 6;
if (IsKeyDown(KEY_SPACE)) currentFont = 1;
if (IsKeyDown(KeyboardKey.KEY_SPACE)) currentFont = 1;
else currentFont = 0;
if (currentFont == 0) textSize = MeasureTextEx(fontDefault, msg, fontSize, 0);

View File

@ -57,7 +57,7 @@ public partial class text_input_box
letterCount++;
}
if (IsKeyPressed(KEY_BACKSPACE))
if (IsKeyPressed(KeyboardKey.KEY_BACKSPACE))
{
letterCount--;
if (letterCount < 0) letterCount = 0;
@ -109,7 +109,7 @@ public partial class text_input_box
}
// Check if any key is pressed
// NOTE: We limit keys check to keys between 32 (KEY_SPACE) and 126
// NOTE: We limit keys check to keys between 32 (KeyboardKey.KEY_SPACE) and 126
bool IsAnyKeyPressed()
{
bool keyPressed = false;

View File

@ -40,7 +40,7 @@ public partial class text_ttf_loading
Vector2 fontPosition = new Vector2( 40, screenHeight/2 - 80 );
Vector2 textSize;
SetTextureFilter(font.texture, (int)FILTER_POINT);
SetTextureFilter(font.texture, TextureFilterMode.FILTER_POINT);
int currentFontFilter = 0; // FILTER_POINT
// NOTE: Drag and drop support only available for desktop platforms: Windows, Linux, OSX
@ -57,27 +57,27 @@ public partial class text_ttf_loading
fontSize += GetMouseWheelMove()*4.0f;
// Choose font texture filter method
if (IsKeyPressed(KEY_ONE))
if (IsKeyPressed(KeyboardKey.KEY_ONE))
{
SetTextureFilter(font.texture, (int)FILTER_POINT);
SetTextureFilter(font.texture, TextureFilterMode.FILTER_POINT);
currentFontFilter = 0;
}
else if (IsKeyPressed(KEY_TWO))
else if (IsKeyPressed(KeyboardKey.KEY_TWO))
{
SetTextureFilter(font.texture, (int)FILTER_BILINEAR);
SetTextureFilter(font.texture, TextureFilterMode.FILTER_BILINEAR);
currentFontFilter = 1;
}
else if (IsKeyPressed(KEY_THREE))
else if (IsKeyPressed(KeyboardKey.KEY_THREE))
{
// NOTE: Trilinear filter won't be noticed on 2D drawing
SetTextureFilter(font.texture, (int)FILTER_TRILINEAR);
SetTextureFilter(font.texture, TextureFilterMode.FILTER_TRILINEAR);
currentFontFilter = 2;
}
textSize = MeasureTextEx(font, msg, fontSize, 0);
if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10;
else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10;
if (IsKeyDown(KeyboardKey.KEY_LEFT)) fontPosition.x -= 10;
else if (IsKeyDown(KeyboardKey.KEY_RIGHT)) fontPosition.x += 10;
// Load a dropped TTF file dynamically (at current fontSize)
if (IsFileDropped())

View File

@ -36,10 +36,10 @@ public partial class text_writing_anim
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KEY_SPACE)) framesCounter += 8;
if (IsKeyDown(KeyboardKey.KEY_SPACE)) framesCounter += 8;
else framesCounter++;
if (IsKeyPressed(KEY_ENTER)) framesCounter = 0;
if (IsKeyPressed(KeyboardKey.KEY_ENTER)) framesCounter = 0;
//----------------------------------------------------------------------------------
// Draw

View File

@ -62,7 +62,7 @@ public partial class textures_image_generation
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_RIGHT))
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON) || IsKeyPressed(KeyboardKey.KEY_RIGHT))
{
currentTexture = (currentTexture + 1)%NUM_TEXTURES; // Cycle between the textures
}

View File

@ -74,13 +74,13 @@ public partial class textures_image_processing
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_DOWN))
if (IsKeyPressed(KeyboardKey.KEY_DOWN))
{
currentProcess++;
if (currentProcess > 7) currentProcess = 0;
textureReload = true;
}
else if (IsKeyPressed(KEY_UP))
else if (IsKeyPressed(KeyboardKey.KEY_UP))
{
currentProcess--;
if (currentProcess < 0) currentProcess = 7;

View File

@ -47,7 +47,7 @@ public partial class textures_image_text
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KEY_SPACE)) showFont = true;
if (IsKeyDown(KeyboardKey.KEY_SPACE)) showFont = true;
else showFont = false;
//----------------------------------------------------------------------------------

View File

@ -56,7 +56,7 @@ public partial class textures_particles_blending
Texture2D smoke = LoadTexture("resources/smoke.png");
int blending = (int)BLEND_ALPHA;
var blending = BlendMode.BLEND_ALPHA;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -95,10 +95,10 @@ public partial class textures_particles_blending
}
}
if (IsKeyPressed(KEY_SPACE))
if (IsKeyPressed(KeyboardKey.KEY_SPACE))
{
if (blending == (int)BLEND_ALPHA) blending = (int)BLEND_ADDITIVE;
else blending = (int)BLEND_ALPHA;
if (blending == BlendMode.BLEND_ALPHA) blending = BlendMode.BLEND_ADDITIVE;
else blending = BlendMode.BLEND_ALPHA;
}
//----------------------------------------------------------------------------------

View File

@ -57,8 +57,8 @@ public partial class textures_rectangle
frameRec.x = (float)currentFrame*(float)scarfy.width/6;
}
if (IsKeyPressed(KEY_RIGHT)) framesSpeed++;
else if (IsKeyPressed(KEY_LEFT)) framesSpeed--;
if (IsKeyPressed(KeyboardKey.KEY_RIGHT)) framesSpeed++;
else if (IsKeyPressed(KeyboardKey.KEY_LEFT)) framesSpeed--;
if (framesSpeed > MAX_FRAME_SPEED) framesSpeed = MAX_FRAME_SPEED;
else if (framesSpeed < MIN_FRAME_SPEED) framesSpeed = MIN_FRAME_SPEED;

View File

@ -2,6 +2,7 @@
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Raylib;
using static Raylib.Raylib;
namespace Test.NetFX
@ -54,7 +55,7 @@ namespace Test.NetFX
private void Test()
{
SetConfigFlags(FLAG_WINDOW_UNDECORATED);
SetConfigFlags(ConfigFlag.FLAG_WINDOW_UNDECORATED);
InitWindow(800, 480, "Rayforms test");
SetTargetFPS(60);