diff options
| author | Ray <[email protected]> | 2019-05-21 17:03:01 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-21 17:03:01 +0200 |
| commit | 6f4a27cc61f12d3789729413bed69e86226911cf (patch) | |
| tree | 92a23884870826e6deaf560743ebbdae8bce94ba | |
| parent | 2141d7943b6b65fa66f583f0819bb27fee815189 (diff) | |
| download | raylib.com-6f4a27cc61f12d3789729413bed69e86226911cf.tar.gz raylib.com-6f4a27cc61f12d3789729413bed69e86226911cf.zip | |
Remove examples default code
Code is directly fetched form raylib repo, this way we avoid duplicate code!
96 files changed, 0 insertions, 10493 deletions
diff --git a/examples/src/audio/audio_module_playing.c b/examples/src/audio/audio_module_playing.c deleted file mode 100644 index 4aebd1e..0000000 --- a/examples/src/audio/audio_module_playing.c +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************************* -* -* raylib [audio] example - Module playing (streaming) -* -* NOTE: This example requires OpenAL Soft library installed -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_CIRCLES 64 - -typedef struct { - Vector2 position; - float radius; - float alpha; - float speed; - Color color; -} CircleWave; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X - - InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)"); - - InitAudioDevice(); // Initialize audio device - - Color colors[14] = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, - YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE }; - - // Creates ome circles for visual effect - CircleWave circles[MAX_CIRCLES]; - - for (int i = MAX_CIRCLES - 1; i >= 0; i--) - { - circles[i].alpha = 0.0f; - circles[i].radius = GetRandomValue(10, 40); - circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius); - circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius); - circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f; - circles[i].color = colors[GetRandomValue(0, 13)]; - } - - Music xm = LoadMusicStream("resources/chiptun1.mod"); - - PlayMusicStream(xm); - - float timePlayed = 0.0f; - bool pause = false; - - 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 - //---------------------------------------------------------------------------------- - UpdateMusicStream(xm); // Update music buffer with new stream data - - // Restart music playing (stop and play) - if (IsKeyPressed(KEY_SPACE)) - { - StopMusicStream(xm); - PlayMusicStream(xm); - } - - // Pause/Resume music playing - if (IsKeyPressed(KEY_P)) - { - pause = !pause; - - if (pause) PauseMusicStream(xm); - else ResumeMusicStream(xm); - } - - // Get timePlayed scaled to bar dimensions - timePlayed = GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40); - - // Color circles animation - for (int i = MAX_CIRCLES - 1; (i >= 0) && !pause; i--) - { - circles[i].alpha += circles[i].speed; - circles[i].radius += circles[i].speed*10.0f; - - if (circles[i].alpha > 1.0f) circles[i].speed *= -1; - - if (circles[i].alpha <= 0.0f) - { - circles[i].alpha = 0.0f; - circles[i].radius = GetRandomValue(10, 40); - circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius); - circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius); - circles[i].color = colors[GetRandomValue(0, 13)]; - circles[i].speed = (float)GetRandomValue(1, 100)/20000.0f; - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - for (int i = MAX_CIRCLES - 1; i >= 0; i--) - { - DrawCircleV(circles[i].position, circles[i].radius, Fade(circles[i].color, circles[i].alpha)); - } - - // Draw time bar - DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY); - DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON); - DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadMusicStream(xm); // Unload music stream buffers from RAM - - CloseAudioDevice(); // Close audio device (music streaming is automatically stopped) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/audio/audio_music_stream.c b/examples/src/audio/audio_music_stream.c deleted file mode 100644 index 76efb7d..0000000 --- a/examples/src/audio/audio_music_stream.c +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************************* -* -* raylib [audio] example - Music playing (streaming) -* -* NOTE: This example requires OpenAL Soft library installed -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)"); - - InitAudioDevice(); // Initialize audio device - - Music music = LoadMusicStream("resources/guitar_noodling.ogg"); - - PlayMusicStream(music); - - float timePlayed = 0.0f; - bool pause = false; - - 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 - //---------------------------------------------------------------------------------- - UpdateMusicStream(music); // Update music buffer with new stream data - - // Restart music playing (stop and play) - if (IsKeyPressed(KEY_SPACE)) - { - StopMusicStream(music); - PlayMusicStream(music); - } - - // Pause/Resume music playing - if (IsKeyPressed(KEY_P)) - { - pause = !pause; - - if (pause) PauseMusicStream(music); - else ResumeMusicStream(music); - } - - // Get timePlayed scaled to bar dimensions (400 pixels) - timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*400; - - if (timePlayed > 400) StopMusicStream(music); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY); - - DrawRectangle(200, 200, 400, 12, LIGHTGRAY); - DrawRectangle(200, 200, (int)timePlayed, 12, MAROON); - DrawRectangleLines(200, 200, 400, 12, GRAY); - - DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY); - DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadMusicStream(music); // Unload music stream buffers from RAM - - CloseAudioDevice(); // Close audio device (music streaming is automatically stopped) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/audio/audio_raw_stream.c b/examples/src/audio/audio_raw_stream.c deleted file mode 100644 index b114173..0000000 --- a/examples/src/audio/audio_raw_stream.c +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************************* -* -* raylib [audio] example - Raw audio streaming -* -* NOTE: This example requires OpenAL Soft library installed -* -* This example has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015-2019 Ramon Santamaria (@raysan5) and James Hofmann (@triplefox) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <stdlib.h> // Required for: malloc(), free() -#include <math.h> // Required for: sinf() -#include <string.h> // Required for: memcpy() - -#define MAX_SAMPLES 512 -#define MAX_SAMPLES_PER_UPDATE 4096 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming"); - - InitAudioDevice(); // Initialize audio device - - // Init raw audio stream (sample rate: 22050, sample size: 16bit-short, channels: 1-mono) - AudioStream stream = InitAudioStream(22050, 16, 1); - - // Buffer for the single cycle waveform we are synthesizing - short *data = (short *)malloc(sizeof(short)*MAX_SAMPLES); - - // Frame buffer, describing the waveform when repeated over the course of a frame - short *writeBuf = (short *)malloc(sizeof(short)*MAX_SAMPLES_PER_UPDATE); - - PlayAudioStream(stream); // Start processing stream buffer (no data loaded currently) - - // Position read in to determine next frequency - Vector2 mousePosition = { -100.0f, -100.0f }; - - // Cycles per second (hz) - float frequency = 440.0f; - - // Previous value, used to test if sine needs to be rewritten, and to smoothly modulate frequency - float oldFrequency = 1.0f; - - // Cursor to read and copy the samples of the sine wave buffer - int readCursor = 0; - - // Computed size in samples of the sine wave - int waveLength = 1; - - Vector2 position = { 0, 0 }; - - SetTargetFPS(30); // Set our game to run at 30 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Sample mouse input. - mousePosition = GetMousePosition(); - - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) - { - float fp = (float)(mousePosition.y); - frequency = 40.0f + (float)(fp); - } - - // Rewrite the sine wave. - // Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc. - if (frequency != oldFrequency) - { - // Compute wavelength. Limit size in both directions. - int oldWavelength = waveLength; - waveLength = (int)(22050/frequency); - if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2; - if (waveLength < 1) waveLength = 1; - - // Write sine wave. - for (int i = 0; i < waveLength*2; i++) - { - data[i] = (short)(sinf(((2*PI*(float)i/waveLength)))*32000); - } - - // Scale read cursor's position to minimize transition artifacts - readCursor = (int)(readCursor * ((float)waveLength / (float)oldWavelength)); - oldFrequency = frequency; - } - - // Refill audio stream if required - if (IsAudioBufferProcessed(stream)) - { - // Synthesize a buffer that is exactly the requested size - int writeCursor = 0; - - while (writeCursor < MAX_SAMPLES_PER_UPDATE) - { - // Start by trying to write the whole chunk at once - int writeLength = MAX_SAMPLES_PER_UPDATE-writeCursor; - - // Limit to the maximum readable size - int readLength = waveLength-readCursor; - - if (writeLength > readLength) writeLength = readLength; - - // Write the slice - memcpy(writeBuf + writeCursor, data + readCursor, writeLength*sizeof(short)); - - // Update cursors and loop audio - readCursor = (readCursor + writeLength) % waveLength; - - writeCursor += writeLength; - } - - // Copy finished frame to audio stream - UpdateAudioStream(stream, writeBuf, MAX_SAMPLES_PER_UPDATE); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText(FormatText("sine frequency: %i",(int)frequency), GetScreenWidth() - 220, 10, 20, RED); - DrawText("click mouse button to change frequency", 10, 10, 20, DARKGRAY); - - // Draw the current buffer state proportionate to the screen - for (int i = 0; i < screenWidth; i++) - { - position.x = i; - position.y = 250 + 50*data[i*MAX_SAMPLES/screenWidth]/32000; - - DrawPixelV(position, RED); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - free(data); // Unload sine wave data - free(writeBuf); // Unload write buffer - - CloseAudioStream(stream); // Close raw audio stream and delete buffers from RAM - CloseAudioDevice(); // Close audio device (music streaming is automatically stopped) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/audio/audio_sound_loading.c b/examples/src/audio/audio_sound_loading.c deleted file mode 100644 index d208dd9..0000000 --- a/examples/src/audio/audio_sound_loading.c +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************************* -* -* raylib [audio] example - Sound loading and playing -* -* NOTE: This example requires OpenAL Soft library installed -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing"); - - InitAudioDevice(); // Initialize audio device - - Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file - Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file - - 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 - //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_SPACE)) PlaySound(fxWav); // Play WAV sound - if (IsKeyPressed(KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY); - - DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadSound(fxWav); // Unload sound data - UnloadSound(fxOgg); // Unload sound data - - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_2d_camera.c b/examples/src/core/core_2d_camera.c deleted file mode 100644 index fe8e584..0000000 --- a/examples/src/core/core_2d_camera.c +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - 2d camera -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_BUILDINGS 100 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera"); - - Rectangle player = { 400, 280, 40, 40 }; - Rectangle buildings[MAX_BUILDINGS]; - Color buildColors[MAX_BUILDINGS]; - - int spacing = 0; - - for (int i = 0; i < MAX_BUILDINGS; i++) - { - buildings[i].width = GetRandomValue(50, 200); - buildings[i].height = GetRandomValue(100, 800); - buildings[i].y = screenHeight - 130 - buildings[i].height; - buildings[i].x = -6000 + spacing; - - spacing += buildings[i].width; - - buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 }; - } - - Camera2D camera = { 0 }; - - camera.target = (Vector2){ player.x + 20, player.y + 20 }; - camera.offset = (Vector2){ 0, 0 }; - camera.rotation = 0.0f; - camera.zoom = 1.0f; - - 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 - //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_RIGHT)) - { - player.x += 2; // Player movement - camera.offset.x -= 2; // Camera displacement with player movement - } - else if (IsKeyDown(KEY_LEFT)) - { - player.x -= 2; // Player movement - camera.offset.x += 2; // Camera displacement with player movement - } - - // Camera target follows player - camera.target = (Vector2){ player.x + 20, player.y + 20 }; - - // Camera rotation controls - if (IsKeyDown(KEY_A)) camera.rotation--; - else if (IsKeyDown(KEY_S)) camera.rotation++; - - // Limit camera rotation to 80 degrees (-40 to 40) - if (camera.rotation > 40) camera.rotation = 40; - else if (camera.rotation < -40) camera.rotation = -40; - - // Camera zoom controls - camera.zoom += ((float)GetMouseWheelMove()*0.05f); - - if (camera.zoom > 3.0f) camera.zoom = 3.0f; - else if (camera.zoom < 0.1f) camera.zoom = 0.1f; - - // Camera reset (zoom and rotation) - if (IsKeyPressed(KEY_R)) - { - camera.zoom = 1.0f; - camera.rotation = 0.0f; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode2D(camera); - - DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY); - - for (int i = 0; i < MAX_BUILDINGS; i++) DrawRectangleRec(buildings[i], buildColors[i]); - - DrawRectangleRec(player, RED); - - DrawLine(camera.target.x, -screenHeight*10, camera.target.x, screenHeight*10, GREEN); - DrawLine(-screenWidth*10, camera.target.y, screenWidth*10, camera.target.y, GREEN); - - EndMode2D(); - - DrawText("SCREEN AREA", 640, 10, 20, RED); - - DrawRectangle(0, 0, screenWidth, 5, RED); - DrawRectangle(0, 5, 5, screenHeight - 10, RED); - DrawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, RED); - DrawRectangle(0, screenHeight - 5, screenWidth, 5, RED); - - DrawRectangle( 10, 10, 250, 113, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines( 10, 10, 250, 113, BLUE); - - DrawText("Free 2d camera controls:", 20, 20, 10, BLACK); - DrawText("- Right/Left to move Offset", 40, 40, 10, DARKGRAY); - DrawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, DARKGRAY); - DrawText("- A / S to Rotate", 40, 80, 10, DARKGRAY); - DrawText("- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_3d_camera_first_person.c b/examples/src/core/core_3d_camera_first_person.c deleted file mode 100644 index 825a9ca..0000000 --- a/examples/src/core/core_3d_camera_first_person.c +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - 3d camera first person -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_COLUMNS 20 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); - - // Define the camera to look into our 3d world (position, target, up vector) - Camera camera = { 0 }; - camera.position = (Vector3){ 4.0f, 2.0f, 4.0f }; - camera.target = (Vector3){ 0.0f, 1.8f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 60.0f; - camera.type = CAMERA_PERSPECTIVE; - - // Generates some random columns - float heights[MAX_COLUMNS]; - Vector3 positions[MAX_COLUMNS]; - Color colors[MAX_COLUMNS]; - - for (int i = 0; i < MAX_COLUMNS; i++) - { - heights[i] = (float)GetRandomValue(1, 12); - positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) }; - colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; - } - - SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person 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(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground - DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall - DrawCube((Vector3){ 16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, LIME); // Draw a green wall - DrawCube((Vector3){ 0.0f, 2.5f, 16.0f }, 32.0f, 5.0f, 1.0f, GOLD); // Draw a yellow wall - - // Draw some cubes around - for (int i = 0; i < MAX_COLUMNS; i++) - { - DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]); - DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON); - } - - EndMode3D(); - - DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines( 10, 10, 220, 70, BLUE); - - DrawText("First person camera default controls:", 20, 20, 10, BLACK); - DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY); - DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_3d_camera_free.c b/examples/src/core/core_3d_camera_free.c deleted file mode 100644 index c1445f6..0000000 --- a/examples/src/core/core_3d_camera_free.c +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Initialize 3d camera free -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); - - // Define the camera to look into our 3d world - Camera3D camera; - camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - - SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - - if (IsKeyDown('Z')) camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines( 10, 10, 320, 133, BLUE); - - DrawText("Free camera default controls:", 20, 20, 10, BLACK); - DrawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, DARKGRAY); - DrawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, DARKGRAY); - DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 80, 10, DARKGRAY); - DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 100, 10, DARKGRAY); - DrawText("- Z to zoom to (0, 0, 0)", 40, 120, 10, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_3d_camera_mode.c b/examples/src/core/core_3d_camera_mode.c deleted file mode 100644 index eae6c88..0000000 --- a/examples/src/core/core_3d_camera_mode.c +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Initialize 3d camera mode -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera mode"); - - // Define the camera to look into our 3d world - Camera3D camera = { 0 }; - camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_3d_picking.c b/examples/src/core/core_3d_picking.c deleted file mode 100644 index 1e60c03..0000000 --- a/examples/src/core/core_3d_picking.c +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Picking in 3d mode -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking"); - - // Define the camera to look into our 3d world - Camera camera; - camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; - Vector3 cubeSize = { 2.0f, 2.0f, 2.0f }; - - Ray ray = {0.0f, 0.0f, 0.0f}; // Picking line ray - - bool collision = false; - - SetCameraMode(camera, CAMERA_FREE); // Set a free 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(&camera); // Update camera - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - ray = GetMouseRay(GetMousePosition(), camera); - - // Check collision between ray and box - collision = CheckCollisionRayBox(ray, - (BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 }, - (Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }}); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - if (collision) - { - DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED); - DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON); - - DrawCubeWires(cubePosition, cubeSize.x + 0.2f, cubeSize.y + 0.2f, cubeSize.z + 0.2f, GREEN); - } - else - { - DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY); - DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY); - } - - DrawRay(ray, MAROON); - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY); - - if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/core/core_basic_window.c b/examples/src/core/core_basic_window.c deleted file mode 100644 index 3c103a5..0000000 --- a/examples/src/core/core_basic_window.c +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Basic window -* -* Welcome to raylib! -* -* To test examples, just press F6 and execute raylib_compile_execute script -* Note that compiled executable is placed in the same folder as .c file -* -* You can find all basic examples on C:\raylib\raylib\examples folder or -* raylib official webpage: www.raylib.com -* -* Enjoy using raylib. :) -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_custom_logging.c b/examples/src/core/core_custom_logging.c deleted file mode 100644 index 0ab3fa4..0000000 --- a/examples/src/core/core_custom_logging.c +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Custom logging -* -* This example has been created using raylib 2.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Pablo Marcos Oltra (@pamarcos) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Pablo Marcos Oltra (@pamarcos) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen() -#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime() - -// Custom logging funtion -void LogCustom(int msgType, const char *text, va_list args) -{ - char timeStr[64]; - time_t now = time(NULL); - struct tm *tm_info = localtime(&now); - - strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", tm_info); - printf("[%s] ", timeStr); - - switch (msgType) - { - case LOG_INFO: printf("[INFO] : "); break; - case LOG_ERROR: printf("[ERROR]: "); break; - case LOG_WARNING: printf("[WARN] : "); break; - case LOG_DEBUG: printf("[DEBUG]: "); break; - default: break; - } - - vprintf(text, args); - printf("\n"); -} - -int main(int argc, char* argv[]) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - // First thing we do is setting our custom logger to ensure everything raylib logs - // will use our own logger instead of its internal one - SetTraceLogCallback(LogCustom); - - InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging"); - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/core/core_drop_files.c b/examples/src/core/core_drop_files.c deleted file mode 100644 index 5c3af6a..0000000 --- a/examples/src/core/core_drop_files.c +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Windows drop files -* -* This example only works on platforms that support drag & drop (Windows, Linux, OSX, Html5?) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files"); - - int count = 0; - char **droppedFiles = { 0 }; - - 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 - //---------------------------------------------------------------------------------- - if (IsFileDropped()) - { - droppedFiles = GetDroppedFiles(&count); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (count == 0) DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY); - else - { - DrawText("Dropped files:", 100, 40, 20, DARKGRAY); - - for (int i = 0; i < count; i++) - { - if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f)); - else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f)); - - DrawText(droppedFiles[i], 120, 100 + 40*i, 10, GRAY); - } - - DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClearDroppedFiles(); // Clear internal buffers - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_gamepad.c b/examples/src/core/core_input_gamepad.c deleted file mode 100644 index 51646aa..0000000 --- a/examples/src/core/core_input_gamepad.c +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Gamepad input -* -* NOTE: This example requires a Gamepad connected to the system -* raylib is configured to work with the following gamepads: -* - Xbox 360 Controller (Xbox 360, Xbox One) -* - PLAYSTATION(R)3 Controller -* Check raylib.h for buttons configuration -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -// NOTE: Gamepad name ID depends on drivers and OS -#if defined(PLATFORM_RPI) - #define XBOX360_NAME_ID "Microsoft X-Box 360 pad" - #define PS3_NAME_ID "PLAYSTATION(R)3 Controller" -#else - #define XBOX360_NAME_ID "Xbox 360 Controller" - #define PS3_NAME_ID "PLAYSTATION(R)3 Controller" -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation - - InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input"); - - Texture2D texPs3Pad = LoadTexture("resources/ps3.png"); - Texture2D texXboxPad = LoadTexture("resources/xbox.png"); - - 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 - //---------------------------------------------------------------------------------- - // ... - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (IsGamepadAvailable(GAMEPAD_PLAYER1)) - { - DrawText(FormatText("GP1: %s", GetGamepadName(GAMEPAD_PLAYER1)), 10, 10, 10, BLACK); - - if (IsGamepadName(GAMEPAD_PLAYER1, XBOX360_NAME_ID)) - { - DrawTexture(texXboxPad, 0, 0, DARKGRAY); - - // Draw buttons: xbox home - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(394, 89, 19, RED); - - // Draw buttons: basic - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawCircle(436, 150, 9, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawCircle(352, 150, 9, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) DrawCircle(501, 151, 15, BLUE); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(536, 187, 15, LIME); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(572, 151, 15, MAROON); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_UP)) 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_BUTTON_LEFT_FACE_UP)) DrawRectangle(317, 202, 19, 26, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(292, 228, 25, 19, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED); - - // Draw buttons: left-right back - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(259, 61, 20, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(536, 61, 20, RED); - - // Draw axis: left joystick - DrawCircle(259, 152, 39, BLACK); - DrawCircle(259, 152, 34, LIGHTGRAY); - DrawCircle(259 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_X)*20), - 152 - (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK); - - // Draw axis: right joystick - DrawCircle(461, 237, 38, BLACK); - DrawCircle(461, 237, 33, LIGHTGRAY); - DrawCircle(461 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_X)*20), - 237 - (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_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, (((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_TRIGGER))/2.0f)*70), RED); - DrawRectangle(604, 30, 15, (((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_TRIGGER))/2.0f)*70), RED); - - //DrawText(FormatText("Xbox axis LT: %02.02f", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK); - //DrawText(FormatText("Xbox axis RT: %02.02f", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK); - } - else if (IsGamepadName(GAMEPAD_PLAYER1, PS3_NAME_ID)) - { - DrawTexture(texPs3Pad, 0, 0, DARKGRAY); - - // Draw buttons: ps - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE)) DrawCircle(396, 222, 13, RED); - - // Draw buttons: basic - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE_LEFT)) DrawRectangle(328, 170, 32, 13, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_MIDDLE_RIGHT)) DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_UP)) DrawCircle(557, 144, 13, LIME); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) DrawCircle(586, 173, 13, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) DrawCircle(557, 203, 13, VIOLET); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)) 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_BUTTON_LEFT_FACE_UP)) DrawRectangle(225, 132, 24, 29, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) DrawRectangle(195, 161, 30, 25, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED); - - // Draw buttons: left-right back buttons - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_LEFT_TRIGGER_1)) DrawCircle(239, 82, 20, RED); - if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)) DrawCircle(557, 82, 20, RED); - - // Draw axis: left joystick - DrawCircle(319, 255, 35, BLACK); - DrawCircle(319, 255, 31, LIGHTGRAY); - DrawCircle(319 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_X)*20), - 255 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK); - - // Draw axis: right joystick - DrawCircle(475, 255, 35, BLACK); - DrawCircle(475, 255, 31, LIGHTGRAY); - DrawCircle(475 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_X)*20), - 255 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_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, (((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_LEFT_TRIGGER))/2.0f)*70), RED); - DrawRectangle(611, 48, 15, (((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_AXIS_RIGHT_TRIGGER))/2.0f)*70), RED); - } - else - { - DrawText("- GENERIC GAMEPAD -", 280, 180, 20, GRAY); - - // TODO: Draw generic gamepad - } - - DrawText(FormatText("DETECTED AXIS [%i]:", GetGamepadAxisCount(GAMEPAD_PLAYER1)), 10, 50, 10, MAROON); - - for (int i = 0; i < GetGamepadAxisCount(GAMEPAD_PLAYER1); i++) - { - DrawText(FormatText("AXIS %i: %.02f", i, GetGamepadAxisMovement(GAMEPAD_PLAYER1, i)), 20, 70 + 20*i, 10, DARKGRAY); - } - - if (GetGamepadButtonPressed() != -1) DrawText(FormatText("DETECTED BUTTON: %i", GetGamepadButtonPressed()), 10, 430, 10, RED); - else DrawText("DETECTED BUTTON: NONE", 10, 430, 10, GRAY); - } - else - { - DrawText("GP1: NOT DETECTED", 10, 10, 10, GRAY); - - DrawTexture(texXboxPad, 0, 0, LIGHTGRAY); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texPs3Pad); - UnloadTexture(texXboxPad); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_gestures.c b/examples/src/core/core_input_gestures.c deleted file mode 100644 index affab3e..0000000 --- a/examples/src/core/core_input_gestures.c +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Input Gestures Detection -* -* This example has been created using raylib 1.4 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include <string.h> - -#define MAX_GESTURE_STRINGS 20 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures"); - - Vector2 touchPosition = { 0, 0 }; - Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 }; - - int gesturesCount = 0; - char gestureStrings[MAX_GESTURE_STRINGS][32]; - - int currentGesture = GESTURE_NONE; - int lastGesture = GESTURE_NONE; - - //SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected - - 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 - //---------------------------------------------------------------------------------- - lastGesture = currentGesture; - currentGesture = GetGestureDetected(); - touchPosition = GetTouchPosition(0); - - if (CheckCollisionPointRec(touchPosition, touchArea) && (currentGesture != GESTURE_NONE)) - { - if (currentGesture != lastGesture) - { - // Store gesture string - switch (currentGesture) - { - case GESTURE_TAP: strcpy(gestureStrings[gesturesCount], "GESTURE TAP"); break; - case GESTURE_DOUBLETAP: strcpy(gestureStrings[gesturesCount], "GESTURE DOUBLETAP"); break; - case GESTURE_HOLD: strcpy(gestureStrings[gesturesCount], "GESTURE HOLD"); break; - case GESTURE_DRAG: strcpy(gestureStrings[gesturesCount], "GESTURE DRAG"); break; - case GESTURE_SWIPE_RIGHT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE RIGHT"); break; - case GESTURE_SWIPE_LEFT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE LEFT"); break; - case GESTURE_SWIPE_UP: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE UP"); break; - case GESTURE_SWIPE_DOWN: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE DOWN"); break; - case GESTURE_PINCH_IN: strcpy(gestureStrings[gesturesCount], "GESTURE PINCH IN"); break; - case GESTURE_PINCH_OUT: strcpy(gestureStrings[gesturesCount], "GESTURE PINCH OUT"); break; - default: break; - } - - gesturesCount++; - - // Reset gestures strings - if (gesturesCount >= MAX_GESTURE_STRINGS) - { - for (int i = 0; i < MAX_GESTURE_STRINGS; i++) strcpy(gestureStrings[i], "\0"); - - gesturesCount = 0; - } - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangleRec(touchArea, GRAY); - DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE); - - DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5f)); - - for (int i = 0; i < gesturesCount; i++) - { - if (i%2 == 0) DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.5f)); - else DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.3f)); - - if (i < gesturesCount - 1) DrawText(gestureStrings[i], 35, 36 + 20*i, 10, DARKGRAY); - else DrawText(gestureStrings[i], 35, 36 + 20*i, 10, MAROON); - } - - DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY); - DrawText("DETECTED GESTURES", 50, 15, 10, GRAY); - - if (currentGesture != GESTURE_NONE) DrawCircleV(touchPosition, 30, MAROON); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- -}
\ No newline at end of file diff --git a/examples/src/core/core_input_keys.c b/examples/src/core/core_input_keys.c deleted file mode 100644 index bbb71ee..0000000 --- a/examples/src/core/core_input_keys.c +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Keyboard input -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input"); - - Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 }; - - 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 - //---------------------------------------------------------------------------------- - 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; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY); - - DrawCircleV(ballPosition, 50, MAROON); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_mouse.c b/examples/src/core/core_input_mouse.c deleted file mode 100644 index ad205ae..0000000 --- a/examples/src/core/core_input_mouse.c +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Mouse input -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input"); - - Vector2 ballPosition = { -100.0f, -100.0f }; - Color ballColor = DARKBLUE; - - 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 - //---------------------------------------------------------------------------------- - 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; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawCircleV(ballPosition, 40, ballColor); - - DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_mouse_wheel.c b/examples/src/core/core_input_mouse_wheel.c deleted file mode 100644 index 7c3e2a1..0000000 --- a/examples/src/core/core_input_mouse_wheel.c +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] examples - Mouse wheel input -* -* This test has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel"); - - int boxPositionY = screenHeight/2 - 40; - int scrollSpeed = 4; // Scrolling speed in pixels - - 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 - //---------------------------------------------------------------------------------- - boxPositionY -= (GetMouseWheelMove()*scrollSpeed); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangle(screenWidth/2 - 40, boxPositionY, 80, 80, MAROON); - - DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, GRAY); - DrawText(FormatText("Box position Y: %03i", boxPositionY), 10, 40, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_input_multitouch.c b/examples/src/core/core_input_multitouch.c deleted file mode 100644 index 5fbb086..0000000 --- a/examples/src/core/core_input_multitouch.c +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Input multitouch -* -* This example has been created using raylib 2.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Berni (@Berni8k) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch"); - - Vector2 ballPosition = { -100.0f, -100.0f }; - Color ballColor = BEIGE; - - int touchCounter = 0; - Vector2 touchPosition = { 0.0f }; - - 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 - //---------------------------------------------------------------------------------- - ballPosition = GetMousePosition(); - - ballColor = BEIGE; - - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) ballColor = MAROON; - if (IsMouseButtonDown(MOUSE_MIDDLE_BUTTON)) ballColor = LIME; - if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE; - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) touchCounter = 10; - if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) touchCounter = 10; - if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) touchCounter = 10; - - if (touchCounter > 0) touchCounter--; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Multitouch - for (int i = 0; i < MAX_TOUCH_POINTS; ++i) - { - touchPosition = GetTouchPosition(i); // Get the touch point - - if ((touchPosition.x >= 0) && (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it - { - // Draw circle and touch index number - DrawCircleV(touchPosition, 34, ORANGE); - DrawText(FormatText("%d", i), touchPosition.x - 10, touchPosition.y - 70, 40, BLACK); - } - } - - // Draw the normal mouse location - DrawCircleV(ballPosition, 30 + (touchCounter*3), ballColor); - - DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY); - DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_loading_thread.c b/examples/src/core/core_loading_thread.c deleted file mode 100644 index 773ad2e..0000000 --- a/examples/src/core/core_loading_thread.c +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************************* -* -* raylib example - loading thread -* -* NOTE: This example requires linking with pthreads library, -* on MinGW, it can be accomplished passing -static parameter to compiler -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include "pthread.h" // POSIX style threads management - -#include <stdatomic.h> // C11 atomic data types - -#include <time.h> // Required for: clock() - -// Using C11 atomics for synchronization -// NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization -static atomic_bool dataLoaded = ATOMIC_VAR_INIT(false); // Data Loaded completion indicator -static void *LoadDataThread(void *arg); // Loading data thread function declaration - -static int dataProgress = 0; // Data progress accumulator - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread"); - - pthread_t threadId; // Loading data thread id - - enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING; - int framesCounter = 0; - - 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 - //---------------------------------------------------------------------------------- - switch (state) - { - case STATE_WAITING: - { - if (IsKeyPressed(KEY_ENTER)) - { - int error = pthread_create(&threadId, NULL, &LoadDataThread, NULL); - if (error != 0) TraceLog(LOG_ERROR, "Error creating loading thread"); - else TraceLog(LOG_INFO, "Loading thread initialized successfully"); - - state = STATE_LOADING; - } - } break; - case STATE_LOADING: - { - framesCounter++; - if (atomic_load(&dataLoaded)) - { - framesCounter = 0; - state = STATE_FINISHED; - } - } break; - case STATE_FINISHED: - { - if (IsKeyPressed(KEY_ENTER)) - { - // Reset everything to launch again - atomic_store(&dataLoaded, false); - dataProgress = 0; - state = STATE_WAITING; - } - } break; - default: break; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - switch (state) - { - case STATE_WAITING: DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break; - case STATE_LOADING: - { - DrawRectangle(150, 200, dataProgress, 60, SKYBLUE); - if ((framesCounter/15)%2) DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE); - - } break; - case STATE_FINISHED: - { - DrawRectangle(150, 200, 500, 60, LIME); - DrawText("DATA LOADED!", 250, 210, 40, GREEN); - - } break; - default: break; - } - - DrawRectangleLines(150, 200, 500, 60, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -// Loading data thread function definition -static void *LoadDataThread(void *arg) -{ - int timeCounter = 0; // Time counted in ms - clock_t prevTime = clock(); // Previous time - - // We simulate data loading with a time counter for 5 seconds - while (timeCounter < 5000) - { - clock_t currentTime = clock() - prevTime; - timeCounter = currentTime*1000/CLOCKS_PER_SEC; - - // We accumulate time over a global variable to be used in - // main thread as a progress bar - dataProgress = timeCounter/10; - } - - // When data has finished loading, we set global variable - atomic_store(&dataLoaded, true); - - return NULL; -} diff --git a/examples/src/core/core_random_values.c b/examples/src/core/core_random_values.c deleted file mode 100644 index 52dabe0..0000000 --- a/examples/src/core/core_random_values.c +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Generate random values -* -* This example has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values"); - - int framesCounter = 0; // Variable used to count frames - - int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included) - - 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 - //---------------------------------------------------------------------------------- - framesCounter++; - - // Every two seconds (120 frames) a new random value is generated - if (((framesCounter/120)%2) == 1) - { - randValue = GetRandomValue(-8, 5); - framesCounter = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON); - - DrawText(FormatText("%i", randValue), 360, 180, 80, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_storage_values.c b/examples/src/core/core_storage_values.c deleted file mode 100644 index fbbbc52..0000000 --- a/examples/src/core/core_storage_values.c +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - Storage save/load values -* -* This example has been created using raylib 1.4 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -// NOTE: Storage positions must start with 0, directly related to file memory layout -typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values"); - - int score = 0; - int hiscore = 0; - int framesCounter = 0; - - 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 - //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_R)) - { - score = GetRandomValue(1000, 2000); - hiscore = GetRandomValue(2000, 4000); - } - - if (IsKeyPressed(KEY_ENTER)) - { - StorageSaveValue(STORAGE_SCORE, score); - StorageSaveValue(STORAGE_HISCORE, hiscore); - } - else if (IsKeyPressed(KEY_SPACE)) - { - // NOTE: If requested position could not be found, value 0 is returned - score = StorageLoadValue(STORAGE_SCORE); - hiscore = StorageLoadValue(STORAGE_HISCORE); - } - - framesCounter++; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText(FormatText("SCORE: %i", score), 280, 130, 40, MAROON); - DrawText(FormatText("HI-SCORE: %i", hiscore), 210, 200, 50, BLACK); - - DrawText(FormatText("frames: %i", framesCounter), 10, 10, 20, LIME); - - DrawText("Press R to generate random numbers", 220, 40, 20, LIGHTGRAY); - DrawText("Press ENTER to SAVE values", 250, 310, 20, LIGHTGRAY); - DrawText("Press SPACE to LOAD values", 252, 350, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_vr_simulator.c b/examples/src/core/core_vr_simulator.c deleted file mode 100644 index 134a36f..0000000 --- a/examples/src/core/core_vr_simulator.c +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - VR Simulator (Oculus Rift CV1 parameters) -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 1080; - const int screenHeight = 600; - - // NOTE: screenWidth/screenHeight should match VR device aspect ratio - - InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator"); - - // Init VR simulator (Oculus Rift CV1 parameters) - InitVrSimulator(); - - VrDeviceInfo hmd = { 0 }; // VR device parameters (head-mounted-device) - - // Oculus Rift CV1 parameters for simulator - hmd.hResolution = 2160; // HMD horizontal resolution in pixels - hmd.vResolution = 1200; // HMD vertical resolution in pixels - hmd.hScreenSize = 0.133793f; // HMD horizontal size in meters - hmd.vScreenSize = 0.0669f; // HMD vertical size in meters - hmd.vScreenCenter = 0.04678f; // HMD screen center in meters - hmd.eyeToScreenDistance = 0.041f; // HMD distance between eye and display in meters - hmd.lensSeparationDistance = 0.07f; // HMD lens separation distance in meters - hmd.interpupillaryDistance = 0.07f; // HMD IPD (distance between pupils) in meters - - // NOTE: CV1 uses a Fresnel-hybrid-asymmetric lenses with specific distortion compute shaders. - // Following parameters are an approximation to distortion stereo rendering but results differ from actual device. - hmd.lensDistortionValues[0] = 1.0f; // HMD lens distortion constant parameter 0 - hmd.lensDistortionValues[1] = 0.22f; // HMD lens distortion constant parameter 1 - hmd.lensDistortionValues[2] = 0.24f; // HMD lens distortion constant parameter 2 - hmd.lensDistortionValues[3] = 0.0f; // HMD lens distortion constant parameter 3 - hmd.chromaAbCorrection[0] = 0.996f; // HMD chromatic aberration correction parameter 0 - hmd.chromaAbCorrection[1] = -0.004f; // HMD chromatic aberration correction parameter 1 - hmd.chromaAbCorrection[2] = 1.014f; // HMD chromatic aberration correction parameter 2 - hmd.chromaAbCorrection[3] = 0.0f; // HMD chromatic aberration correction parameter 3 - - // Distortion shader (uses device lens distortion and chroma) - Shader distortion = LoadShader(0, FormatText("resources/distortion%i.fs", GLSL_VERSION)); - - SetVrConfiguration(hmd, distortion); // Set Vr device parameters for stereo rendering - - // Define the camera to look into our 3d world - Camera camera; - camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 60.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera type - - Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - - SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set first person camera mode - - SetTargetFPS(90); // Set our game to run at 90 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera (simulator mode) - - if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginVrDrawing(); - - BeginMode3D(camera); - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - - DrawGrid(40, 1.0f); - - EndMode3D(); - - EndVrDrawing(); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(distortion); // Unload distortion shader - - CloseVrSimulator(); // Close VR simulator - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/core/core_window_letterbox.c b/examples/src/core/core_window_letterbox.c deleted file mode 100644 index f90214c..0000000 --- a/examples/src/core/core_window_letterbox.c +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - window scale letterbox -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define max(a, b) ((a)>(b)? (a) : (b)) -#define min(a, b) ((a)<(b)? (a) : (b)) - -int main(void) -{ - const int windowWidth = 800; - const int windowHeight = 450; - - // Enable config flags for resizable window and vertical synchro - SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT); - InitWindow(windowWidth, windowHeight, "raylib [core] example - window scale letterbox"); - SetWindowMinSize(320, 240); - - int gameScreenWidth = 640; - int gameScreenHeight = 480; - - // Render texture initialization - RenderTexture2D target = LoadRenderTexture(gameScreenWidth, gameScreenHeight); - SetTextureFilter(target.texture, FILTER_BILINEAR); // Texture scale filter to use - - Color colors[10] = { 0 }; - for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 }; - - 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 - //---------------------------------------------------------------------------------- - // Compute required framebuffer scaling - float scale = min((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight); - - if (IsKeyPressed(KEY_SPACE)) - { - // Recalculate random colors for the bars - for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 }; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - ClearBackground(BLACK); - - // Draw everything in the render texture - BeginTextureMode(target); - - ClearBackground(RAYWHITE); // Clear render texture background color - - for (int i = 0; i < 10; i++) DrawRectangle(0, (gameScreenHeight/10)*i, gameScreenWidth, gameScreenHeight/10, colors[i]); - - DrawText("You can resize the window,\nand see the screen scaling!", 10, 25, 20, WHITE); - - EndTextureMode(); - - // Draw RenderTexture2D to window, properly scaled - DrawTexturePro(target.texture, (Rectangle){ 0.0f, 0.0f, (float)target.texture.width, (float)-target.texture.height }, - (Rectangle){ (GetScreenWidth() - ((float)gameScreenWidth*scale))*0.5, (GetScreenHeight() - ((float)gameScreenHeight*scale))*0.5, - (float)gameScreenWidth*scale, (float)gameScreenHeight*scale }, (Vector2){ 0, 0 }, 0.0f, WHITE); - - EndDrawing(); - //-------------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadRenderTexture(target); // Unload render texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/core/core_world_screen.c b/examples/src/core/core_world_screen.c deleted file mode 100644 index 434952b..0000000 --- a/examples/src/core/core_world_screen.c +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************************* -* -* raylib [core] example - World to screen -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; - - Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - - Vector2 cubeScreenPosition; - - SetCameraMode(camera, CAMERA_FREE); // Set a free 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(&camera); // Update camera - - // Calculate cube screen space position (with a little offset to be in top) - cubeScreenPosition = GetWorldToScreen((Vector3){cubePosition.x, cubePosition.y + 2.5f, cubePosition.z}, camera); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); - - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawText("Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100 / 100", 20) / 2, cubeScreenPosition.y, 20, BLACK); - DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2, 25, 20, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_animation.c b/examples/src/models/models_animation.c deleted file mode 100644 index 294b07a..0000000 --- a/examples/src/models/models_animation.c +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Load 3d model with animations and play them -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2019 Ramon Santamaria (@raysan5) and @culacant -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - - Model model = LoadModel("resources/guy/guy.iqm"); // Load the animated model mesh and basic data - Texture2D texture = LoadTexture("resources/guy/guytex.png"); // Load model texture and set material - SetMaterialTexture(&model.materials[0], MAP_DIFFUSE, texture); // Set model material map texture - - Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - - // Load animation data - int animsCount = 0; - ModelAnimation *anims = LoadModelAnimations("resources/guy/guyanim.iqm", &animsCount); - int animFrameCounter = 0; - - SetCameraMode(camera, CAMERA_FREE); // Set free 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(&camera); - - // Play animation when spacebar is held down - if (IsKeyDown(KEY_SPACE)) - { - animFrameCounter++; - UpdateModelAnimation(model, anims[0], animFrameCounter); - if (animFrameCounter >= anims[0].frameCount) animFrameCounter = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModelEx(model, position, (Vector3){ 1.0f, 0.0f, 0.0f }, -90.0f, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE); - - for (int i = 0; i < model.boneCount; i++) - { - DrawCube(anims[0].framePoses[animFrameCounter][i].translation, 0.2f, 0.2f, 0.2f, RED); - } - - DrawGrid(10, 1.0f); // Draw a grid - - EndMode3D(); - - DrawText("PRESS SPACE to PLAY MODEL ANIMATION", 10, 10, 20, MAROON); - DrawText("(c) Guy IQM 3D model by @culacant", screenWidth - 200, screenHeight - 20, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - // Unload model animations data - for (int i = 0; i < animsCount; i++) UnloadModelAnimation(anims[i]); - - UnloadModel(model); // Unload model - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/models/models_billboard.c b/examples/src/models/models_billboard.c deleted file mode 100644 index 597e9a6..0000000 --- a/examples/src/models/models_billboard.c +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Drawing billboards -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 5.0f, 4.0f, 5.0f }; - camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; - - Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard - Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard - - SetCameraMode(camera, 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(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawGrid(10, 1.0f); // Draw a grid - - DrawBillboard(camera, bill, billPosition, 2.0f, WHITE); - - EndMode3D(); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(bill); // Unload texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_box_collisions.c b/examples/src/models/models_box_collisions.c deleted file mode 100644 index 0dd0710..0000000 --- a/examples/src/models/models_box_collisions.c +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Detect basic 3d collisions (box vs sphere vs box) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions"); - - // Define the camera to look into our 3d world - Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; - - Vector3 playerPosition = { 0.0f, 1.0f, 2.0f }; - Vector3 playerSize = { 1.0f, 2.0f, 1.0f }; - Color playerColor = GREEN; - - Vector3 enemyBoxPos = { -4.0f, 1.0f, 0.0f }; - Vector3 enemyBoxSize = { 2.0f, 2.0f, 2.0f }; - - Vector3 enemySpherePos = { 4.0f, 0.0f, 0.0f }; - float enemySphereSize = 1.5f; - - bool collision = false; - - 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 - //---------------------------------------------------------------------------------- - - // 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; - - collision = false; - - // Check collisions player vs enemy-box - if (CheckCollisionBoxes( - (BoundingBox){(Vector3){ playerPosition.x - playerSize.x/2, - playerPosition.y - playerSize.y/2, - playerPosition.z - playerSize.z/2 }, - (Vector3){ playerPosition.x + playerSize.x/2, - playerPosition.y + playerSize.y/2, - playerPosition.z + playerSize.z/2 }}, - (BoundingBox){(Vector3){ enemyBoxPos.x - enemyBoxSize.x/2, - enemyBoxPos.y - enemyBoxSize.y/2, - enemyBoxPos.z - enemyBoxSize.z/2 }, - (Vector3){ enemyBoxPos.x + enemyBoxSize.x/2, - enemyBoxPos.y + enemyBoxSize.y/2, - enemyBoxPos.z + enemyBoxSize.z/2 }})) collision = true; - - // Check collisions player vs enemy-sphere - if (CheckCollisionBoxSphere( - (BoundingBox){(Vector3){ playerPosition.x - playerSize.x/2, - playerPosition.y - playerSize.y/2, - playerPosition.z - playerSize.z/2 }, - (Vector3){ playerPosition.x + playerSize.x/2, - playerPosition.y + playerSize.y/2, - playerPosition.z + playerSize.z/2 }}, - enemySpherePos, enemySphereSize)) collision = true; - - if (collision) playerColor = RED; - else playerColor = GREEN; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - // Draw enemy-box - DrawCube(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, GRAY); - DrawCubeWires(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, DARKGRAY); - - // Draw enemy-sphere - DrawSphere(enemySpherePos, enemySphereSize, GRAY); - DrawSphereWires(enemySpherePos, enemySphereSize, 16, 16, DARKGRAY); - - // Draw player - DrawCubeV(playerPosition, playerSize, playerColor); - - DrawGrid(10, 1.0f); // Draw a grid - - EndMode3D(); - - DrawText("Move player with cursors to collide", 220, 40, 20, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_cubicmap.c b/examples/src/models/models_cubicmap.c deleted file mode 100644 index f399a56..0000000 --- a/examples/src/models/models_cubicmap.c +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Cubicmap loading and drawing -* -* 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) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing"); - - // Define the camera to look into our 3d world - Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; - - Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) - Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM) - - Mesh mesh = GenMeshCubicmap(image, (Vector3){ 1.0f, 1.0f, 1.0f }); - Model model = LoadModelFromMesh(mesh); - - // NOTE: By default each cube is mapped to one part of texture atlas - Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture - model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture - - Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position - - UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM - - SetCameraMode(camera, 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(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModel(model, mapPosition, 1.0f, WHITE); - - EndMode3D(); - - DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE); - DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); - - DrawText("cubicmap image used to", 658, 90, 10, GRAY); - DrawText("generate map 3d model", 658, 104, 10, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(cubicmap); // Unload cubicmap texture - UnloadTexture(texture); // Unload map texture - UnloadModel(model); // Unload map model - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/models/models_first_person_maze.c b/examples/src/models/models_first_person_maze.c deleted file mode 100644 index 4236374..0000000 --- a/examples/src/models/models_first_person_maze.c +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - first person maze -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <stdlib.h> // Required for: free() - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze"); - - // Define the camera to look into our 3d world - Camera camera = {{ 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; - - Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) - Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM) - Mesh mesh = GenMeshCubicmap(imMap, (Vector3){ 1.0f, 1.0f, 1.0f }); - Model model = LoadModelFromMesh(mesh); - - // NOTE: By default each cube is mapped to one part of texture atlas - Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture - model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture - - // Get map image data to be used for collision detection - Color *mapPixels = GetImageData(imMap); - UnloadImage(imMap); // Unload image from RAM - - Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position - Vector3 playerPosition = camera.position; // Set player position - - SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set 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 - //---------------------------------------------------------------------------------- - Vector3 oldCamPos = camera.position; // Store old camera position - - UpdateCamera(&camera); // Update camera - - // Check player collision (we simplify to 2D collision detection) - Vector2 playerPos = { camera.position.x, camera.position.z }; - float playerRadius = 0.1f; // Collision radius (player is modelled as a cilinder for collision) - - int playerCellX = (int)(playerPos.x - mapPosition.x + 0.5f); - int playerCellY = (int)(playerPos.y - mapPosition.z + 0.5f); - - // Out-of-limits security check - if (playerCellX < 0) playerCellX = 0; - else if (playerCellX >= cubicmap.width) playerCellX = cubicmap.width - 1; - - if (playerCellY < 0) playerCellY = 0; - else if (playerCellY >= cubicmap.height) playerCellY = cubicmap.height - 1; - - // Check map collisions using image data and player position - // TODO: Improvement: Just check player surrounding cells for collision - for (int y = 0; y < cubicmap.height; y++) - { - for (int x = 0; x < cubicmap.width; x++) - { - if ((mapPixels[y*cubicmap.width + x].r == 255) && // Collision: white pixel, only check R channel - (CheckCollisionCircleRec(playerPos, playerRadius, - (Rectangle){ mapPosition.x - 0.5f + x*1.0f, mapPosition.z - 0.5f + y*1.0f, 1.0f, 1.0f }))) - { - // Collision detected, reset camera position - camera.position = oldCamPos; - } - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModel(model, mapPosition, 1.0f, WHITE); // Draw maze map - //DrawCubeV(playerPosition, (Vector3){ 0.2f, 0.4f, 0.2f }, RED); // Draw player - - EndMode3D(); - - DrawTextureEx(cubicmap, (Vector2){ GetScreenWidth() - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE); - DrawRectangleLines(GetScreenWidth() - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); - - // Draw player position radar - DrawRectangle(GetScreenWidth() - cubicmap.width*4 - 20 + playerCellX*4, 20 + playerCellY*4, 4, 4, RED); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - free(mapPixels); // Unload color array - - UnloadTexture(cubicmap); // Unload cubicmap texture - UnloadTexture(texture); // Unload map texture - UnloadModel(model); // Unload map model - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/models/models_geometric_shapes.c b/examples/src/models/models_geometric_shapes.c deleted file mode 100644 index 3947792..0000000 --- a/examples/src/models/models_geometric_shapes.c +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...) -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); - DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); - DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON); - - DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN); - DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME); - - DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE); - DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE); - DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN); - - DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD); - DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK); - - DrawGrid(10, 1.0f); // Draw a grid - - EndMode3D(); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_heightmap.c b/examples/src/models/models_heightmap.c deleted file mode 100644 index e242db1..0000000 --- a/examples/src/models/models_heightmap.c +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Heightmap loading and drawing -* -* 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) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing"); - - // Define our custom camera to look into our 3d world - Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; - - Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) - Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) - - Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM) - Model model = LoadModelFromMesh(mesh); // Load model from generated mesh - - model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture - Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position - - UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM - - SetCameraMode(camera, 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(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModel(model, mapPosition, 1.0f, RED); - - DrawGrid(20, 1.0f); - - EndMode3D(); - - DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE); - DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Unload texture - UnloadModel(model); // Unload model - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_material_pbr.c b/examples/src/models/models_material_pbr.c deleted file mode 100644 index 8d51eef..0000000 --- a/examples/src/models/models_material_pbr.c +++ /dev/null @@ -1,222 +0,0 @@ -/******************************************************************************************* -* -* 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) -* -********************************************************************************************/ - -#include "raylib.h" -#include "raymath.h" - -#include <stdio.h> - -#define RLIGHTS_IMPLEMENTATION -#include "rlights.h" - -#define CUBEMAP_SIZE 512 // Cubemap texture size -#define IRRADIANCE_SIZE 32 // Irradiance texture size -#define PREFILTERED_SIZE 256 // Prefiltered HDR environment texture size -#define BRDF_SIZE 512 // BRDF LUT texture size - -// PBR material loading -static Material LoadMaterialPBR(Color albedo, float metalness, float roughness); - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const 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 - Camera camera = { 0 }; - camera.position = (Vector3){ 4.0f, 4.0f, 4.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - // Load model and PBR material - Model model = LoadModel("resources/pbr/trooper.obj"); - - // Mesh tangents are generated... and uploaded to GPU - // NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO - MeshTangents(&model.meshes[0]); - - model.materials[0] = LoadMaterialPBR((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[MAX_LIGHTS] = { - CreateLight(LIGHT_POINT, (Vector3){ LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 0, 255 }, model.materials[0].shader), - CreateLight(LIGHT_POINT, (Vector3){ 0.0f, LIGHT_HEIGHT, LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 255, 0, 255 }, model.materials[0].shader), - CreateLight(LIGHT_POINT, (Vector3){ -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0f }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 0, 0, 255, 255 }, model.materials[0].shader), - CreateLight(LIGHT_DIRECTIONAL, (Vector3){ 0.0f, LIGHT_HEIGHT*2.0f, -LIGHT_DISTANCE }, (Vector3){ 0.0f, 0.0f, 0.0f }, (Color){ 255, 0, 255, 255 }, model.materials[0].shader) - }; - - SetCameraMode(camera, 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(&camera); // Update camera - - // Send to material PBR shader camera view position - float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; - SetShaderValue(model.materials[0].shader, model.materials[0].shader.locs[LOC_VECTOR_VIEW], cameraPos, UNIFORM_VEC3); - //---------------------------------------------------------------------------------- - - // 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 -static Material LoadMaterialPBR(Color albedo, float metalness, float roughness) -{ - Material mat = { 0 }; // NOTE: All maps textures are set to { 0 } - -#if defined(PLATFORM_DESKTOP) - mat.shader = LoadShader("resources/shaders/glsl330/pbr.vs", "resources/shaders/glsl330/pbr.fs"); -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - mat.shader = LoadShader("resources/shaders/glsl100/pbr.vs", "resources/shaders/glsl100/pbr.fs"); -#endif - - // Get required locations points for PBR material - // NOTE: Those location names must be available and used in the shader code - mat.shader.locs[LOC_MAP_ALBEDO] = GetShaderLocation(mat.shader, "albedo.sampler"); - mat.shader.locs[LOC_MAP_METALNESS] = GetShaderLocation(mat.shader, "metalness.sampler"); - mat.shader.locs[LOC_MAP_NORMAL] = GetShaderLocation(mat.shader, "normals.sampler"); - mat.shader.locs[LOC_MAP_ROUGHNESS] = GetShaderLocation(mat.shader, "roughness.sampler"); - mat.shader.locs[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[LOC_MAP_IRRADIANCE] = GetShaderLocation(mat.shader, "irradianceMap"); - mat.shader.locs[LOC_MAP_PREFILTER] = GetShaderLocation(mat.shader, "prefilterMap"); - mat.shader.locs[LOC_MAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT"); - - // Set view matrix location - mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel"); - mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view"); - mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos"); - - // Set PBR standard maps - mat.maps[MAP_ALBEDO].texture = LoadTexture("resources/pbr/trooper_albedo.png"); - mat.maps[MAP_NORMAL].texture = LoadTexture("resources/pbr/trooper_normals.png"); - mat.maps[MAP_METALNESS].texture = LoadTexture("resources/pbr/trooper_metalness.png"); - mat.maps[MAP_ROUGHNESS].texture = LoadTexture("resources/pbr/trooper_roughness.png"); - mat.maps[MAP_OCCLUSION].texture = LoadTexture("resources/pbr/trooper_ao.png"); - - // Load equirectangular to cubemap shader -#if defined(PLATFORM_DESKTOP) - Shader shdrCubemap = LoadShader("resources/shaders/glsl330/cubemap.vs", "resources/shaders/glsl330/cubemap.fs"); -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - Shader shdrCubemap = LoadShader("resources/shaders/glsl100/cubemap.vs", "resources/shaders/glsl100/cubemap.fs"); -#endif - - // Load irradiance (GI) calculation shader -#if defined(PLATFORM_DESKTOP) - Shader shdrIrradiance = LoadShader("resources/shaders/glsl330/skybox.vs", "resources/shaders/glsl330/irradiance.fs"); -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - Shader shdrIrradiance = LoadShader("resources/shaders/glsl100/skybox.vs", "resources/shaders/glsl100/irradiance.fs"); -#endif - - // Load reflection prefilter calculation shader -#if defined(PLATFORM_DESKTOP) - Shader shdrPrefilter = LoadShader("resources/shaders/glsl330/skybox.vs", "resources/shaders/glsl330/prefilter.fs"); -#else - Shader shdrPrefilter = LoadShader("resources/shaders/glsl100/skybox.vs", "resources/shaders/glsl100/prefilter.fs"); -#endif - - // Load bidirectional reflectance distribution function shader -#if defined(PLATFORM_DESKTOP) - Shader shdrBRDF = LoadShader("resources/shaders/glsl330/brdf.vs", "resources/shaders/glsl330/brdf.fs"); -#else - Shader shdrBRDF = LoadShader("resources/shaders/glsl100/brdf.vs", "resources/shaders/glsl100/brdf.fs"); -#endif - - // Setup required shader locations - SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, UNIFORM_INT); - SetShaderValue(shdrIrradiance, GetShaderLocation(shdrIrradiance, "environmentMap"), (int[1]){ 0 }, UNIFORM_INT); - SetShaderValue(shdrPrefilter, GetShaderLocation(shdrPrefilter, "environmentMap"), (int[1]){ 0 }, UNIFORM_INT); - - Texture2D texHDR = LoadTexture("resources/dresden_square.hdr"); - Texture2D cubemap = GenTextureCubemap(shdrCubemap, texHDR, CUBEMAP_SIZE); - mat.maps[MAP_IRRADIANCE].texture = GenTextureIrradiance(shdrIrradiance, cubemap, IRRADIANCE_SIZE); - mat.maps[MAP_PREFILTER].texture = GenTexturePrefilter(shdrPrefilter, cubemap, PREFILTERED_SIZE); - mat.maps[MAP_BRDF].texture = GenTextureBRDF(shdrBRDF, 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[MAP_ALBEDO].texture, FILTER_BILINEAR); - SetTextureFilter(mat.maps[MAP_NORMAL].texture, FILTER_BILINEAR); - SetTextureFilter(mat.maps[MAP_METALNESS].texture, FILTER_BILINEAR); - SetTextureFilter(mat.maps[MAP_ROUGHNESS].texture, FILTER_BILINEAR); - SetTextureFilter(mat.maps[MAP_OCCLUSION].texture, FILTER_BILINEAR); - - // Enable sample usage in shader for assigned textures - SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "albedo.useSampler"), (int[1]){ 1 }, UNIFORM_INT); - SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "normals.useSampler"), (int[1]){ 1 }, UNIFORM_INT); - SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "metalness.useSampler"), (int[1]){ 1 }, UNIFORM_INT); - SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "roughness.useSampler"), (int[1]){ 1 }, UNIFORM_INT); - SetShaderValue(mat.shader, GetShaderLocation(mat.shader, "occlusion.useSampler"), (int[1]){ 1 }, UNIFORM_INT); - - int renderModeLoc = GetShaderLocation(mat.shader, "renderMode"); - SetShaderValue(mat.shader, renderModeLoc, (int[1]){ 0 }, UNIFORM_INT); - - // Set up material properties color - mat.maps[MAP_ALBEDO].color = albedo; - mat.maps[MAP_NORMAL].color = (Color){ 128, 128, 255, 255 }; - mat.maps[MAP_METALNESS].value = metalness; - mat.maps[MAP_ROUGHNESS].value = roughness; - mat.maps[MAP_OCCLUSION].value = 1.0f; - mat.maps[MAP_EMISSION].value = 0.5f; - mat.maps[MAP_HEIGHT].value = 0.5f; - - return mat; -} diff --git a/examples/src/models/models_mesh_generation.c b/examples/src/models/models_mesh_generation.c deleted file mode 100644 index cfc3bdd..0000000 --- a/examples/src/models/models_mesh_generation.c +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************************* -* -* raylib example - procedural mesh generation -* -* 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 (Ray San) -* -********************************************************************************************/ - -#include "raylib.h" - -#define NUM_MODELS 8 // Parametric 3d shapes to generate - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation"); - - // We generate a checked image for texturing - Image checked = GenImageChecked(2, 2, 1, 1, RED, GREEN); - Texture2D texture = LoadTextureFromImage(checked); - UnloadImage(checked); - - Model models[NUM_MODELS]; - - models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 5, 5)); - models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f)); - models[2] = LoadModelFromMesh(GenMeshSphere(2, 32, 32)); - models[3] = LoadModelFromMesh(GenMeshHemiSphere(2, 16, 16)); - models[4] = LoadModelFromMesh(GenMeshCylinder(1, 2, 16)); - models[5] = LoadModelFromMesh(GenMeshTorus(0.25f, 4.0f, 16, 32)); - models[6] = LoadModelFromMesh(GenMeshKnot(1.0f, 2.0f, 16, 128)); - models[7] = LoadModelFromMesh(GenMeshPoly(5, 2.0f)); - - // Set checked texture as default diffuse component for all models material - for (int i = 0; i < NUM_MODELS; i++) models[i].materials[0].maps[MAP_DIFFUSE].texture = texture; - - // Define the camera to look into our 3d world - Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; - - // Model drawing position - Vector3 position = { 0.0f, 0.0f, 0.0f }; - - int currentModel = 0; - - SetCameraMode(camera, CAMERA_ORBITAL); // Set a 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(&camera); // Update internal camera and our camera - - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - currentModel = (currentModel + 1)%NUM_MODELS; // Cycle between the textures - } - - if (IsKeyPressed(KEY_RIGHT)) - { - currentModel++; - if (currentModel >= NUM_MODELS) currentModel = 0; - } - else if (IsKeyPressed(KEY_LEFT)) - { - currentModel--; - if (currentModel < 0) currentModel = NUM_MODELS - 1; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModel(models[currentModel], position, 1.0f, WHITE); - - DrawGrid(10, 1.0); - - EndMode3D(); - - DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f)); - DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, BLUE); - - switch(currentModel) - { - case 0: DrawText("PLANE", 680, 10, 20, DARKBLUE); break; - case 1: DrawText("CUBE", 680, 10, 20, DARKBLUE); break; - case 2: DrawText("SPHERE", 680, 10, 20, DARKBLUE); break; - case 3: DrawText("HEMISPHERE", 640, 10, 20, DARKBLUE); break; - case 4: DrawText("CYLINDER", 680, 10, 20, DARKBLUE); break; - case 5: DrawText("TORUS", 680, 10, 20, DARKBLUE); break; - case 6: DrawText("KNOT", 680, 10, 20, DARKBLUE); break; - case 7: DrawText("POLY", 680, 10, 20, DARKBLUE); break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload models data (GPU VRAM) - for (int i = 0; i < NUM_MODELS; i++) UnloadModel(models[i]); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_mesh_picking.c b/examples/src/models/models_mesh_picking.c deleted file mode 100644 index 26d9fa7..0000000 --- a/examples/src/models/models_mesh_picking.c +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Mesh picking in 3d mode, ground plane, triangle, mesh -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* Example contributed by Joel Davis (@joeld42) -* -********************************************************************************************/ - -#include "raylib.h" -#include "raymath.h" - -#define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 20.0f, 20.0f, 20.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 8.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - Ray ray = { 0 }; // Picking ray - - Model tower = LoadModel("resources/models/turret.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load model texture - tower.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture - - Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position - BoundingBox towerBBox = MeshBoundingBox(tower.meshes[0]); // Get mesh bounding box - bool hitMeshBBox = false; - bool hitTriangle = false; - - // Test triangle - Vector3 ta = (Vector3){ -25.0, 0.5, 0.0 }; - Vector3 tb = (Vector3){ -4.0, 2.5, 1.0 }; - Vector3 tc = (Vector3){ -8.0, 6.5, 0.0 }; - - Vector3 bary = { 0.0f, 0.0f, 0.0f }; - - SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - - // Display information about closest hit - RayHitInfo nearestHit = { 0 }; - char *hitObjectName = "None"; - nearestHit.distance = FLT_MAX; - nearestHit.hit = false; - Color cursorColor = WHITE; - - // Get ray and test against ground, triangle, and mesh - ray = GetMouseRay(GetMousePosition(), camera); - - // Check ray collision aginst ground plane - RayHitInfo groundHitInfo = GetCollisionRayGround(ray, 0.0f); - - if ((groundHitInfo.hit) && (groundHitInfo.distance < nearestHit.distance)) - { - nearestHit = groundHitInfo; - cursorColor = GREEN; - hitObjectName = "Ground"; - } - - // Check ray collision against test triangle - RayHitInfo triHitInfo = GetCollisionRayTriangle(ray, ta, tb, tc); - - if ((triHitInfo.hit) && (triHitInfo.distance < nearestHit.distance)) - { - nearestHit = triHitInfo; - cursorColor = PURPLE; - hitObjectName = "Triangle"; - - bary = Vector3Barycenter(nearestHit.position, ta, tb, tc); - hitTriangle = true; - } - else hitTriangle = false; - - RayHitInfo meshHitInfo = { 0 }; - - // Check ray collision against bounding box first, before trying the full ray-mesh test - if (CheckCollisionRayBox(ray, towerBBox)) - { - hitMeshBBox = true; - - // Check ray collision against model - // NOTE: It considers model.transform matrix! - meshHitInfo = GetCollisionRayModel(ray, &tower); - - if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance)) - { - nearestHit = meshHitInfo; - cursorColor = ORANGE; - hitObjectName = "Mesh"; - } - } - - hitMeshBBox = false; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - // Draw the tower - // WARNING: If scale is different than 1.0f, - // not considered by GetCollisionRayModel() - DrawModel(tower, towerPos, 1.0f, WHITE); - - // Draw the test triangle - DrawLine3D(ta, tb, PURPLE); - DrawLine3D(tb, tc, PURPLE); - DrawLine3D(tc, ta, PURPLE); - - // Draw the mesh bbox if we hit it - if (hitMeshBBox) DrawBoundingBox(towerBBox, LIME); - - // If we hit something, draw the cursor at the hit point - if (nearestHit.hit) - { - DrawCube(nearestHit.position, 0.3, 0.3, 0.3, cursorColor); - DrawCubeWires(nearestHit.position, 0.3, 0.3, 0.3, RED); - - Vector3 normalEnd; - normalEnd.x = nearestHit.position.x + nearestHit.normal.x; - normalEnd.y = nearestHit.position.y + nearestHit.normal.y; - normalEnd.z = nearestHit.position.z + nearestHit.normal.z; - - DrawLine3D(nearestHit.position, normalEnd, RED); - } - - DrawRay(ray, MAROON); - - DrawGrid(10, 10.0f); - - EndMode3D(); - - // Draw some debug GUI text - DrawText(FormatText("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK); - - if (nearestHit.hit) - { - int ypos = 70; - - DrawText(FormatText("Distance: %3.2f", nearestHit.distance), 10, ypos, 10, BLACK); - - DrawText(FormatText("Hit Pos: %3.2f %3.2f %3.2f", - nearestHit.position.x, - nearestHit.position.y, - nearestHit.position.z), 10, ypos + 15, 10, BLACK); - - DrawText(FormatText("Hit Norm: %3.2f %3.2f %3.2f", - nearestHit.normal.x, - nearestHit.normal.y, - nearestHit.normal.z), 10, ypos + 30, 10, BLACK); - - if (hitTriangle) DrawText(FormatText("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK); - } - - DrawText("Use Mouse to Move Camera", 10, 430, 10, GRAY); - - DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadModel(tower); // Unload model - UnloadTexture(texture); // Unload texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_obj_loading.c b/examples/src/models/models_obj_loading.c deleted file mode 100644 index 51578bc..0000000 --- a/examples/src/models/models_obj_loading.c +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Load and draw a 3d model (OBJ) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 8.0f, 8.0f, 8.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 2.5f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera mode type - - Model model = LoadModel("resources/models/castle.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture - model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture - Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - - 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 - //---------------------------------------------------------------------------------- - //... - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModel(model, position, 0.2f, WHITE); // Draw 3d model with texture - - DrawGrid(10, 1.0f); // Draw a grid - - DrawGizmo(position); // Draw gizmo - - EndMode3D(); - - DrawText("(c) Castle 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Unload texture - UnloadModel(model); // Unload model - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_obj_viewer.c b/examples/src/models/models_obj_viewer.c deleted file mode 100644 index dc6787e..0000000 --- a/examples/src/models/models_obj_viewer.c +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - OBJ models viewer -* -* This example has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <string.h> // Required for: strcpy() - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib example - obj viewer"); - - // Define the camera to look into our 3d world - Camera camera = {{ 30.0f, 30.0f, 30.0f }, { 0.0f, 10.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; - - Model model = LoadModel("resources/models/turret.obj"); // Load default model obj - Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load default model texture - model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Bind texture to model - - Vector3 position = { 0.0, 0.0, 0.0 }; // Set model position - BoundingBox bounds = MeshBoundingBox(model.meshes[0]); // Set model bounds - bool selected = false; // Selected object flag - - SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode - - char objFilename[64] = "turret.obj"; - - 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 - //---------------------------------------------------------------------------------- - if (IsFileDropped()) - { - int count = 0; - char **droppedFiles = GetDroppedFiles(&count); - - if (count == 1) - { - if (IsFileExtension(droppedFiles[0], ".obj")) - { - for (int i = 0; i < model.meshCount; i++) UnloadMesh(&model.meshes[i]); - model.meshes = LoadMeshes(droppedFiles[0], &model.meshCount); - bounds = MeshBoundingBox(model.meshes[0]); - } - else if (IsFileExtension(droppedFiles[0], ".png")) - { - UnloadTexture(texture); - texture = LoadTexture(droppedFiles[0]); - model.materials[0].maps[MAP_DIFFUSE].texture = texture; - } - - strcpy(objFilename, GetFileName(droppedFiles[0])); - } - - ClearDroppedFiles(); // Clear internal buffers - } - - UpdateCamera(&camera); - - // Select model on mouse click - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - // Check collision between ray and box - if (CheckCollisionRayBox(GetMouseRay(GetMousePosition(), camera), bounds)) selected = !selected; - else selected = false; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModel(model, position, 1.0f, WHITE); // Draw 3d model with texture - - DrawGrid(20.0, 10.0); // Draw a grid - - if (selected) DrawBoundingBox(bounds, GREEN); - - EndMode3D(); - - DrawText("Free camera default controls:", 10, 20, 10, DARKGRAY); - DrawText("- Mouse Wheel to Zoom in-out", 20, 40, 10, GRAY); - DrawText("- Mouse Wheel Pressed to Pan", 20, 60, 10, GRAY); - DrawText("- Alt + Mouse Wheel Pressed to Rotate", 20, 80, 10, GRAY); - DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 20, 100, 10, GRAY); - - DrawText("Drag & drop .obj/.png to load mesh/texture.", 10, GetScreenHeight() - 20, 10, DARKGRAY); - DrawText(FormatText("Current file: %s", objFilename), 250, GetScreenHeight() - 20, 10, GRAY); - if (selected) DrawText("MODEL SELECTED", GetScreenWidth() - 110, 10, 10, GREEN); - - DrawText("(c) Turret 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadModel(model); // Unload model - - ClearDroppedFiles(); // Clear internal buffers - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/models/models_orthographic_projection.c b/examples/src/models/models_orthographic_projection.c deleted file mode 100644 index ca9d83c..0000000 --- a/examples/src/models/models_orthographic_projection.c +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Show the difference between perspective and orthographic projection -* -* This program is heavily based on the geometric objects example -* -* This example has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Max Danielsson (@autious) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Max Danielsson (@autious) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define FOVY_PERSPECTIVE 45.0f -#define WIDTH_ORTHOGRAPHIC 10.0f - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); - - // Define the camera to look into our 3d world - Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE }; - - 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 - //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_SPACE)) - { - if (camera.type == CAMERA_PERSPECTIVE) - { - camera.fovy = WIDTH_ORTHOGRAPHIC; - camera.type = CAMERA_ORTHOGRAPHIC; - } - else - { - camera.fovy = FOVY_PERSPECTIVE; - camera.type = CAMERA_PERSPECTIVE; - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); - DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); - DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON); - - DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN); - DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME); - - DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE); - DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE); - DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN); - - DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD); - DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK); - - DrawGrid(10, 1.0f); // Draw a grid - - EndMode3D(); - - DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, DARKGRAY); - - if (camera.type == CAMERA_ORTHOGRAPHIC) DrawText("ORTHOGRAPHIC", 10, 40, 20, BLACK); - else if (camera.type == CAMERA_PERSPECTIVE) DrawText("PERSPECTIVE", 10, 40, 20, BLACK); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/models/models_rlgl_solar_system.c b/examples/src/models/models_rlgl_solar_system.c deleted file mode 100644 index cb9289a..0000000 --- a/examples/src/models/models_rlgl_solar_system.c +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - rlgl module usage with push/pop matrix transformations -* -* This example uses [rlgl] module funtionality (pseudo-OpenGL 1.1 style coding) -* -* This example has been created using raylib 2.2 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2018 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "rlgl.h" - -//------------------------------------------------------------------------------------ -// Module Functions Declaration -//------------------------------------------------------------------------------------ -void DrawSphereBasic(Color color); // Draw sphere without any matrix transformation - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - const float sunRadius = 4.0f; - const float earthRadius = 0.6f; - const float earthOrbitRadius = 8.0f; - const float moonRadius = 0.16f; - const float moonOrbitRadius = 1.5f; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - rlgl module usage with push/pop matrix transformations"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 16.0f, 16.0f, 16.0f }; - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; - - SetCameraMode(camera, CAMERA_FREE); - - float rotationSpeed = 0.2f; // General system rotation speed - - float earthRotation = 0.0f; // Rotation of earth around itself (days) in degrees - float earthOrbitRotation = 0.0f; // Rotation of earth around the Sun (years) in degrees - float moonRotation = 0.0f; // Rotation of moon around itself - float moonOrbitRotation = 0.0f; // Rotation of moon around earth in degrees - - 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(&camera); - - earthRotation += (5.0f*rotationSpeed); - earthOrbitRotation += (365/360.0f*(5.0f*rotationSpeed)*rotationSpeed); - moonRotation += (2.0f*rotationSpeed); - moonOrbitRotation += (8.0f*rotationSpeed); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - rlPushMatrix(); - rlScalef(sunRadius, sunRadius, sunRadius); // Scale Sun - DrawSphereBasic(GOLD); // Draw the Sun - rlPopMatrix(); - - rlPushMatrix(); - rlRotatef(earthOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Earth orbit around Sun - rlTranslatef(earthOrbitRadius, 0.0f, 0.0f); // Translation for Earth orbit - rlRotatef(-earthOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Earth orbit around Sun inverted - - rlPushMatrix(); - rlRotatef(earthRotation, 0.25, 1.0, 0.0); // Rotation for Earth itself - rlScalef(earthRadius, earthRadius, earthRadius);// Scale Earth - - DrawSphereBasic(BLUE); // Draw the Earth - rlPopMatrix(); - - rlRotatef(moonOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon orbit around Earth - rlTranslatef(moonOrbitRadius, 0.0f, 0.0f); // Translation for Moon orbit - rlRotatef(-moonOrbitRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon orbit around Earth inverted - rlRotatef(moonRotation, 0.0f, 1.0f, 0.0f); // Rotation for Moon itself - rlScalef(moonRadius, moonRadius, moonRadius); // Scale Moon - - DrawSphereBasic(LIGHTGRAY); // Draw the Moon - rlPopMatrix(); - - // Some reference elements (not affected by previous matrix transformations) - DrawCircle3D((Vector3){ 0.0f, 0.0f, 0.0f }, earthOrbitRadius, (Vector3){ 1, 0, 0 }, 90.0f, Fade(RED, 0.5f)); - DrawGrid(20, 1.0f); - - EndMode3D(); - - DrawText("EARTH ORBITING AROUND THE SUN!", 400, 10, 20, MAROON); - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//-------------------------------------------------------------------------------------------- -// Module Functions Definitions (local) -//-------------------------------------------------------------------------------------------- - -// Draw sphere without any matrix transformation -// NOTE: Sphere is drawn in world position ( 0, 0, 0 ) with radius 1.0f -void DrawSphereBasic(Color color) -{ - int rings = 16; - int slices = 16; - - rlBegin(RL_TRIANGLES); - rlColor4ub(color.r, color.g, color.b, color.a); - - for (int i = 0; i < (rings + 2); i++) - { - for (int j = 0; j < slices; j++) - { - rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*i))*sinf(DEG2RAD*(j*360/slices)), - sinf(DEG2RAD*(270+(180/(rings + 1))*i)), - cosf(DEG2RAD*(270+(180/(rings + 1))*i))*cosf(DEG2RAD*(j*360/slices))); - rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*sinf(DEG2RAD*((j+1)*360/slices)), - sinf(DEG2RAD*(270+(180/(rings + 1))*(i+1))), - cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*cosf(DEG2RAD*((j+1)*360/slices))); - rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*sinf(DEG2RAD*(j*360/slices)), - sinf(DEG2RAD*(270+(180/(rings + 1))*(i+1))), - cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*cosf(DEG2RAD*(j*360/slices))); - - rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*i))*sinf(DEG2RAD*(j*360/slices)), - sinf(DEG2RAD*(270+(180/(rings + 1))*i)), - cosf(DEG2RAD*(270+(180/(rings + 1))*i))*cosf(DEG2RAD*(j*360/slices))); - rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*(i)))*sinf(DEG2RAD*((j+1)*360/slices)), - sinf(DEG2RAD*(270+(180/(rings + 1))*(i))), - cosf(DEG2RAD*(270+(180/(rings + 1))*(i)))*cosf(DEG2RAD*((j+1)*360/slices))); - rlVertex3f(cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*sinf(DEG2RAD*((j+1)*360/slices)), - sinf(DEG2RAD*(270+(180/(rings + 1))*(i+1))), - cosf(DEG2RAD*(270+(180/(rings + 1))*(i+1)))*cosf(DEG2RAD*((j+1)*360/slices))); - } - } - rlEnd(); -} diff --git a/examples/src/models/models_skybox.c b/examples/src/models/models_skybox.c deleted file mode 100644 index 1693d9b..0000000 --- a/examples/src/models/models_skybox.c +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Skybox loading and drawing -* -* 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) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing"); - - // Define the camera to look into our 3d world - Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 4.0f, 1.0f, 4.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; - - // Load skybox model - Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f); - Model skybox = LoadModelFromMesh(cube); - - // Load skybox shader and set required locations - // NOTE: Some locations are automatically set at shader loading -#if defined(PLATFORM_DESKTOP) - skybox.materials[0].shader = LoadShader("resources/shaders/glsl330/skybox.vs", "resources/shaders/glsl330/skybox.fs"); -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - skybox.materials[0].shader = LoadShader("resources/shaders/glsl100/skybox.vs", "resources/shaders/glsl100/skybox.fs"); -#endif - SetShaderValue(skybox.materials[0].shader, GetShaderLocation(skybox.materials[0].shader, "environmentMap"), (int[1]){ MAP_CUBEMAP }, UNIFORM_INT); - - // Load cubemap shader and setup required shader locations -#if defined(PLATFORM_DESKTOP) - Shader shdrCubemap = LoadShader("resources/shaders/glsl330/cubemap.vs", "resources/shaders/glsl330/cubemap.fs"); -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - Shader shdrCubemap = LoadShader("resources/shaders/glsl100/cubemap.vs", "resources/shaders/glsl100/cubemap.fs"); -#endif - SetShaderValue(shdrCubemap, GetShaderLocation(shdrCubemap, "equirectangularMap"), (int[1]){ 0 }, UNIFORM_INT); - - // Load HDR panorama (sphere) texture - Texture2D texHDR = LoadTexture("resources/dresden_square.hdr"); - - // Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture - // NOTE: New texture is generated rendering to texture, shader computes the sphre->cube coordinates mapping - skybox.materials[0].maps[MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, texHDR, 512); - - UnloadTexture(texHDR); // Texture not required anymore, cubemap already generated - UnloadShader(shdrCubemap); // Unload cubemap generation shader, not required anymore - - SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set a first person 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(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE); - - DrawGrid(10, 1.0f); - - EndMode3D(); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadModel(skybox); // Unload skybox model (and textures) - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/models/models_yaw_pitch_roll.c b/examples/src/models/models_yaw_pitch_roll.c deleted file mode 100644 index 0931c00..0000000 --- a/examples/src/models/models_yaw_pitch_roll.c +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Plane rotations (yaw, pitch, roll) -* -* 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) -* -* Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2017 Berni (@Berni8k) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include "raymath.h" - -// Draw angle gauge controls -void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[], Color color); - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - plane rotations (yaw, pitch, roll)"); - - Texture2D texAngleGauge = LoadTexture("resources/angle_gauge.png"); - Texture2D texBackground = LoadTexture("resources/background.png"); - Texture2D texPitch = LoadTexture("resources/pitch.png"); - Texture2D texPlane = LoadTexture("resources/plane.png"); - - RenderTexture2D framebuffer = LoadRenderTexture(192, 192); - - // Model loading - Model model = LoadModel("resources/plane.obj"); // Load OBJ model - model.materials[0].maps[MAP_DIFFUSE].texture = LoadTexture("resources/plane_diffuse.png"); // Set map diffuse texture - - GenTextureMipmaps(&model.materials[0].maps[MAP_DIFFUSE].texture); - - Camera camera = { 0 }; - camera.position = (Vector3){ 0.0f, 60.0f, -120.0f };// Camera position perspective - camera.target = (Vector3){ 0.0f, 12.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 30.0f; // Camera field-of-view Y - camera.type = CAMERA_PERSPECTIVE; // Camera type - - float pitch = 0.0f; - float roll = 0.0f; - float yaw = 0.0f; - - 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 - //---------------------------------------------------------------------------------- - - // Plane roll (x-axis) controls - if (IsKeyDown(KEY_LEFT)) roll += 1.0f; - else if (IsKeyDown(KEY_RIGHT)) roll -= 1.0f; - else - { - if (roll > 0.0f) roll -= 0.5f; - else if (roll < 0.0f) roll += 0.5f; - } - - // Plane yaw (y-axis) controls - if (IsKeyDown(KEY_S)) yaw += 1.0f; - else if (IsKeyDown(KEY_A)) yaw -= 1.0f; - else - { - if (yaw > 0.0f) yaw -= 0.5f; - else if (yaw < 0.0f) yaw += 0.5f; - } - - // Plane pitch (z-axis) controls - if (IsKeyDown(KEY_DOWN)) pitch += 0.6f; - else if (IsKeyDown(KEY_UP)) pitch -= 0.6f; - else - { - if (pitch > 0.3f) pitch -= 0.3f; - else if (pitch < -0.3f) pitch += 0.3f; - } - - // Wraps the phase of an angle to fit between -180 and +180 degrees - int pitchOffset = pitch; - while (pitchOffset > 180) pitchOffset -= 360; - while (pitchOffset < -180) pitchOffset += 360; - pitchOffset *= 10; - - Matrix transform = MatrixIdentity(); - - transform = MatrixMultiply(transform, MatrixRotateZ(DEG2RAD*roll)); - transform = MatrixMultiply(transform, MatrixRotateX(DEG2RAD*pitch)); - transform = MatrixMultiply(transform, MatrixRotateY(DEG2RAD*yaw)); - - model.transform = transform; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw framebuffer texture (Ahrs Display) - int centerX = framebuffer.texture.width/2; - int centerY = framebuffer.texture.height/2; - float scaleFactor = 0.5f; - - BeginTextureMode(framebuffer); - - BeginBlendMode(BLEND_ALPHA); - - DrawTexturePro(texBackground, (Rectangle){ 0, 0, texBackground.width, texBackground.height }, - (Rectangle){ centerX, centerY, texBackground.width*scaleFactor, texBackground.height*scaleFactor}, - (Vector2){ texBackground.width/2*scaleFactor, texBackground.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE); - - DrawTexturePro(texPitch, (Rectangle){ 0, 0, texPitch.width, texPitch.height }, - (Rectangle){ centerX, centerY, texPitch.width*scaleFactor, texPitch.height*scaleFactor }, - (Vector2){ texPitch.width/2*scaleFactor, texPitch.height/2*scaleFactor + pitchOffset*scaleFactor }, roll, WHITE); - - DrawTexturePro(texPlane, (Rectangle){ 0, 0, texPlane.width, texPlane.height }, - (Rectangle){ centerX, centerY, texPlane.width*scaleFactor, texPlane.height*scaleFactor }, - (Vector2){ texPlane.width/2*scaleFactor, texPlane.height/2*scaleFactor }, 0, WHITE); - - EndBlendMode(); - - EndTextureMode(); - - // Draw 3D model (recomended to draw 3D always before 2D) - BeginMode3D(camera); - - DrawModel(model, (Vector3){ 0, 6.0f, 0 }, 1.0f, WHITE); // Draw 3d model with texture - DrawGrid(10, 10.0f); - - EndMode3D(); - - // Draw 2D GUI stuff - DrawAngleGauge(texAngleGauge, 80, 70, roll, "roll", RED); - DrawAngleGauge(texAngleGauge, 190, 70, pitch, "pitch", GREEN); - DrawAngleGauge(texAngleGauge, 300, 70, yaw, "yaw", SKYBLUE); - - DrawRectangle(30, 360, 260, 70, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines(30, 360, 260, 70, Fade(DARKBLUE, 0.5f)); - DrawText("Pitch controlled with: KEY_UP / KEY_DOWN", 40, 370, 10, DARKGRAY); - DrawText("Roll controlled with: KEY_LEFT / KEY_RIGHT", 40, 390, 10, DARKGRAY); - DrawText("Yaw controlled with: KEY_A / KEY_S", 40, 410, 10, DARKGRAY); - - // Draw framebuffer texture - DrawTextureRec(framebuffer.texture, (Rectangle){ 0, 0, framebuffer.texture.width, -framebuffer.texture.height }, - (Vector2){ screenWidth - framebuffer.texture.width - 20, 20 }, Fade(WHITE, 0.8f)); - - DrawRectangleLines(screenWidth - framebuffer.texture.width - 20, 20, framebuffer.texture.width, framebuffer.texture.height, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload all loaded data - UnloadModel(model); - - UnloadRenderTexture(framebuffer); - - UnloadTexture(texAngleGauge); - UnloadTexture(texBackground); - UnloadTexture(texPitch); - UnloadTexture(texPlane); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -// Draw angle gauge controls -void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[], Color color) -{ - Rectangle srcRec = { 0, 0, angleGauge.width, angleGauge.height }; - Rectangle dstRec = { x, y, angleGauge.width, angleGauge.height }; - Vector2 origin = { angleGauge.width/2, angleGauge.height/2}; - int textSize = 20; - - DrawTexturePro(angleGauge, srcRec, dstRec, origin, angle, color); - - DrawText(FormatText("%5.1f", angle), x - MeasureText(FormatText("%5.1f", angle), textSize) / 2, y + 10, textSize, DARKGRAY); - DrawText(title, x - MeasureText(title, textSize) / 2, y + 60, textSize, DARKGRAY); -} diff --git a/examples/src/physac/physics_demo.c b/examples/src/physac/physics_demo.c deleted file mode 100644 index 421c82a..0000000 --- a/examples/src/physac/physics_demo.c +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************************* -* -* Physac - Physics demo -* -* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. -* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) -* -* Use the following line to compile: -* -* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static / -* -lraylib -lpthread -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm / -* -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition -* -* Copyright (c) 2016-2018 Victor Fisac -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#define PHYSAC_NO_THREADS -#include "physac.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics demo"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - bool needsReset = false; - - // Initialize physics and default physics bodies - InitPhysics(); - - // Create floor rectangle physics body - PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10); - floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - - // Create obstacle circle physics body - PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10); - circle->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - - 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 - //---------------------------------------------------------------------------------- - // Delay initialization of variables due to physics reset async - RunPhysicsStep(); - - if (needsReset) - { - floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10); - floor->enabled = false; - - circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10); - circle->enabled = false; - - needsReset = false; - } - - // Reset physics input - if (IsKeyPressed('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); - - // Destroy falling physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = bodiesCount - 1; i >= 0; i--) - { - PhysicsBody body = GetPhysicsBody(i); - if (body != NULL && (body->position.y > screenHeight*2)) DestroyPhysicsBody(body); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - DrawFPS(screenWidth - 90, screenHeight - 30); - - // Draw created physics bodies - bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody body = GetPhysicsBody(i); - - if (body != NULL) - { - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(body, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(body, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - } - - DrawText("Left mouse button to create a polygon", 10, 10, 10, WHITE); - DrawText("Right mouse button to create a circle", 10, 25, 10, WHITE); - DrawText("Press 'R' to reset example", 10, 40, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/physac/physics_friction.c b/examples/src/physac/physics_friction.c deleted file mode 100644 index cbb9dc4..0000000 --- a/examples/src/physac/physics_friction.c +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************************* -* -* Physac - Physics friction -* -* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. -* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) -* -* Use the following line to compile: -* -* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static / -* -lraylib -lpthread -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm / -* -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition -* -* Copyright (c) 2016-2018 Victor Fisac -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#define PHYSAC_NO_THREADS -#include "physac.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics friction"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - - // Initialize physics and default physics bodies - InitPhysics(); - - // Create floor rectangle physics body - PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10); - floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - PhysicsBody wall = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight*0.8f }, 10, 80, 10); - wall->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - - // Create left ramp physics body - PhysicsBody rectLeft = CreatePhysicsBodyRectangle((Vector2){ 25, screenHeight - 5 }, 250, 250, 10); - rectLeft->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - SetPhysicsBodyRotation(rectLeft, 30*DEG2RAD); - - // Create right ramp physics body - PhysicsBody rectRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 25, screenHeight - 5 }, 250, 250, 10); - rectRight->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - SetPhysicsBodyRotation(rectRight, 330*DEG2RAD); - - // Create dynamic physics bodies - PhysicsBody bodyA = CreatePhysicsBodyRectangle((Vector2){ 35, screenHeight*0.6f }, 40, 40, 10); - bodyA->staticFriction = 0.1f; - bodyA->dynamicFriction = 0.1f; - SetPhysicsBodyRotation(bodyA, 30*DEG2RAD); - - PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 35, screenHeight*0.6f }, 40, 40, 10); - bodyB->staticFriction = 1; - bodyB->dynamicFriction = 1; - SetPhysicsBodyRotation(bodyB, 330*DEG2RAD); - - 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 - //---------------------------------------------------------------------------------- - RunPhysicsStep(); - - if (IsKeyPressed('R')) // Reset physics input - { - // Reset dynamic physics bodies position, velocity and rotation - bodyA->position = (Vector2){ 35, screenHeight*0.6f }; - bodyA->velocity = (Vector2){ 0, 0 }; - bodyA->angularVelocity = 0; - SetPhysicsBodyRotation(bodyA, 30*DEG2RAD); - - bodyB->position = (Vector2){ screenWidth - 35, screenHeight*0.6f }; - bodyB->velocity = (Vector2){ 0, 0 }; - bodyB->angularVelocity = 0; - SetPhysicsBodyRotation(bodyB, 330*DEG2RAD); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - DrawFPS(screenWidth - 90, screenHeight - 30); - - // Draw created physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody body = GetPhysicsBody(i); - - if (body != NULL) - { - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(body, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(body, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - } - - DrawRectangle(0, screenHeight - 49, screenWidth, 49, BLACK); - - DrawText("Friction amount", (screenWidth - MeasureText("Friction amount", 30))/2, 75, 30, WHITE); - DrawText("0.1", bodyA->position.x - MeasureText("0.1", 20)/2, bodyA->position.y - 7, 20, WHITE); - DrawText("1", bodyB->position.x - MeasureText("1", 20)/2, bodyB->position.y - 7, 20, WHITE); - - DrawText("Press 'R' to reset example", 10, 10, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/physac/physics_movement.c b/examples/src/physac/physics_movement.c deleted file mode 100644 index d946811..0000000 --- a/examples/src/physac/physics_movement.c +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************************* -* -* Physac - Physics movement -* -* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. -* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) -* -* Use the following line to compile: -* -* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static / -* -lraylib -lpthread -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm / -* -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition -* -* Copyright (c) 2016-2018 Victor Fisac -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#define PHYSAC_NO_THREADS -#include "physac.h" - -#define VELOCITY 0.5f - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics movement"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - - // Initialize physics and default physics bodies - InitPhysics(); - - // Create floor and walls rectangle physics body - PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10); - PhysicsBody platformLeft = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.25f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10); - PhysicsBody platformRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth*0.75f, screenHeight*0.6f }, screenWidth*0.25f, 10, 10); - PhysicsBody wallLeft = CreatePhysicsBodyRectangle((Vector2){ -5, screenHeight/2 }, 10, screenHeight, 10); - PhysicsBody wallRight = CreatePhysicsBodyRectangle((Vector2){ screenWidth + 5, screenHeight/2 }, 10, screenHeight, 10); - - // Disable dynamics to floor and walls physics bodies - floor->enabled = false; - platformLeft->enabled = false; - platformRight->enabled = false; - wallLeft->enabled = false; - wallRight->enabled = false; - - // Create movement physics body - PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight/2 }, 50, 50, 1); - body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts - - 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 - //---------------------------------------------------------------------------------- - RunPhysicsStep(); - - if (IsKeyPressed('R')) // Reset physics input - { - // Reset movement physics body position, velocity and rotation - body->position = (Vector2){ screenWidth/2, screenHeight/2 }; - body->velocity = (Vector2){ 0, 0 }; - SetPhysicsBodyRotation(body, 0); - } - - // Horizontal movement input - if (IsKeyDown(KEY_RIGHT)) body->velocity.x = VELOCITY; - else if (IsKeyDown(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; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - DrawFPS(screenWidth - 90, screenHeight - 30); - - // Draw created physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody body = GetPhysicsBody(i); - - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(body, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(body, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - - DrawText("Use 'ARROWS' to move player", 10, 10, 10, WHITE); - DrawText("Press 'R' to reset example", 10, 30, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/physac/physics_restitution.c b/examples/src/physac/physics_restitution.c deleted file mode 100644 index a701252..0000000 --- a/examples/src/physac/physics_restitution.c +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************************* -* -* Physac - Physics restitution -* -* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. -* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) -* -* Use the following line to compile: -* -* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static / -* -lraylib -lpthread -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm / -* -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition -* -* Copyright (c) 2016-2018 Victor Fisac -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#define PHYSAC_NO_THREADS -#include "physac.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics restitution"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - - // Initialize physics and default physics bodies - InitPhysics(); - - // Create floor rectangle physics body - PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10); - floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) - floor->restitution = 1; - - // Create circles physics body - PhysicsBody circleA = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.25f, screenHeight/2 }, 30, 10); - circleA->restitution = 0; - PhysicsBody circleB = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.5f, screenHeight/2 }, 30, 10); - circleB->restitution = 0.5f; - PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/2 }, 30, 10); - circleC->restitution = 1; - - // Restitution demo needs a very tiny physics time step for a proper simulation - SetPhysicsTimeStep(1.0/60.0/100*1000); - - 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 - //---------------------------------------------------------------------------------- - RunPhysicsStep(); - - if (IsKeyPressed('R')) // Reset physics input - { - // Reset circles physics bodies position and velocity - circleA->position = (Vector2){ screenWidth*0.25f, screenHeight/2 }; - circleA->velocity = (Vector2){ 0, 0 }; - circleB->position = (Vector2){ screenWidth*0.5f, screenHeight/2 }; - circleB->velocity = (Vector2){ 0, 0 }; - circleC->position = (Vector2){ screenWidth*0.75f, screenHeight/2 }; - circleC->velocity = (Vector2){ 0, 0 }; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - DrawFPS(screenWidth - 90, screenHeight - 30); - - // Draw created physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody body = GetPhysicsBody(i); - - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(body, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(body, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - - DrawText("Restitution amount", (screenWidth - MeasureText("Restitution amount", 30))/2, 75, 30, WHITE); - DrawText("0", circleA->position.x - MeasureText("0", 20)/2, circleA->position.y - 7, 20, WHITE); - DrawText("0.5", circleB->position.x - MeasureText("0.5", 20)/2, circleB->position.y - 7, 20, WHITE); - DrawText("1", circleC->position.x - MeasureText("1", 20)/2, circleC->position.y - 7, 20, WHITE); - - DrawText("Press 'R' to reset example", 10, 10, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/physac/physics_shatter.c b/examples/src/physac/physics_shatter.c deleted file mode 100644 index cbc6522..0000000 --- a/examples/src/physac/physics_shatter.c +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************************* -* -* Physac - Body shatter -* -* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. -* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) -* -* Use the following line to compile: -* -* gcc -o $(NAME_PART).exe $(FILE_NAME) -s -static / -* -lraylib -lpthread -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm / -* -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition -* -* Copyright (c) 2016-2018 Victor Fisac -* -********************************************************************************************/ - -#include "raylib.h" - -#define PHYSAC_IMPLEMENTATION -#define PHYSAC_NO_THREADS -#include "physac.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "Physac [raylib] - Body shatter"); - - // Physac logo drawing position - int logoX = screenWidth - MeasureText("Physac", 30) - 10; - int logoY = 15; - bool needsReset = false; - - // Initialize physics and default physics bodies - InitPhysics(); - SetPhysicsGravity(0, 0); - - // Create random polygon physics body to shatter - CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); - - 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 - RunPhysicsStep(); - - //---------------------------------------------------------------------------------- - // Delay initialization of variables due to physics reset asynchronous - if (needsReset) - { - // Create random polygon physics body to shatter - CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); - needsReset = false; - } - - if (IsKeyPressed('R')) // Reset physics input - { - ResetPhysics(); - needsReset = true; - } - - if (IsMouseButtonPressed(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(); - for (int i = count - 1; i >= 0; i--) - { - PhysicsBody currentBody = GetPhysicsBody(i); - if (currentBody != NULL) PhysicsShatter(currentBody, GetMousePosition(), 10/currentBody->inverseMass); - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); - - // Draw created physics bodies - int bodiesCount = GetPhysicsBodiesCount(); - for (int i = 0; i < bodiesCount; i++) - { - PhysicsBody currentBody = GetPhysicsBody(i); - - int vertexCount = GetPhysicsShapeVerticesCount(i); - for (int j = 0; j < vertexCount; j++) - { - // Get physics bodies shape vertices to draw lines - // Note: GetPhysicsShapeVertex() already calculates rotation transformations - Vector2 vertexA = GetPhysicsShapeVertex(currentBody, j); - - int jj = (((j + 1) < vertexCount) ? (j + 1) : 0); // Get next vertex or first to close the shape - Vector2 vertexB = GetPhysicsShapeVertex(currentBody, jj); - - DrawLineV(vertexA, vertexB, GREEN); // Draw a line between two vertex positions - } - } - - DrawText("Left mouse button in polygon area to shatter body\nPress 'R' to reset example", 10, 10, 10, WHITE); - - DrawText("Physac", logoX, logoY, 30, WHITE); - DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClosePhysics(); // Unitialize physics - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shaders/shaders_custom_uniform.c b/examples/src/shaders/shaders_custom_uniform.c deleted file mode 100644 index 1c82bba..0000000 --- a/examples/src/shaders/shaders_custom_uniform.c +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Apply a postprocessing shader and connect a custom uniform variable -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 8.0f, 8.0f, 8.0f }; - camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; - - Model model = LoadModel("resources/models/barracks.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/models/barracks_diffuse.png"); // Load model texture (diffuse map) - model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture - - Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - - // Load postprocessing shader - // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/swirl.fs", GLSL_VERSION)); - - // Get variable (uniform) location on the shader to connect with the program - // NOTE: If uniform variable could not be found in the shader, function returns -1 - int swirlCenterLoc = GetShaderLocation(shader, "center"); - - float swirlCenter[2] = { (float)screenWidth/2, (float)screenHeight/2 }; - - // Create a RenderTexture2D to be used for render to texture - RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); - - // Setup orbital camera - SetCameraMode(camera, 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 - //---------------------------------------------------------------------------------- - Vector2 mousePosition = GetMousePosition(); - - swirlCenter[0] = mousePosition.x; - swirlCenter[1] = screenHeight - mousePosition.y; - - // Send new value to the shader to be used on drawing - SetShaderValue(shader, swirlCenterLoc, swirlCenter, UNIFORM_VEC2); - - UpdateCamera(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginTextureMode(target); // Enable drawing to texture - - ClearBackground(RAYWHITE); // Clear texture background - - BeginMode3D(camera); // Begin 3d mode drawing - - DrawModel(model, position, 0.5f, WHITE); // Draw 3d model with texture - - DrawGrid(10, 1.0f); // Draw a grid - - EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode - - DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, RED); - - EndTextureMode(); // End drawing to texture (now we have a texture available for next passes) - - BeginShaderMode(shader); - - // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) - DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE); - - EndShaderMode(); - - // Draw some 2d text over drawn texture - DrawText("(c) Barracks 3D model by Alberto Cano", screenWidth - 220, screenHeight - 20, 10, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadTexture(texture); // Unload texture - UnloadModel(model); // Unload model - UnloadRenderTexture(target); // Unload render texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shaders/shaders_eratosthenes.c b/examples/src/shaders/shaders_eratosthenes.c deleted file mode 100644 index 068fc26..0000000 --- a/examples/src/shaders/shaders_eratosthenes.c +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Sieve of Eratosthenes -* -* Sieve of Eratosthenes, the earliest known (ancient Greek) prime number sieve. -* -* "Sift the twos and sift the threes, -* The Sieve of Eratosthenes. -* When the multiples sublime, -* the numbers that are left are prime." -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3). -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by ProfJski and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 ProfJski and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Sieve of Eratosthenes"); - - RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); - - // Load Eratosthenes shader - // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/eratosthenes.fs", GLSL_VERSION)); - - 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 - //---------------------------------------------------------------------------------- - // Nothing to do here, everything is happening in the shader - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginTextureMode(target); // Enable drawing to texture - ClearBackground(BLACK); // Clear the render texture - - // 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(), BLACK); - EndTextureMode(); // End drawing to texture (now we have a blank texture available for the shader) - - BeginShaderMode(shader); - // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) - DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE); - EndShaderMode(); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadRenderTexture(target); // Unload texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shaders/shaders_julia_set.c b/examples/src/shaders/shaders_julia_set.c deleted file mode 100644 index e64b622..0000000 --- a/examples/src/shaders/shaders_julia_set.c +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - julia sets -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3). -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by eggmund (@eggmund) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 eggmund (@eggmund) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -// A few good julia sets -const float POINTS_OF_INTEREST[6][2] = -{ - { -0.348827, 0.607167 }, - { -0.786268, 0.169728 }, - { -0.8, 0.156 }, - { 0.285, 0.0 }, - { -0.835, -0.2321 }, - { -0.70176, -0.3842 }, -}; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - julia sets"); - - // Load julia set shader - // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/julia_set.fs", GLSL_VERSION)); - - // c constant to use in z^2 + c - float c[2] = { POINTS_OF_INTEREST[0][0], POINTS_OF_INTEREST[0][1] }; - - // Offset and zoom to draw the julia set at. (centered on screen and default size) - float offset[2] = { -(float)screenWidth/2, -(float)screenHeight/2 }; - float zoom = 1.0f; - - Vector2 offsetSpeed = { 0.0f, 0.0f }; - - // Get variable (uniform) locations on the shader to connect with the program - // NOTE: If uniform variable could not be found in the shader, function returns -1 - int cLoc = GetShaderLocation(shader, "c"); - int zoomLoc = GetShaderLocation(shader, "zoom"); - int offsetLoc = GetShaderLocation(shader, "offset"); - - // Tell the shader what the screen dimensions, zoom, offset and c are - float screenDims[2] = { (float)screenWidth, (float)screenHeight }; - SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, UNIFORM_VEC2); - - SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); - SetShaderValue(shader, zoomLoc, &zoom, UNIFORM_FLOAT); - SetShaderValue(shader, offsetLoc, offset, UNIFORM_VEC2); - - // Create a RenderTexture2D to be used for render to texture - RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); - - int incrementSpeed = 0; // Multiplier of speed to change c value - bool showControls = true; // Show controls - bool pause = false; // Pause animation - - 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 - //---------------------------------------------------------------------------------- - // Press [1 - 6] to reset c to a point of interest - if (IsKeyPressed(KEY_ONE) || - IsKeyPressed(KEY_TWO) || - IsKeyPressed(KEY_THREE) || - IsKeyPressed(KEY_FOUR) || - IsKeyPressed(KEY_FIVE) || - IsKeyPressed(KEY_SIX)) - { - if (IsKeyPressed(KEY_ONE)) c[0] = POINTS_OF_INTEREST[0][0], c[1] = POINTS_OF_INTEREST[0][1]; - else if (IsKeyPressed(KEY_TWO)) c[0] = POINTS_OF_INTEREST[1][0], c[1] = POINTS_OF_INTEREST[1][1]; - else if (IsKeyPressed(KEY_THREE)) c[0] = POINTS_OF_INTEREST[2][0], c[1] = POINTS_OF_INTEREST[2][1]; - else if (IsKeyPressed(KEY_FOUR)) c[0] = POINTS_OF_INTEREST[3][0], c[1] = POINTS_OF_INTEREST[3][1]; - else if (IsKeyPressed(KEY_FIVE)) c[0] = POINTS_OF_INTEREST[4][0], c[1] = POINTS_OF_INTEREST[4][1]; - else if (IsKeyPressed(KEY_SIX)) c[0] = POINTS_OF_INTEREST[5][0], c[1] = POINTS_OF_INTEREST[5][1]; - - SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); - } - - if (IsKeyPressed(KEY_SPACE)) pause = !pause; // Pause animation (c change) - if (IsKeyPressed(KEY_F1)) showControls = !showControls; // Toggle whether or not to show controls - - if (!pause) - { - if (IsKeyPressed(KEY_RIGHT)) incrementSpeed++; - else if (IsKeyPressed(KEY_LEFT)) incrementSpeed--; - - // TODO: The idea is to zoom and move around with mouse - // Probably offset movement should be proportional to zoom level - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) || IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) - { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) zoom += zoom*0.003f; - if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) zoom -= zoom*0.003f; - - Vector2 mousePos = GetMousePosition(); - - offsetSpeed.x = mousePos.x -(float)screenWidth/2; - offsetSpeed.y = mousePos.y -(float)screenHeight/2; - - // Slowly move camera to targetOffset - offset[0] += GetFrameTime()*offsetSpeed.x*0.8f; - offset[1] += GetFrameTime()*offsetSpeed.y*0.8f; - } - else offsetSpeed = (Vector2){ 0.0f, 0.0f }; - - SetShaderValue(shader, zoomLoc, &zoom, UNIFORM_FLOAT); - SetShaderValue(shader, offsetLoc, offset, UNIFORM_VEC2); - - // Increment c value with time - float amount = GetFrameTime()*incrementSpeed*0.0005f; - c[0] += amount; - c[1] += amount; - - SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(BLACK); // Clear the screen of the previous frame. - - // Using a render texture to draw Julia set - BeginTextureMode(target); // Enable drawing to texture - ClearBackground(BLACK); // Clear the render texture - - // 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(), 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, WHITE); - EndShaderMode(); - - if (showControls) - { - DrawText("Press Mouse buttons right/left to zoom in/out and move", 10, 15, 10, RAYWHITE); - DrawText("Press KEY_F1 to toggle these controls", 10, 30, 10, RAYWHITE); - DrawText("Press KEYS [1 - 6] to change point of interest", 10, 45, 10, RAYWHITE); - DrawText("Press KEY_LEFT | KEY_RIGHT to change speed", 10, 60, 10, RAYWHITE); - DrawText("Press KEY_SPACE to pause movement animation", 10, 75, 10, RAYWHITE); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadRenderTexture(target); // Unload render texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shaders/shaders_model_shader.c b/examples/src/shaders/shaders_model_shader.c deleted file mode 100644 index 8224a33..0000000 --- a/examples/src/shaders/shaders_model_shader.c +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Apply a shader to a 3d model -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader"); - - // Define the camera to look into our 3d world - Camera camera = { 0 }; - camera.position = (Vector3){ 4.0f, 4.0f, 4.0f }; - camera.target = (Vector3){ 0.0f, 1.0f, -1.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; - - Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture - - // Load shader for model - // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION)); - - model.materials[0].shader = shader; // Set shader effect to 3d model - model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Bind texture to model - - Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - - SetCameraMode(camera, CAMERA_FREE); // 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(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginMode3D(camera); - - DrawModel(model, position, 0.2f, WHITE); // Draw 3d model with texture - - DrawGrid(10, 1.0f); // Draw a grid - - EndMode3D(); - - DrawText("(c) Watermill 3D model by Alberto Cano", screenWidth - 210, screenHeight - 20, 10, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadTexture(texture); // Unload texture - UnloadModel(model); // Unload model - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shaders/shaders_palette_switch.c b/examples/src/shaders/shaders_palette_switch.c deleted file mode 100644 index 05e2e50..0000000 --- a/examples/src/shaders/shaders_palette_switch.c +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Color palette switch -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 2.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Marco Lizza (@MarcoLizza) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Marco Lizza (@MarcoLizza) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -#define MAX_PALETTES 3 -#define COLORS_PER_PALETTE 8 -#define VALUES_PER_COLOR 3 - -static const int palettes[MAX_PALETTES][COLORS_PER_PALETTE*VALUES_PER_COLOR] = { - { // 3-BIT RGB - 0, 0, 0, - 255, 0, 0, - 0, 255, 0, - 0, 0, 255, - 0, 255, 255, - 255, 0, 255, - 255, 255, 0, - 255, 255, 255, - }, - { // AMMO-8 (GameBoy-like) - 4, 12, 6, - 17, 35, 24, - 30, 58, 41, - 48, 93, 66, - 77, 128, 97, - 137, 162, 87, - 190, 220, 127, - 238, 255, 204, - }, - { // RKBV (2-strip film) - 21, 25, 26, - 138, 76, 88, - 217, 98, 117, - 230, 184, 193, - 69, 107, 115, - 75, 151, 166, - 165, 189, 194, - 255, 245, 247, - } -}; - -static const char *paletteText[] = { - "3-BIT RGB", - "AMMO-8 (GameBoy-like)", - "RKBV (2-strip film)" -}; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - color palette switch"); - - // Load shader to be used on some parts drawing - // NOTE 1: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version - // NOTE 2: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/palette_switch.fs", GLSL_VERSION)); - - // Get variable (uniform) location on the shader to connect with the program - // NOTE: If uniform variable could not be found in the shader, function returns -1 - int paletteLoc = GetShaderLocation(shader, "palette"); - - int currentPalette = 0; - int lineHeight = screenHeight/COLORS_PER_PALETTE; - - 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 - //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_RIGHT)) currentPalette++; - else if (IsKeyPressed(KEY_LEFT)) currentPalette--; - - if (currentPalette >= MAX_PALETTES) currentPalette = 0; - else if (currentPalette < 0) currentPalette = MAX_PALETTES - 1; - - // Send new value to the shader to be used on drawing. - // NOTE: We are sending RGB triplets w/o the alpha channel - SetShaderValueV(shader, paletteLoc, palettes[currentPalette], UNIFORM_IVEC3, COLORS_PER_PALETTE); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginShaderMode(shader); - - for (int i = 0; i < COLORS_PER_PALETTE; i++) - { - // Draw horizontal screen-wide rectangles with increasing "palette index" - // The used palette index is encoded in the RGB components of the pixel - DrawRectangle(0, lineHeight*i, GetScreenWidth(), lineHeight, (Color){ i, i, i, 255 }); - } - - EndShaderMode(); - - DrawText("< >", 10, 10, 30, DARKBLUE); - DrawText("CURRENT PALETTE:", 60, 15, 20, RAYWHITE); - DrawText(paletteText[currentPalette], 300, 15, 20, RED); - - DrawFPS(700, 15); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shaders/shaders_postprocessing.c b/examples/src/shaders/shaders_postprocessing.c deleted file mode 100644 index 018b8d1..0000000 --- a/examples/src/shaders/shaders_postprocessing.c +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Apply a postprocessing shader to a scene -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -#define MAX_POSTPRO_SHADERS 12 - -typedef enum { - FX_GRAYSCALE = 0, - FX_POSTERIZATION, - FX_DREAM_VISION, - FX_PIXELIZER, - FX_CROSS_HATCHING, - FX_CROSS_STITCHING, - FX_PREDATOR_VIEW, - FX_SCANLINES, - FX_FISHEYE, - FX_SOBEL, - FX_BLOOM, - FX_BLUR, - //FX_FXAA -} PostproShader; - -static const char *postproShaderText[] = { - "GRAYSCALE", - "POSTERIZATION", - "DREAM_VISION", - "PIXELIZER", - "CROSS_HATCHING", - "CROSS_STITCHING", - "PREDATOR_VIEW", - "SCANLINES", - "FISHEYE", - "SOBEL", - "BLOOM", - "BLUR", - //"FXAA" -}; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader"); - - // Define the camera to look into our 3d world - Camera camera = {{ 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; - - Model model = LoadModel("resources/models/church.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map) - model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set model diffuse texture - - Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - - // Load all postpro shaders - // NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER) - // NOTE 2: We load the correct shader depending on GLSL version - Shader shaders[MAX_POSTPRO_SHADERS]; - - // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - shaders[FX_GRAYSCALE] = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION)); - shaders[FX_POSTERIZATION] = LoadShader(0, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION)); - shaders[FX_DREAM_VISION] = LoadShader(0, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION)); - shaders[FX_PIXELIZER] = LoadShader(0, FormatText("resources/shaders/glsl%i/pixelizer.fs", GLSL_VERSION)); - shaders[FX_CROSS_HATCHING] = LoadShader(0, FormatText("resources/shaders/glsl%i/cross_hatching.fs", GLSL_VERSION)); - shaders[FX_CROSS_STITCHING] = LoadShader(0, FormatText("resources/shaders/glsl%i/cross_stitching.fs", GLSL_VERSION)); - shaders[FX_PREDATOR_VIEW] = LoadShader(0, FormatText("resources/shaders/glsl%i/predator.fs", GLSL_VERSION)); - shaders[FX_SCANLINES] = LoadShader(0, FormatText("resources/shaders/glsl%i/scanlines.fs", GLSL_VERSION)); - shaders[FX_FISHEYE] = LoadShader(0, FormatText("resources/shaders/glsl%i/fisheye.fs", GLSL_VERSION)); - shaders[FX_SOBEL] = LoadShader(0, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION)); - shaders[FX_BLOOM] = LoadShader(0, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION)); - shaders[FX_BLUR] = LoadShader(0, FormatText("resources/shaders/glsl%i/blur.fs", GLSL_VERSION)); - - int currentShader = FX_GRAYSCALE; - - // Create a RenderTexture2D to be used for render to texture - RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); - - // Setup orbital camera - SetCameraMode(camera, 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(&camera); // Update camera - - if (IsKeyPressed(KEY_RIGHT)) currentShader++; - else if (IsKeyPressed(KEY_LEFT)) currentShader--; - - if (currentShader >= MAX_POSTPRO_SHADERS) currentShader = 0; - else if (currentShader < 0) currentShader = MAX_POSTPRO_SHADERS - 1; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginTextureMode(target); // Enable drawing to texture - - ClearBackground(RAYWHITE); // Clear texture background - - BeginMode3D(camera); // Begin 3d mode drawing - - DrawModel(model, position, 0.1f, WHITE); // Draw 3d model with texture - - DrawGrid(10, 1.0f); // Draw a grid - - EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode - - EndTextureMode(); // End drawing to texture (now we have a texture available for next passes) - - // Render previously generated texture using selected postpro shader - BeginShaderMode(shaders[currentShader]); - - // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) - DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE); - - EndShaderMode(); - - // Draw 2d shapes and text over drawn texture - DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f)); - - DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY); - - DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, BLACK); - DrawText(postproShaderText[currentShader], 330, 15, 20, RED); - DrawText("< >", 540, 10, 30, DARKBLUE); - - DrawFPS(700, 15); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload all postpro shaders - for (int i = 0; i < MAX_POSTPRO_SHADERS; i++) UnloadShader(shaders[i]); - - UnloadTexture(texture); // Unload texture - UnloadModel(model); // Unload model - UnloadRenderTexture(target); // Unload render texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shaders/shaders_raymarching.c b/examples/src/shaders/shaders_raymarching.c deleted file mode 100644 index 3409179..0000000 --- a/examples/src/shaders/shaders_raymarching.c +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Raymarching shapes generation -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2018 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - raymarching shapes"); - - Camera camera = { 0 }; - camera.position = (Vector3){ 2.5f, 2.5f, 3.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.7f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 65.0f; // Camera field-of-view Y - - SetCameraMode(camera, CAMERA_FREE); // Set camera mode - - // Load raymarching shader - // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/raymarching.fs", GLSL_VERSION)); - - // Get shader locations for required uniforms - int viewEyeLoc = GetShaderLocation(shader, "viewEye"); - int viewCenterLoc = GetShaderLocation(shader, "viewCenter"); - int viewUpLoc = GetShaderLocation(shader, "viewUp"); - int deltaTimeLoc = GetShaderLocation(shader, "deltaTime"); - int runTimeLoc = GetShaderLocation(shader, "runTime"); - int resolutionLoc = GetShaderLocation(shader, "resolution"); - - float resolution[2] = { screenWidth, screenHeight }; - SetShaderValue(shader, resolutionLoc, resolution, UNIFORM_VEC2); - - float runTime = 0.0f; - - 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(&camera); // Update camera - - float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z }; - float cameraTarget[3] = { camera.target.x, camera.target.y, camera.target.z }; - float cameraUp[3] = { camera.up.x, camera.up.y, camera.up.z }; - - float deltaTime = GetFrameTime(); - runTime += deltaTime; - - // Set shader required uniform values - SetShaderValue(shader, viewEyeLoc, cameraPos, UNIFORM_VEC3); - SetShaderValue(shader, viewCenterLoc, cameraTarget, UNIFORM_VEC3); - SetShaderValue(shader, viewUpLoc, cameraUp, UNIFORM_VEC3); - SetShaderValue(shader, deltaTimeLoc, &deltaTime, UNIFORM_FLOAT); - SetShaderValue(shader, runTimeLoc, &runTime, UNIFORM_FLOAT); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // We only draw a white full-screen rectangle, - // frame is generated in shader using raymarching - BeginShaderMode(shader); - DrawRectangle(0, 0, screenWidth, screenHeight, WHITE); - EndShaderMode(); - - DrawText("(c) Raymarching shader by Iñigo Quilez. MIT License.", screenWidth - 280, screenHeight - 20, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shaders/shaders_shapes_textures.c b/examples/src/shaders/shaders_shapes_textures.c deleted file mode 100644 index cf53bf9..0000000 --- a/examples/src/shaders/shaders_shapes_textures.c +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Apply a shader to some shape or texture -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders"); - - Texture2D fudesumi = LoadTexture("resources/fudesumi.png"); - - // Load shader to be used on some parts drawing - // NOTE 1: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version - // NOTE 2: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION)); - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Start drawing with default shader - - DrawText("USING DEFAULT SHADER", 20, 40, 10, RED); - - DrawCircle(80, 120, 35, DARKBLUE); - DrawCircleGradient(80, 220, 60, GREEN, SKYBLUE); - DrawCircleLines(80, 340, 80, DARKBLUE); - - - // Activate our custom shader to be applied on next shapes/textures drawings - BeginShaderMode(shader); - - DrawText("USING CUSTOM SHADER", 190, 40, 10, RED); - - DrawRectangle(250 - 60, 90, 120, 60, RED); - DrawRectangleGradientH(250 - 90, 170, 180, 130, MAROON, GOLD); - DrawRectangleLines(250 - 40, 320, 80, 60, ORANGE); - - // Activate our default shader for next drawings - EndShaderMode(); - - DrawText("USING DEFAULT SHADER", 370, 40, 10, RED); - - DrawTriangle((Vector2){430, 80}, - (Vector2){430 - 60, 150}, - (Vector2){430 + 60, 150}, VIOLET); - - DrawTriangleLines((Vector2){430, 160}, - (Vector2){430 - 20, 230}, - (Vector2){430 + 20, 230}, DARKBLUE); - - DrawPoly((Vector2){430, 320}, 6, 80, 0, BROWN); - - // Activate our custom shader to be applied on next shapes/textures drawings - BeginShaderMode(shader); - - DrawTexture(fudesumi, 500, -30, WHITE); // Using custom shader - - // Activate our default shader for next drawings - EndShaderMode(); - - DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadTexture(fudesumi); // Unload texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shaders/shaders_texture_drawing.c b/examples/src/shaders/shaders_texture_drawing.c deleted file mode 100644 index 697000b..0000000 --- a/examples/src/shaders/shaders_texture_drawing.c +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Texture drawing -* -* This example illustrates how to draw on a blank texture using a shader -* -* This example has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Michał Ciesielski and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Michał Ciesielski and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing"); - - Image imBlank = GenImageColor(1024, 1024, BLANK); - Texture2D texture = LoadTextureFromImage(imBlank); // Load blank texture to fill on shader - UnloadImage(imBlank); - - // NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/cubes_panning.fs", GLSL_VERSION)); - - float time = 0.0f; - int timeLoc = GetShaderLocation(shader, "uTime"); - SetShaderValue(shader, timeLoc, &time, UNIFORM_FLOAT); - - 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 - //---------------------------------------------------------------------------------- - time = GetTime(); - SetShaderValue(shader, timeLoc, &time, UNIFORM_FLOAT); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginShaderMode(shader); // Enable our custom shader for next shapes/textures drawings - DrawTexture(texture, 0, 0, WHITE); // Drawing BLANK texture, all magic happens on shader - EndShaderMode(); // Disable our custom shader, return to default shader - - DrawText("BACKGROUND is PAINTED and ANIMATED on SHADER!", 10, 10, 20, MAROON); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shaders/shaders_texture_waves.c b/examples/src/shaders/shaders_texture_waves.c deleted file mode 100644 index 07186d3..0000000 --- a/examples/src/shaders/shaders_texture_waves.c +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Texture Waves -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture waves"); - - // Load texture texture to apply shaders - Texture2D texture = LoadTexture("resources/space.png"); - - // Load shader and setup location points and values - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/wave.fs", GLSL_VERSION)); - - int secondsLoc = GetShaderLocation(shader, "secondes"); - int freqXLoc = GetShaderLocation(shader, "freqX"); - int freqYLoc = GetShaderLocation(shader, "freqY"); - int ampXLoc = GetShaderLocation(shader, "ampX"); - int ampYLoc = GetShaderLocation(shader, "ampY"); - int speedXLoc = GetShaderLocation(shader, "speedX"); - int speedYLoc = GetShaderLocation(shader, "speedY"); - - // Shader uniform values that can be updated at any time - float freqX = 25.0f; - float freqY = 25.0f; - float ampX = 5.0f; - float ampY = 5.0f; - float speedX = 8.0f; - float speedY = 8.0f; - - float screenSize[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() }; - SetShaderValue(shader, GetShaderLocation(shader, "size"), &screenSize, UNIFORM_VEC2); - SetShaderValue(shader, freqXLoc, &freqX, UNIFORM_FLOAT); - SetShaderValue(shader, freqYLoc, &freqY, UNIFORM_FLOAT); - SetShaderValue(shader, ampXLoc, &X, UNIFORM_FLOAT); - SetShaderValue(shader, ampYLoc, &Y, UNIFORM_FLOAT); - SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT); - SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT); - - float seconds = 0.0f; - - 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 - //---------------------------------------------------------------------------------- - seconds += GetFrameTime(); - - SetShaderValue(shader, secondsLoc, &seconds, UNIFORM_FLOAT); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - BeginShaderMode(shader); - - DrawTexture(texture, 0, 0, WHITE); - DrawTexture(texture, texture.width, 0, WHITE); - - EndShaderMode(); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadTexture(texture); // Unload texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shapes/shapes_basic_shapes.c b/examples/src/shapes/shapes_basic_shapes.c deleted file mode 100644 index f7a8d02..0000000 --- a/examples/src/shapes/shapes_basic_shapes.c +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...) -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing"); - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY); - - DrawCircle(screenWidth/4, 120, 35, DARKBLUE); - - DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED); - DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines - DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD); - - DrawTriangle((Vector2){screenWidth/4*3, 80}, - (Vector2){screenWidth/4*3 - 60, 150}, - (Vector2){screenWidth/4*3 + 60, 150}, VIOLET); - - DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN); - - DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE); - - // NOTE: We draw all LINES based shapes together to optimize internal drawing, - // this way, all LINES are rendered in a single draw pass - DrawLine(18, 42, screenWidth - 18, 42, BLACK); - DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE); - DrawTriangleLines((Vector2){screenWidth/4*3, 160}, - (Vector2){screenWidth/4*3 - 20, 230}, - (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE); - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_bouncing_ball.c b/examples/src/shapes/shapes_bouncing_ball.c deleted file mode 100644 index 9f01ff1..0000000 --- a/examples/src/shapes/shapes_bouncing_ball.c +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - bouncing ball -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2013 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //--------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball"); - - Vector2 ballPosition = { GetScreenWidth()/2, GetScreenHeight()/2 }; - Vector2 ballSpeed = { 5.0f, 4.0f }; - int ballRadius = 20; - - bool pause = 0; - int framesCounter = 0; - - 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 - //----------------------------------------------------- - if (IsKeyPressed(KEY_SPACE)) pause = !pause; - - if (!pause) - { - ballPosition.x += ballSpeed.x; - ballPosition.y += ballSpeed.y; - - // Check walls collision for bouncing - if ((ballPosition.x >= (GetScreenWidth() - ballRadius)) || (ballPosition.x <= ballRadius)) ballSpeed.x *= -1.0f; - if ((ballPosition.y >= (GetScreenHeight() - ballRadius)) || (ballPosition.y <= ballRadius)) ballSpeed.y *= -1.0f; - } - else framesCounter++; - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawCircleV(ballPosition, ballRadius, MAROON); - DrawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, GetScreenHeight() - 25, 20, LIGHTGRAY); - - // On pause, we draw a blinking message - if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", 350, 200, 30, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //----------------------------------------------------- - } - - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_collision_area.c b/examples/src/shapes/shapes_collision_area.c deleted file mode 100644 index 0deba0d..0000000 --- a/examples/src/shapes/shapes_collision_area.c +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - collision area -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" -#include <stdlib.h> // Required for abs() - -int main(void) -{ - // Initialization - //--------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area"); - - // Box A: Moving box - Rectangle boxA = { 10, GetScreenHeight()/2 - 50, 200, 100 }; - int boxASpeedX = 4; - - // Box B: Mouse moved box - Rectangle boxB = { GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60 }; - - Rectangle boxCollision = { 0 }; // Collision rectangle - - int screenUpperLimit = 40; // Top menu limits - - bool pause = false; // Movement pause - bool collision = false; // Collision detection - - 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 - //----------------------------------------------------- - // Move box if not paused - if (!pause) boxA.x += boxASpeedX; - - // Bounce box on x screen limits - if (((boxA.x + boxA.width) >= GetScreenWidth()) || (boxA.x <= 0)) boxASpeedX *= -1; - - // Update player-controlled-box (box02) - boxB.x = GetMouseX() - boxB.width/2; - boxB.y = GetMouseY() - boxB.height/2; - - // Make sure Box B does not go out of move area limits - if ((boxB.x + boxB.width) >= GetScreenWidth()) boxB.x = GetScreenWidth() - boxB.width; - else if (boxB.x <= 0) boxB.x = 0; - - if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height; - else if (boxB.y <= screenUpperLimit) boxB.y = screenUpperLimit; - - // Check boxes collision - collision = CheckCollisionRecs(boxA, boxB); - - // Get collision rectangle (only on collision) - if (collision) boxCollision = GetCollisionRec(boxA, boxB); - - // Pause Box A movement - if (IsKeyPressed(KEY_SPACE)) pause = !pause; - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangle(0, 0, screenWidth, screenUpperLimit, collision? RED : BLACK); - - DrawRectangleRec(boxA, GOLD); - DrawRectangleRec(boxB, BLUE); - - if (collision) - { - // Draw collision area - DrawRectangleRec(boxCollision, LIME); - - // Draw collision message - DrawText("COLLISION!", GetScreenWidth()/2 - MeasureText("COLLISION!", 20)/2, screenUpperLimit/2 - 10, 20, BLACK); - - // Draw collision area - DrawText(FormatText("Collision Area: %i", (int)boxCollision.width*(int)boxCollision.height), GetScreenWidth()/2 - 100, screenUpperLimit + 10, 20, BLACK); - } - - DrawFPS(10, 10); - - EndDrawing(); - //----------------------------------------------------- - } - - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_colors_palette.c b/examples/src/shapes/shapes_colors_palette.c deleted file mode 100644 index 7322f7e..0000000 --- a/examples/src/shapes/shapes_colors_palette.c +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - Colors palette -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_COLORS_COUNT 21 // Number of colors available - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - colors palette"); - - Color colors[MAX_COLORS_COUNT] = { - DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN, - GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW, - GREEN, SKYBLUE, PURPLE, BEIGE }; - - const char *colorNames[MAX_COLORS_COUNT] = { - "DARKGRAY", "MAROON", "ORANGE", "DARKGREEN", "DARKBLUE", "DARKPURPLE", - "DARKBROWN", "GRAY", "RED", "GOLD", "LIME", "BLUE", "VIOLET", "BROWN", - "LIGHTGRAY", "PINK", "YELLOW", "GREEN", "SKYBLUE", "PURPLE", "BEIGE" }; - - Rectangle colorsRecs[MAX_COLORS_COUNT] = { 0 }; // Rectangles array - - // Fills colorsRecs data (for every rectangle) - for (int i = 0; i < MAX_COLORS_COUNT; i++) - { - colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7); - colorsRecs[i].y = 80 + 100*(i/7) + 10*(i/7); - colorsRecs[i].width = 100; - colorsRecs[i].height = 100; - } - - int colorState[MAX_COLORS_COUNT] = { 0 }; // Color state: 0-DEFAULT, 1-MOUSE_HOVER - - Vector2 mousePoint; - - 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 - //---------------------------------------------------------------------------------- - mousePoint = GetMousePosition(); - - for (int i = 0; i < MAX_COLORS_COUNT; i++) - { - if (CheckCollisionPointRec(mousePoint, colorsRecs[i])) colorState[i] = 1; - else colorState[i] = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("raylib colors palette", 28, 42, 20, BLACK); - DrawText("press SPACE to see all colors", GetScreenWidth() - 180, GetScreenHeight() - 40, 10, GRAY); - - for (int i = 0; i < MAX_COLORS_COUNT; i++) // Draw all rectangles - { - DrawRectangleRec(colorsRecs[i], Fade(colors[i], colorState[i]? 0.6f : 1.0f)); - - if (IsKeyDown(KEY_SPACE) || colorState[i]) - { - DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + colorsRecs[i].height - 26, colorsRecs[i].width, 20, BLACK); - DrawRectangleLinesEx(colorsRecs[i], 6, Fade(BLACK, 0.3f)); - DrawText(colorNames[i], colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12, - colorsRecs[i].y + colorsRecs[i].height - 20, 10, colors[i]); - } - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_draw_circle_sector.c b/examples/src/shapes/shapes_draw_circle_sector.c deleted file mode 100644 index ae6de5f..0000000 --- a/examples/src/shapes/shapes_draw_circle_sector.c +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - draw circle sector (with gui options) -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include <raylib.h> - -#define RAYGUI_IMPLEMENTATION -#include "raygui.h" // Required for GUI controls - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector"); - - Vector2 center = {(GetScreenWidth() - 300)/2, GetScreenHeight()/2 }; - - float outerRadius = 180.f; - int startAngle = 0; - int endAngle = 180; - int segments = 0; - - 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 - //---------------------------------------------------------------------------------- - // NOTE: All variables update happens inside GUI control functions - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f)); - DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f)); - - DrawCircleSector(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3)); - DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6)); - - // Draw GUI controls - //------------------------------------------------------------------------------ - startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", startAngle, 0, 720, true ); - endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", endAngle, 0, 720, true); - - outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", outerRadius, 0, 200, true); - segments = GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", segments, 0, 100, true); - //------------------------------------------------------------------------------ - - DrawText(FormatText("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 600, 200, 10, (segments >= 4)? MAROON : DARKGRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_draw_rectangle_rounded.c b/examples/src/shapes/shapes_draw_rectangle_rounded.c deleted file mode 100644 index c183e88..0000000 --- a/examples/src/shapes/shapes_draw_rectangle_rounded.c +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - draw rectangle rounded (with gui options) -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include <raylib.h> - -#define RAYGUI_IMPLEMENTATION -#include "raygui.h" // Required for GUI controls - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw rectangle rounded"); - - float roundness = 0.2f; - int width = 200; - int height = 100; - int segments = 0; - int lineThick = 1; - - bool drawRect = false; - bool drawRoundedRect = true; - bool drawRoundedLines = false; - - 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 - //---------------------------------------------------------------------------------- - Rectangle rec = { (GetScreenWidth() - width - 250)/2, (GetScreenHeight() - height)/2, width, height }; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawLine(560, 0, 560, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f)); - DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f)); - - if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6)); - if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2)); - if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, segments, lineThick, Fade(MAROON, 0.4)); - - // Draw GUI controls - //------------------------------------------------------------------------------ - width = GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", width, 0, GetScreenWidth() - 300, true ); - height = GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", height, 0, GetScreenHeight() - 50, true); - roundness = GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", roundness, 0.0f, 1.0f, true); - lineThick = GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", lineThick, 0, 20, true); - segments = GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", segments, 0, 60, true); - - drawRoundedRect = GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", drawRoundedRect); - drawRoundedLines = GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", drawRoundedLines); - drawRect = GuiCheckBox((Rectangle){ 640, 380, 20, 20}, "DrawRect", drawRect); - //------------------------------------------------------------------------------ - - DrawText(FormatText("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 640, 280, 10, (segments >= 4)? MAROON : DARKGRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shapes/shapes_draw_ring.c b/examples/src/shapes/shapes_draw_ring.c deleted file mode 100644 index a90feab..0000000 --- a/examples/src/shapes/shapes_draw_ring.c +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - draw ring (with gui options) -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include <raylib.h> - -#define RAYGUI_IMPLEMENTATION -#include "raygui.h" // Required for GUI controls - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw ring"); - - Vector2 center = {(GetScreenWidth() - 300)/2, GetScreenHeight()/2 }; - - float innerRadius = 80.0f; - float outerRadius = 190.0f; - - int startAngle = 0; - int endAngle = 360; - int segments = 0; - - bool drawRing = true; - bool drawRingLines = false; - bool drawCircleLines = false; - - 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 - //---------------------------------------------------------------------------------- - // NOTE: All variables update happens inside GUI control functions - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f)); - DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f)); - - if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3)); - if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4)); - if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4)); - - // Draw GUI controls - //------------------------------------------------------------------------------ - startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20 }, "StartAngle", startAngle, -450, 450, true); - endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20 }, "EndAngle", endAngle, -450, 450, true); - - innerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", innerRadius, 0, 100, true); - outerRadius = GuiSliderBar((Rectangle){ 600, 170, 120, 20 }, "OuterRadius", outerRadius, 0, 200, true); - - segments = GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", segments, 0, 100, true); - - drawRing = GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", drawRing); - drawRingLines = GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", drawRingLines); - drawCircleLines = GuiCheckBox((Rectangle){ 600, 380, 20, 20 }, "Draw CircleLines", drawCircleLines); - //------------------------------------------------------------------------------ - - DrawText(FormatText("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 600, 270, 10, (segments >= 4)? MAROON : DARKGRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_easings_ball_anim.c b/examples/src/shapes/shapes_easings_ball_anim.c deleted file mode 100644 index 5bb2b4c..0000000 --- a/examples/src/shapes/shapes_easings_ball_anim.c +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - easings ball anim -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include "easings.h" // Required for easing functions - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings ball anim"); - - // Ball variable value to be animated with easings - int ballPositionX = -100; - int ballRadius = 20; - float ballAlpha = 0.0f; - - int state = 0; - int framesCounter = 0; - - 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 - //---------------------------------------------------------------------------------- - if (state == 0) // Move ball position X with easing - { - framesCounter++; - ballPositionX = EaseElasticOut(framesCounter, -100, screenWidth/2 + 100, 120); - - if (framesCounter >= 120) - { - framesCounter = 0; - state = 1; - } - } - else if (state == 1) // Increase ball radius with easing - { - framesCounter++; - ballRadius = EaseElasticIn(framesCounter, 20, 500, 200); - - if (framesCounter >= 200) - { - framesCounter = 0; - state = 2; - } - } - else if (state == 2) // Change ball alpha with easing (background color blending) - { - framesCounter++; - ballAlpha = EaseCubicOut(framesCounter, 0.0f, 1.0f, 200); - - if (framesCounter >= 200) - { - framesCounter = 0; - state = 3; - } - } - else if (state == 3) // Reset state to play again - { - if (IsKeyPressed(KEY_ENTER)) - { - // Reset required variables to play again - ballPositionX = -100; - ballRadius = 20; - ballAlpha = 0.0f; - state = 0; - } - } - - if (IsKeyPressed(KEY_R)) framesCounter = 0; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (state >= 2) DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); - DrawCircle(ballPositionX, 200, ballRadius, Fade(RED, 1.0f - ballAlpha)); - - if (state == 3) DrawText("PRESS [ENTER] TO PLAY AGAIN!", 240, 200, 20, BLACK); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_easings_box_anim.c b/examples/src/shapes/shapes_easings_box_anim.c deleted file mode 100644 index 6805d53..0000000 --- a/examples/src/shapes/shapes_easings_box_anim.c +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - easings box anim -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include "easings.h" // Required for easing functions - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings box anim"); - - // Box variables to be animated with easings - Rectangle rec = { GetScreenWidth()/2, -100, 100, 100 }; - float rotation = 0.0f; - float alpha = 1.0f; - - int state = 0; - int framesCounter = 0; - - 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 - //---------------------------------------------------------------------------------- - switch (state) - { - case 0: // Move box down to center of screen - { - framesCounter++; - - // NOTE: Remember that 3rd parameter of easing function refers to - // desired value variation, do not confuse it with expected final value! - rec.y = EaseElasticOut(framesCounter, -100, GetScreenHeight()/2 + 100, 120); - - if (framesCounter >= 120) - { - framesCounter = 0; - state = 1; - } - } break; - case 1: // Scale box to an horizontal bar - { - framesCounter++; - rec.height = EaseBounceOut(framesCounter, 100, -90, 120); - rec.width = EaseBounceOut(framesCounter, 100, GetScreenWidth(), 120); - - if (framesCounter >= 120) - { - framesCounter = 0; - state = 2; - } - } break; - case 2: // Rotate horizontal bar rectangle - { - framesCounter++; - rotation = EaseQuadOut(framesCounter, 0.0f, 270.0f, 240); - - if (framesCounter >= 240) - { - framesCounter = 0; - state = 3; - } - } break; - case 3: // Increase bar size to fill all screen - { - framesCounter++; - rec.height = EaseCircOut(framesCounter, 10, GetScreenWidth(), 120); - - if (framesCounter >= 120) - { - framesCounter = 0; - state = 4; - } - } break; - case 4: // Fade out animation - { - framesCounter++; - alpha = EaseSineOut(framesCounter, 1.0f, -1.0f, 160); - - if (framesCounter >= 160) - { - framesCounter = 0; - state = 5; - } - } break; - default: break; - } - - // Reset animation at any moment - if (IsKeyPressed(KEY_SPACE)) - { - rec = (Rectangle){ GetScreenWidth()/2, -100, 100, 100 }; - rotation = 0.0f; - alpha = 1.0f; - state = 0; - framesCounter = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectanglePro(rec, (Vector2){ rec.width/2, rec.height/2 }, rotation, Fade(BLACK, alpha)); - - DrawText("PRESS [SPACE] TO RESET BOX ANIMATION!", 10, GetScreenHeight() - 25, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_easings_rectangle_array.c b/examples/src/shapes/shapes_easings_rectangle_array.c deleted file mode 100644 index 9844af6..0000000 --- a/examples/src/shapes/shapes_easings_rectangle_array.c +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - easings rectangle array -* -* NOTE: This example requires 'easings.h' library, provided on raylib/src. Just copy -* the library to same directory as example or make sure it's available on include path. -* -* This example has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include "easings.h" // Required for easing functions - -#define RECS_WIDTH 50 -#define RECS_HEIGHT 50 - -#define MAX_RECS_X 800/RECS_WIDTH -#define MAX_RECS_Y 450/RECS_HEIGHT - -#define PLAY_TIME_IN_FRAMES 240 // At 60 fps = 4 seconds - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings rectangle array"); - - Rectangle recs[MAX_RECS_X*MAX_RECS_Y]; - - for (int y = 0; y < MAX_RECS_Y; y++) - { - for (int x = 0; x < MAX_RECS_X; x++) - { - recs[y*MAX_RECS_X + x].x = RECS_WIDTH/2 + RECS_WIDTH*x; - recs[y*MAX_RECS_X + x].y = RECS_HEIGHT/2 + RECS_HEIGHT*y; - recs[y*MAX_RECS_X + x].width = RECS_WIDTH; - recs[y*MAX_RECS_X + x].height = RECS_HEIGHT; - } - } - - float rotation = 0.0f; - int framesCounter = 0; - int state = 0; // Rectangles animation state: 0-Playing, 1-Finished - - 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 - //---------------------------------------------------------------------------------- - if (state == 0) - { - framesCounter++; - - for (int i = 0; i < MAX_RECS_X*MAX_RECS_Y; i++) - { - recs[i].height = EaseCircOut(framesCounter, RECS_HEIGHT, -RECS_HEIGHT, PLAY_TIME_IN_FRAMES); - recs[i].width = EaseCircOut(framesCounter, RECS_WIDTH, -RECS_WIDTH, PLAY_TIME_IN_FRAMES); - - if (recs[i].height < 0) recs[i].height = 0; - if (recs[i].width < 0) recs[i].width = 0; - - if ((recs[i].height == 0) && (recs[i].width == 0)) state = 1; // Finish playing - - rotation = EaseLinearIn(framesCounter, 0.0f, 360.0f, PLAY_TIME_IN_FRAMES); - } - } - else if ((state == 1) && IsKeyPressed(KEY_SPACE)) - { - // When animation has finished, press space to restart - framesCounter = 0; - - for (int i = 0; i < MAX_RECS_X*MAX_RECS_Y; i++) - { - recs[i].height = RECS_HEIGHT; - recs[i].width = RECS_WIDTH; - } - - state = 0; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (state == 0) - { - for (int i = 0; i < MAX_RECS_X*MAX_RECS_Y; i++) - { - DrawRectanglePro(recs[i], (Vector2){ recs[i].width/2, recs[i].height/2 }, rotation, RED); - } - } - else if (state == 1) DrawText("PRESS [SPACE] TO PLAY AGAIN!", 240, 200, 20, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_following_eyes.c b/examples/src/shapes/shapes_following_eyes.c deleted file mode 100644 index a36a8d6..0000000 --- a/examples/src/shapes/shapes_following_eyes.c +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - following eyes -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2013-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <math.h> // Required for: atan2f() - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - following eyes"); - - Vector2 scleraLeftPosition = { GetScreenWidth()/2 - 100, GetScreenHeight()/2 }; - Vector2 scleraRightPosition = { GetScreenWidth()/2 + 100, GetScreenHeight()/2 }; - float scleraRadius = 80; - - Vector2 irisLeftPosition = { GetScreenWidth()/2 - 100, GetScreenHeight()/2 }; - Vector2 irisRightPosition = { GetScreenWidth()/2 + 100, GetScreenHeight()/2}; - float irisRadius = 24; - - float angle = 0.0f; - float dx = 0.0f, dy = 0.0f, dxx = 0.0f, dyy = 0.0f; - - 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 - //---------------------------------------------------------------------------------- - irisLeftPosition = GetMousePosition(); - irisRightPosition = GetMousePosition(); - - // Check not inside the left eye sclera - if (!CheckCollisionPointCircle(irisLeftPosition, scleraLeftPosition, scleraRadius - 20)) - { - dx = irisLeftPosition.x - scleraLeftPosition.x; - dy = irisLeftPosition.y - scleraLeftPosition.y; - - angle = atan2f(dy, dx); - - dxx = (scleraRadius - irisRadius)*cosf(angle); - dyy = (scleraRadius - irisRadius)*sinf(angle); - - irisLeftPosition.x = scleraLeftPosition.x + dxx; - irisLeftPosition.y = scleraLeftPosition.y + dyy; - } - - // Check not inside the right eye sclera - if (!CheckCollisionPointCircle(irisRightPosition, scleraRightPosition, scleraRadius - 20)) - { - dx = irisRightPosition.x - scleraRightPosition.x; - dy = irisRightPosition.y - scleraRightPosition.y; - - angle = atan2f(dy, dx); - - dxx = (scleraRadius - irisRadius)*cosf(angle); - dyy = (scleraRadius - irisRadius)*sinf(angle); - - irisRightPosition.x = scleraRightPosition.x + dxx; - irisRightPosition.y = scleraRightPosition.y + dyy; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawCircleV(scleraLeftPosition, scleraRadius, LIGHTGRAY); - DrawCircleV(irisLeftPosition, irisRadius, BROWN); - DrawCircleV(irisLeftPosition, 10, BLACK); - - DrawCircleV(scleraRightPosition, scleraRadius, LIGHTGRAY); - DrawCircleV(irisRightPosition, irisRadius, DARKGREEN); - DrawCircleV(irisRightPosition, 10, BLACK); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_lines_bezier.c b/examples/src/shapes/shapes_lines_bezier.c deleted file mode 100644 index 3d4edcd..0000000 --- a/examples/src/shapes/shapes_lines_bezier.c +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - Cubic-bezier lines -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines"); - - Vector2 start = { 0, 0 }; - Vector2 end = { screenWidth, screenHeight }; - - 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 - //---------------------------------------------------------------------------------- - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition(); - else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition(); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY); - - DrawLineBezier(start, end, 2.0f, RED); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/shapes/shapes_logo_raylib.c b/examples/src/shapes/shapes_logo_raylib.c deleted file mode 100644 index 3e2d343..0000000 --- a/examples/src/shapes/shapes_logo_raylib.c +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - Draw raylib logo using basic shapes -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes"); - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK); - DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE); - DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 48, 50, BLACK); - - DrawText("this is NOT a texture!", 350, 370, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_logo_raylib_anim.c b/examples/src/shapes/shapes_logo_raylib_anim.c deleted file mode 100644 index b855839..0000000 --- a/examples/src/shapes/shapes_logo_raylib_anim.c +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - raylib logo animation -* -* This example has been created using raylib 2.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation"); - - int logoPositionX = screenWidth/2 - 128; - int logoPositionY = screenHeight/2 - 128; - - int framesCounter = 0; - int lettersCount = 0; - - int topSideRecWidth = 16; - int leftSideRecHeight = 16; - - int bottomSideRecWidth = 16; - int rightSideRecHeight = 16; - - int state = 0; // Tracking animation states (State Machine) - float alpha = 1.0f; // Useful for fading - - 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 - //---------------------------------------------------------------------------------- - if (state == 0) // State 0: Small box blinking - { - framesCounter++; - - if (framesCounter == 120) - { - state = 1; - framesCounter = 0; // Reset counter... will be used later... - } - } - else if (state == 1) // State 1: Top and left bars growing - { - topSideRecWidth += 4; - leftSideRecHeight += 4; - - if (topSideRecWidth == 256) state = 2; - } - else if (state == 2) // State 2: Bottom and right bars growing - { - bottomSideRecWidth += 4; - rightSideRecHeight += 4; - - if (bottomSideRecWidth == 256) state = 3; - } - else if (state == 3) // State 3: Letters appearing (one by one) - { - framesCounter++; - - if (framesCounter/12) // Every 12 frames, one more letter! - { - lettersCount++; - framesCounter = 0; - } - - if (lettersCount >= 10) // When all letters have appeared, just fade out everything - { - alpha -= 0.02f; - - if (alpha <= 0.0f) - { - alpha = 0.0f; - state = 4; - } - } - } - else if (state == 4) // State 4: Reset and Replay - { - if (IsKeyPressed('R')) - { - framesCounter = 0; - lettersCount = 0; - - topSideRecWidth = 16; - leftSideRecHeight = 16; - - bottomSideRecWidth = 16; - rightSideRecHeight = 16; - - alpha = 1.0f; - state = 0; // Return to State 0 - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (state == 0) - { - if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK); - } - else if (state == 1) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - } - else if (state == 2) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK); - DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK); - - DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK); - } - else if (state == 3) - { - DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha)); - - DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha)); - DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha)); - - DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, Fade(RAYWHITE, alpha)); - - DrawText(TextSubtext("raylib", 0, lettersCount), screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha)); - } - else if (state == 4) - { - DrawText("[R] REPLAY", 340, 200, 20, GRAY); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/shapes/shapes_rectangle_scaling.c b/examples/src/shapes/shapes_rectangle_scaling.c deleted file mode 100644 index 6940cbc..0000000 --- a/examples/src/shapes/shapes_rectangle_scaling.c +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************************* -* -* raylib [shapes] example - rectangle scaling by mouse -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MOUSE_SCALE_MARK_SIZE 12 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [shapes] example - rectangle scaling mouse"); - - Rectangle rec = { 100, 100, 200, 80 }; - - Vector2 mousePosition = { 0 }; - - bool mouseScaleReady = false; - bool mouseScaleMode = false; - - 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 - //---------------------------------------------------------------------------------- - mousePosition = GetMousePosition(); - - if (CheckCollisionPointRec(mousePosition, rec) && - CheckCollisionPointRec(mousePosition, (Rectangle){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE })) - { - mouseScaleReady = true; - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) mouseScaleMode = true; - } - else mouseScaleReady = false; - - if (mouseScaleMode) - { - mouseScaleReady = true; - - rec.width = (mousePosition.x - rec.x); - rec.height = (mousePosition.y - rec.y); - - if (rec.width < MOUSE_SCALE_MARK_SIZE) rec.width = MOUSE_SCALE_MARK_SIZE; - if (rec.height < MOUSE_SCALE_MARK_SIZE) rec.height = MOUSE_SCALE_MARK_SIZE; - - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) mouseScaleMode = false; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, GRAY); - - DrawRectangleRec(rec, Fade(GREEN, 0.5f)); - - if (mouseScaleReady) - { - DrawRectangleLinesEx(rec, 1, RED); - DrawTriangle((Vector2){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height }, - (Vector2){ rec.x + rec.width, rec.y + rec.height }, - (Vector2){ rec.x + rec.width, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE }, RED); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/text/text_bmfont_ttf.c b/examples/src/text/text_bmfont_ttf.c deleted file mode 100644 index 175d3f1..0000000 --- a/examples/src/text/text_bmfont_ttf.c +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - BMFont and TTF Fonts loading -* -* This example has been created using raylib 1.4 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading"); - - // Define characters to draw - // NOTE: raylib supports UTF-8 encoding, following list is actually codified as UTF8 internally - const char msg[256] = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI\nJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmn\nopqrstuvwxyz{|}~¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ\nÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷\nøùúûüýþÿ"; - - // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) - - // BMFont (AngelCode) : Font data and image atlas have been generated using external program - Font fontBm = LoadFont("resources/pixantiqua.fnt"); - - // TTF font : Font data and atlas are generated directly from TTF - // NOTE: We define a font base size of 32 pixels tall and up-to 250 characters - Font fontTtf = LoadFontEx("resources/pixantiqua.ttf", 32, 0, 250); - - bool useTtf = false; - - 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 - //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_SPACE)) useTtf = true; - else useTtf = false; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Press SPACE to use TTF generated font", 20, 20, 20, LIGHTGRAY); - - if (!useTtf) - { - DrawTextEx(fontBm, msg, (Vector2){ 20.0f, 100.0f }, fontBm.baseSize, 2, MAROON); - DrawText("Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, GRAY); - } - else - { - DrawTextEx(fontTtf, msg, (Vector2){ 20.0f, 100.0f }, fontTtf.baseSize, 2, LIME); - DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, GRAY); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadFont(fontBm); // AngelCode Font unloading - UnloadFont(fontTtf); // TTF Font unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/text/text_font_sdf.c b/examples/src/text/text_font_sdf.c deleted file mode 100644 index d3c76c4..0000000 --- a/examples/src/text/text_font_sdf.c +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - TTF loading and usage -* -* This example has been created using raylib 1.3.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#if defined(PLATFORM_DESKTOP) - #define GLSL_VERSION 330 -#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB - #define GLSL_VERSION 100 -#endif - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - SDF fonts"); - - // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) - - const char msg[50] = "Signed Distance Fields"; - - // Default font generation from TTF font - Font fontDefault = { 0 }; - fontDefault.baseSize = 16; - fontDefault.charsCount = 95; - // Parameters > font size: 16, no chars array provided (0), chars count: 95 (autogenerate chars array) - fontDefault.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, 0, 95, FONT_DEFAULT); - // Parameters > chars count: 95, font size: 16, chars padding in image: 4 px, pack method: 0 (default) - Image atlas = GenImageFontAtlas(fontDefault.chars, 95, 16, 4, 0); - fontDefault.texture = LoadTextureFromImage(atlas); - UnloadImage(atlas); - - // SDF font generation from TTF font - Font fontSDF = { 0 }; - fontSDF.baseSize = 16; - fontSDF.charsCount = 95; - // Parameters > font size: 16, no chars array provided (0), chars count: 0 (defaults to 95) - fontSDF.chars = LoadFontData("resources/AnonymousPro-Bold.ttf", 16, 0, 0, FONT_SDF); - // Parameters > chars count: 95, font size: 16, chars padding in image: 0 px, pack method: 1 (Skyline algorythm) - atlas = GenImageFontAtlas(fontSDF.chars, 95, 16, 0, 1); - fontSDF.texture = LoadTextureFromImage(atlas); - UnloadImage(atlas); - - // Load SDF required shader (we use default vertex shader) - Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/sdf.fs", GLSL_VERSION)); - SetTextureFilter(fontSDF.texture, FILTER_BILINEAR); // Required for SDF font - - Vector2 fontPosition = { 40, screenHeight/2 - 50 }; - Vector2 textSize = { 0.0f }; - float fontSize = 16.0f; - int currentFont = 0; // 0 - fontDefault, 1 - fontSDF - - 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 - //---------------------------------------------------------------------------------- - fontSize += GetMouseWheelMove()*8.0f; - - if (fontSize < 6) fontSize = 6; - - if (IsKeyDown(KEY_SPACE)) currentFont = 1; - else currentFont = 0; - - if (currentFont == 0) textSize = MeasureTextEx(fontDefault, msg, fontSize, 0); - else textSize = MeasureTextEx(fontSDF, msg, fontSize, 0); - - fontPosition.x = GetScreenWidth()/2 - textSize.x/2; - fontPosition.y = GetScreenHeight()/2 - textSize.y/2 + 80; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (currentFont == 1) - { - // NOTE: SDF fonts require a custom SDf shader to compute fragment color - BeginShaderMode(shader); // Activate SDF font shader - DrawTextEx(fontSDF, msg, fontPosition, fontSize, 0, BLACK); - EndShaderMode(); // Activate our default shader for next drawings - - DrawTexture(fontSDF.texture, 10, 10, BLACK); - } - else - { - DrawTextEx(fontDefault, msg, fontPosition, fontSize, 0, BLACK); - DrawTexture(fontDefault.texture, 10, 10, BLACK); - } - - if (currentFont == 1) DrawText("SDF!", 320, 20, 80, RED); - else DrawText("default font", 315, 40, 30, GRAY); - - DrawText("FONT SIZE: 16.0", GetScreenWidth() - 240, 20, 20, DARKGRAY); - DrawText(FormatText("RENDER SIZE: %02.02f", fontSize), GetScreenWidth() - 240, 50, 20, DARKGRAY); - DrawText("Use MOUSE WHEEL to SCALE TEXT!", GetScreenWidth() - 240, 90, 10, DARKGRAY); - - DrawText("PRESS SPACE to USE SDF FONT VERSION!", 340, GetScreenHeight() - 30, 20, MAROON); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadFont(fontDefault); // Default font unloading - UnloadFont(fontSDF); // SDF font unloading - - UnloadShader(shader); // Unload SDF shader - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/text/text_format_text.c b/examples/src/text/text_format_text.c deleted file mode 100644 index a9f0417..0000000 --- a/examples/src/text/text_format_text.c +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - Text formatting -* -* This example has been created using raylib 1.1 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting"); - - int score = 100020; - int hiscore = 200450; - int lives = 5; - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText(FormatText("Score: %08i", score), 200, 80, 20, RED); - - DrawText(FormatText("HiScore: %08i", hiscore), 200, 120, 20, GREEN); - - DrawText(FormatText("Lives: %02i", lives), 200, 160, 40, BLUE); - - DrawText(FormatText("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 200, 220, 20, BLACK); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/text/text_input_box.c b/examples/src/text/text_input_box.c deleted file mode 100644 index ea3d299..0000000 --- a/examples/src/text/text_input_box.c +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - Input Box -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_INPUT_CHARS 9 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - input box"); - - char name[MAX_INPUT_CHARS + 1] = "\0"; // NOTE: One extra space required for line ending char '\0' - int letterCount = 0; - - Rectangle textBox = { screenWidth/2 - 100, 180, 225, 50 }; - bool mouseOnText = false; - - int framesCounter = 0; - - 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 - //---------------------------------------------------------------------------------- - if (CheckCollisionPointRec(GetMousePosition(), textBox)) mouseOnText = true; - else mouseOnText = false; - - if (mouseOnText) - { - int key = GetKeyPressed(); - - // NOTE: Only allow keys in range [32..125] - if ((key >= 32) && (key <= 125) && (letterCount < MAX_INPUT_CHARS)) - { - name[letterCount] = (char)key; - letterCount++; - } - - if (IsKeyPressed(KEY_BACKSPACE)) - { - letterCount--; - name[letterCount] = '\0'; - - if (letterCount < 0) letterCount = 0; - } - } - - if (mouseOnText) framesCounter++; - else framesCounter = 0; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("PLACE MOUSE OVER INPUT BOX!", 240, 140, 20, GRAY); - - DrawRectangleRec(textBox, LIGHTGRAY); - if (mouseOnText) DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, RED); - else DrawRectangleLines(textBox.x, textBox.y, textBox.width, textBox.height, DARKGRAY); - - DrawText(name, textBox.x + 5, textBox.y + 8, 40, MAROON); - - DrawText(FormatText("INPUT CHARS: %i/%i", letterCount, MAX_INPUT_CHARS), 315, 250, 20, DARKGRAY); - - if (mouseOnText) - { - if (letterCount < MAX_INPUT_CHARS) - { - // Draw blinking underscore char - if (((framesCounter/20)%2) == 0) DrawText("_", textBox.x + 8 + MeasureText(name, 40), textBox.y + 12, 40, MAROON); - } - else DrawText("Press BACKSPACE to delete chars...", 230, 300, 20, GRAY); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -// Check if any key is pressed -// NOTE: We limit keys check to keys between 32 (KEY_SPACE) and 126 -bool IsAnyKeyPressed() -{ - bool keyPressed = false; - int key = GetKeyPressed(); - - if ((key >= 32) && (key <= 126)) keyPressed = true; - - return keyPressed; -}
\ No newline at end of file diff --git a/examples/src/text/text_raylib_fonts.c b/examples/src/text/text_raylib_fonts.c deleted file mode 100644 index 06e6372..0000000 --- a/examples/src/text/text_raylib_fonts.c +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - raylib font loading and usage -* -* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!) -* To view details and credits for those fonts, check raylib license file -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_FONTS 8 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - Font fonts[MAX_FONTS]; - - fonts[0] = LoadFont("resources/fonts/alagard.png"); - fonts[1] = LoadFont("resources/fonts/pixelplay.png"); - fonts[2] = LoadFont("resources/fonts/mecha.png"); - fonts[3] = LoadFont("resources/fonts/setback.png"); - fonts[4] = LoadFont("resources/fonts/romulus.png"); - fonts[5] = LoadFont("resources/fonts/pixantiqua.png"); - fonts[6] = LoadFont("resources/fonts/alpha_beta.png"); - fonts[7] = LoadFont("resources/fonts/jupiter_crash.png"); - - const char *messages[MAX_FONTS] = { "ALAGARD FONT designed by Hewett Tsoi", - "PIXELPLAY FONT designed by Aleksander Shevchuk", - "MECHA FONT designed by Captain Falcon", - "SETBACK FONT designed by Brian Kent (AEnigma)", - "ROMULUS FONT designed by Hewett Tsoi", - "PIXANTIQUA FONT designed by Gerhard Grossmann", - "ALPHA_BETA FONT designed by Brian Kent (AEnigma)", - "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" }; - - const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 }; - - Vector2 positions[MAX_FONTS]; - - for (int i = 0; i < MAX_FONTS; i++) - { - positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2; - positions[i].y = 60 + fonts[i].baseSize + 45*i; - } - - // Small Y position corrections - positions[3].y += 8; - positions[4].y += 2; - positions[7].y -= 8; - - Color colors[MAX_FONTS] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY); - DrawLine(220, 50, 590, 50, DARKGRAY); - - for (int i = 0; i < MAX_FONTS; i++) - { - DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Fonts unloading - for (int i = 0; i < MAX_FONTS; i++) UnloadFont(fonts[i]); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/text/text_rectangle_bounds.c b/examples/src/text/text_rectangle_bounds.c deleted file mode 100644 index 5871278..0000000 --- a/examples/src/text/text_rectangle_bounds.c +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - Draw text inside a rectangle -* -* This example has been created using raylib 2.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - draw text inside a rectangle"); - - char text[] = "Text cannot escape\tthis container\t...word wrap also works when active so here's\ - a long text for testing.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\ - tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet risus nullam eget felis eget."; - - bool resizing = false; - bool wordWrap = true; - - Rectangle container = { 25, 25, screenWidth - 50, screenHeight - 250}; - Rectangle resizer = { container.x + container.width - 17, container.y + container.height - 17, 14, 14 }; - - // Minimum width and heigh for the container rectangle - const int minWidth = 60; - const int minHeight = 60; - const int maxWidth = screenWidth - 50; - const int maxHeight = screenHeight - 160; - - Vector2 lastMouse = { 0, 0 }; // Stores last mouse coordinates - Color borderColor = MAROON; // Container border color - Font font = GetFontDefault(); // Get default system font - - 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 - //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_SPACE)) wordWrap = !wordWrap; - - Vector2 mouse = GetMousePosition(); - - // Check if the mouse is inside the container and toggle border color - if (CheckCollisionPointRec(mouse, container)) borderColor = Fade(MAROON, 0.4f); - else if (!resizing) borderColor = MAROON; - - // Container resizing logic - if (resizing) - { - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) resizing = false; - - int width = container.width + (mouse.x - lastMouse.x); - container.width = (width > minWidth)? ((width < maxWidth)? width : maxWidth) : minWidth; - - int height = container.height + (mouse.y - lastMouse.y); - container.height = (height > minHeight)? ((height < maxHeight)? height : maxHeight) : minHeight; - } - else - { - // Check if we're resizing - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) && CheckCollisionPointRec(mouse, resizer)) resizing = true; - } - - // Move resizer rectangle properly - resizer.x = container.x + container.width - 17; - resizer.y = container.y + container.height - 17; - - lastMouse = mouse; // Update mouse - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawRectangleLinesEx(container, 3, borderColor); // Draw container border - - // Draw text in container (add some padding) - DrawTextRec(font, text, - (Rectangle){ container.x + 4, container.y + 4, container.width - 4, container.height - 4 }, - 20.0f, 2.0f, wordWrap, GRAY); - - DrawRectangleRec(resizer, borderColor); // Draw the resize box - - // Draw info - DrawText("Word Wrap: ", 313, screenHeight-115, 20, BLACK); - if (wordWrap) DrawText("ON", 447, screenHeight - 115, 20, RED); - else DrawText("OFF", 447, screenHeight - 115, 20, BLACK); - DrawText("Press [SPACE] to toggle word wrap", 218, screenHeight - 91, 20, GRAY); - - DrawRectangle(0, screenHeight - 54, screenWidth, 54, GRAY); - DrawText("Click hold & drag the to resize the container", 155, screenHeight - 38, 20, RAYWHITE); - DrawRectangleRec((Rectangle){ 382, screenHeight - 34, 12, 12 }, MAROON); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/text/text_sprite_fonts.c b/examples/src/text/text_sprite_fonts.c deleted file mode 100644 index 3002893..0000000 --- a/examples/src/text/text_sprite_fonts.c +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - Font loading and usage -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage"); - - const char msg1[50] = "THIS IS A custom SPRITE FONT..."; - const char msg2[50] = "...and this is ANOTHER CUSTOM font..."; - const char msg3[50] = "...and a THIRD one! GREAT! :D"; - - // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) - Font font1 = LoadFont("resources/custom_mecha.png"); // Font loading - Font font2 = LoadFont("resources/custom_alagard.png"); // Font loading - Font font3 = LoadFont("resources/custom_jupiter_crash.png"); // Font loading - - Vector2 fontPosition1, fontPosition2, fontPosition3; - - fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2; - fontPosition1.y = screenHeight/2 - font1.baseSize/2 - 80; - - fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2; - fontPosition2.y = screenHeight/2 - font2.baseSize/2 - 10; - - fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2; - fontPosition3.y = screenHeight/2 - font3.baseSize/2 + 50; - - 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 - //---------------------------------------------------------------------------------- - // TODO: Update variables here... - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTextEx(font1, msg1, fontPosition1, font1.baseSize, -3, WHITE); - DrawTextEx(font2, msg2, fontPosition2, font2.baseSize, -2, WHITE); - DrawTextEx(font3, msg3, fontPosition3, font3.baseSize, 2, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadFont(font1); // Font unloading - UnloadFont(font2); // Font unloading - UnloadFont(font3); // Font unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/text/text_ttf_loading.c b/examples/src/text/text_ttf_loading.c deleted file mode 100644 index cc59417..0000000 --- a/examples/src/text/text_ttf_loading.c +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - TTF loading and usage -* -* This example has been created using raylib 1.3.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading"); - - const char msg[50] = "TTF Font"; - - // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) - - // TTF Font loading with custom generation parameters - Font font = LoadFontEx("resources/KAISG.ttf", 96, 0, 0); - - // Generate mipmap levels to use trilinear filtering - // NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR - GenTextureMipmaps(&font.texture); - - float fontSize = font.baseSize; - Vector2 fontPosition = { 40, screenHeight/2 - 80 }; - Vector2 textSize; - - // Setup texture scaling filter - SetTextureFilter(font.texture, FILTER_POINT); - int currentFontFilter = 0; // FILTER_POINT - - 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 - //---------------------------------------------------------------------------------- - fontSize += GetMouseWheelMove()*4.0f; - - // Choose font texture filter method - if (IsKeyPressed(KEY_ONE)) - { - SetTextureFilter(font.texture, FILTER_POINT); - currentFontFilter = 0; - } - else if (IsKeyPressed(KEY_TWO)) - { - SetTextureFilter(font.texture, FILTER_BILINEAR); - currentFontFilter = 1; - } - else if (IsKeyPressed(KEY_THREE)) - { - // NOTE: Trilinear filter won't be noticed on 2D drawing - SetTextureFilter(font.texture, 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; - - // Load a dropped TTF file dynamically (at current fontSize) - if (IsFileDropped()) - { - int count = 0; - char **droppedFiles = GetDroppedFiles(&count); - - if (count == 1) // Only support one ttf file dropped - { - UnloadFont(font); - font = LoadFontEx(droppedFiles[0], fontSize, 0, 0); - ClearDroppedFiles(); - } - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Use mouse wheel to change font size", 20, 20, 10, GRAY); - DrawText("Use KEY_RIGHT and KEY_LEFT to move text", 20, 40, 10, GRAY); - DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY); - DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, DARKGRAY); - - DrawTextEx(font, msg, fontPosition, fontSize, 0, BLACK); - - // TODO: It seems texSize measurement is not accurate due to chars offsets... - //DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED); - - DrawRectangle(0, screenHeight - 80, screenWidth, 80, LIGHTGRAY); - DrawText(FormatText("Font size: %02.02f", fontSize), 20, screenHeight - 50, 10, DARKGRAY); - DrawText(FormatText("Text size: [%02.02f, %02.02f]", textSize.x, textSize.y), 20, screenHeight - 30, 10, DARKGRAY); - DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, GRAY); - - if (currentFontFilter == 0) DrawText("POINT", 570, 400, 20, BLACK); - else if (currentFontFilter == 1) DrawText("BILINEAR", 570, 400, 20, BLACK); - else if (currentFontFilter == 2) DrawText("TRILINEAR", 570, 400, 20, BLACK); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - ClearDroppedFiles(); // Clear internal buffers - - UnloadFont(font); // Font unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/text/text_unicode.c b/examples/src/text/text_unicode.c deleted file mode 100644 index 3525f01..0000000 --- a/examples/src/text/text_unicode.c +++ /dev/null @@ -1,320 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - Using unicode with raylib -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2019 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <stdio.h> -#include <string.h> - -#define SIZEOF(A) (sizeof(A)/sizeof(A[0])) -#define EMOJI_PER_WIDTH 8 -#define EMOJI_PER_HEIGHT 4 - -// String containing 180 emoji codepoints separated by a '\0' char -const char *const emojiCodepoints = "\xF0\x9F\x8C\x80\x00\xF0\x9F\x98\x80\x00\xF0\x9F\x98\x82\x00\xF0\x9F\xA4\xA3\x00\xF0\x9F\x98\x83\x00\xF0\x9F\x98\x86\x00\xF0\x9F\x98\x89\x00" - "\xF0\x9F\x98\x8B\x00\xF0\x9F\x98\x8E\x00\xF0\x9F\x98\x8D\x00\xF0\x9F\x98\x98\x00\xF0\x9F\x98\x97\x00\xF0\x9F\x98\x99\x00\xF0\x9F\x98\x9A\x00\xF0\x9F\x99\x82\x00" - "\xF0\x9F\xA4\x97\x00\xF0\x9F\xA4\xA9\x00\xF0\x9F\xA4\x94\x00\xF0\x9F\xA4\xA8\x00\xF0\x9F\x98\x90\x00\xF0\x9F\x98\x91\x00\xF0\x9F\x98\xB6\x00\xF0\x9F\x99\x84\x00" - "\xF0\x9F\x98\x8F\x00\xF0\x9F\x98\xA3\x00\xF0\x9F\x98\xA5\x00\xF0\x9F\x98\xAE\x00\xF0\x9F\xA4\x90\x00\xF0\x9F\x98\xAF\x00\xF0\x9F\x98\xAA\x00\xF0\x9F\x98\xAB\x00" - "\xF0\x9F\x98\xB4\x00\xF0\x9F\x98\x8C\x00\xF0\x9F\x98\x9B\x00\xF0\x9F\x98\x9D\x00\xF0\x9F\xA4\xA4\x00\xF0\x9F\x98\x92\x00\xF0\x9F\x98\x95\x00\xF0\x9F\x99\x83\x00" - "\xF0\x9F\xA4\x91\x00\xF0\x9F\x98\xB2\x00\xF0\x9F\x99\x81\x00\xF0\x9F\x98\x96\x00\xF0\x9F\x98\x9E\x00\xF0\x9F\x98\x9F\x00\xF0\x9F\x98\xA4\x00\xF0\x9F\x98\xA2\x00" - "\xF0\x9F\x98\xAD\x00\xF0\x9F\x98\xA6\x00\xF0\x9F\x98\xA9\x00\xF0\x9F\xA4\xAF\x00\xF0\x9F\x98\xAC\x00\xF0\x9F\x98\xB0\x00\xF0\x9F\x98\xB1\x00\xF0\x9F\x98\xB3\x00" - "\xF0\x9F\xA4\xAA\x00\xF0\x9F\x98\xB5\x00\xF0\x9F\x98\xA1\x00\xF0\x9F\x98\xA0\x00\xF0\x9F\xA4\xAC\x00\xF0\x9F\x98\xB7\x00\xF0\x9F\xA4\x92\x00\xF0\x9F\xA4\x95\x00" - "\xF0\x9F\xA4\xA2\x00\xF0\x9F\xA4\xAE\x00\xF0\x9F\xA4\xA7\x00\xF0\x9F\x98\x87\x00\xF0\x9F\xA4\xA0\x00\xF0\x9F\xA4\xAB\x00\xF0\x9F\xA4\xAD\x00\xF0\x9F\xA7\x90\x00" - "\xF0\x9F\xA4\x93\x00\xF0\x9F\x98\x88\x00\xF0\x9F\x91\xBF\x00\xF0\x9F\x91\xB9\x00\xF0\x9F\x91\xBA\x00\xF0\x9F\x92\x80\x00\xF0\x9F\x91\xBB\x00\xF0\x9F\x91\xBD\x00" - "\xF0\x9F\x91\xBE\x00\xF0\x9F\xA4\x96\x00\xF0\x9F\x92\xA9\x00\xF0\x9F\x98\xBA\x00\xF0\x9F\x98\xB8\x00\xF0\x9F\x98\xB9\x00\xF0\x9F\x98\xBB\x00\xF0\x9F\x98\xBD\x00" - "\xF0\x9F\x99\x80\x00\xF0\x9F\x98\xBF\x00\xF0\x9F\x8C\xBE\x00\xF0\x9F\x8C\xBF\x00\xF0\x9F\x8D\x80\x00\xF0\x9F\x8D\x83\x00\xF0\x9F\x8D\x87\x00\xF0\x9F\x8D\x93\x00" - "\xF0\x9F\xA5\x9D\x00\xF0\x9F\x8D\x85\x00\xF0\x9F\xA5\xA5\x00\xF0\x9F\xA5\x91\x00\xF0\x9F\x8D\x86\x00\xF0\x9F\xA5\x94\x00\xF0\x9F\xA5\x95\x00\xF0\x9F\x8C\xBD\x00" - "\xF0\x9F\x8C\xB6\x00\xF0\x9F\xA5\x92\x00\xF0\x9F\xA5\xA6\x00\xF0\x9F\x8D\x84\x00\xF0\x9F\xA5\x9C\x00\xF0\x9F\x8C\xB0\x00\xF0\x9F\x8D\x9E\x00\xF0\x9F\xA5\x90\x00" - "\xF0\x9F\xA5\x96\x00\xF0\x9F\xA5\xA8\x00\xF0\x9F\xA5\x9E\x00\xF0\x9F\xA7\x80\x00\xF0\x9F\x8D\x96\x00\xF0\x9F\x8D\x97\x00\xF0\x9F\xA5\xA9\x00\xF0\x9F\xA5\x93\x00" - "\xF0\x9F\x8D\x94\x00\xF0\x9F\x8D\x9F\x00\xF0\x9F\x8D\x95\x00\xF0\x9F\x8C\xAD\x00\xF0\x9F\xA5\xAA\x00\xF0\x9F\x8C\xAE\x00\xF0\x9F\x8C\xAF\x00\xF0\x9F\xA5\x99\x00" - "\xF0\x9F\xA5\x9A\x00\xF0\x9F\x8D\xB3\x00\xF0\x9F\xA5\x98\x00\xF0\x9F\x8D\xB2\x00\xF0\x9F\xA5\xA3\x00\xF0\x9F\xA5\x97\x00\xF0\x9F\x8D\xBF\x00\xF0\x9F\xA5\xAB\x00" - "\xF0\x9F\x8D\xB1\x00\xF0\x9F\x8D\x98\x00\xF0\x9F\x8D\x9D\x00\xF0\x9F\x8D\xA0\x00\xF0\x9F\x8D\xA2\x00\xF0\x9F\x8D\xA5\x00\xF0\x9F\x8D\xA1\x00\xF0\x9F\xA5\x9F\x00" - "\xF0\x9F\xA5\xA1\x00\xF0\x9F\x8D\xA6\x00\xF0\x9F\x8D\xAA\x00\xF0\x9F\x8E\x82\x00\xF0\x9F\x8D\xB0\x00\xF0\x9F\xA5\xA7\x00\xF0\x9F\x8D\xAB\x00\xF0\x9F\x8D\xAF\x00" - "\xF0\x9F\x8D\xBC\x00\xF0\x9F\xA5\x9B\x00\xF0\x9F\x8D\xB5\x00\xF0\x9F\x8D\xB6\x00\xF0\x9F\x8D\xBE\x00\xF0\x9F\x8D\xB7\x00\xF0\x9F\x8D\xBB\x00\xF0\x9F\xA5\x82\x00" - "\xF0\x9F\xA5\x83\x00\xF0\x9F\xA5\xA4\x00\xF0\x9F\xA5\xA2\x00\xF0\x9F\x91\x81\x00\xF0\x9F\x91\x85\x00\xF0\x9F\x91\x84\x00\xF0\x9F\x92\x8B\x00\xF0\x9F\x92\x98\x00" - "\xF0\x9F\x92\x93\x00\xF0\x9F\x92\x97\x00\xF0\x9F\x92\x99\x00\xF0\x9F\x92\x9B\x00\xF0\x9F\xA7\xA1\x00\xF0\x9F\x92\x9C\x00\xF0\x9F\x96\xA4\x00\xF0\x9F\x92\x9D\x00" - "\xF0\x9F\x92\x9F\x00\xF0\x9F\x92\x8C\x00\xF0\x9F\x92\xA4\x00\xF0\x9F\x92\xA2\x00\xF0\x9F\x92\xA3\x00"; - -struct { - char *text; - char *language; -} const messages[] = { // Array containing all of the emojis messages - {"\x46\x61\x6C\x73\x63\x68\x65\x73\x20\xC3\x9C\x62\x65\x6E\x20\x76\x6F\x6E\x20\x58\x79\x6C\x6F\x70\x68\x6F\x6E\x6D\x75\x73\x69\x6B\x20\x71\x75\xC3\xA4\x6C" - "\x74\x20\x6A\x65\x64\x65\x6E\x20\x67\x72\xC3\xB6\xC3\x9F\x65\x72\x65\x6E\x20\x5A\x77\x65\x72\x67", "German"}, - {"\x42\x65\x69\xC3\x9F\x20\x6E\x69\x63\x68\x74\x20\x69\x6E\x20\x64\x69\x65\x20\x48\x61\x6E\x64\x2C\x20\x64\x69\x65\x20\x64\x69\x63\x68\x20\x66\xC3\xBC\x74" - "\x74\x65\x72\x74\x2E", "German"}, - {"\x41\x75\xC3\x9F\x65\x72\x6F\x72\x64\x65\x6E\x74\x6C\x69\x63\x68\x65\x20\xC3\x9C\x62\x65\x6C\x20\x65\x72\x66\x6F\x72\x64\x65\x72\x6E\x20\x61\x75\xC3\x9F" - "\x65\x72\x6F\x72\x64\x65\x6E\x74\x6C\x69\x63\x68\x65\x20\x4D\x69\x74\x74\x65\x6C\x2E", "German"}, - {"\xD4\xBF\xD6\x80\xD5\xB6\xD5\xA1\xD5\xB4\x20\xD5\xA1\xD5\xBA\xD5\xA1\xD5\xAF\xD5\xAB\x20\xD5\xB8\xD6\x82\xD5\xBF\xD5\xA5\xD5\xAC\x20\xD6\x87\x20\xD5\xAB" - "\xD5\xB6\xD5\xAE\xD5\xAB\x20\xD5\xA1\xD5\xB6\xD5\xB0\xD5\xA1\xD5\xB6\xD5\xA3\xD5\xAB\xD5\xBD\xD5\xBF\x20\xD5\xB9\xD5\xA8\xD5\xB6\xD5\xA5\xD6\x80", "Armenian"}, - {"\xD4\xB5\xD6\x80\xD5\xA2\x20\xD5\xB8\xD6\x80\x20\xD5\xAF\xD5\xA1\xD6\x81\xD5\xAB\xD5\xB6\xD5\xA8\x20\xD5\xA5\xD5\xAF\xD5\xA1\xD6\x82\x20\xD5\xA1\xD5\xB6\xD5" - "\xBF\xD5\xA1\xD5\xBC\x2C\x20\xD5\xAE\xD5\xA1\xD5\xBC\xD5\xA5\xD6\x80\xD5\xA8\x20\xD5\xA1\xD5\xBD\xD5\xA1\xD6\x81\xD5\xAB\xD5\xB6\x2E\x2E\x2E\x20\xC2\xAB\xD4\xBF" - "\xD5\xB8\xD5\xBF\xD5\xA8\x20\xD5\xB4\xD5\xA5\xD6\x80\xD5\xB8\xD5\xB6\xD6\x81\xD5\xAB\xD6\x81\x20\xD5\xA7\x3A\xC2\xBB", "Armenian"}, - {"\xD4\xB3\xD5\xA1\xD5\xBC\xD5\xA8\xD5\x9D\x20\xD5\xA3\xD5\xA1\xD6\x80\xD5\xB6\xD5\xA1\xD5\xB6\x2C\x20\xD5\xB1\xD5\xAB\xD6\x82\xD5\xB6\xD5\xA8\xD5\x9D\x20\xD5" - "\xB1\xD5\xB4\xD5\xBC\xD5\xA1\xD5\xB6", "Armenian"}, - {"\x4A\x65\xC5\xBC\x75\x20\x6B\x6C\xC4\x85\x74\x77\x2C\x20\x73\x70\xC5\x82\xC3\xB3\x64\xC5\xBA\x20\x46\x69\x6E\x6F\x6D\x20\x63\x7A\xC4\x99\xC5\x9B\xC4\x87" - "\x20\x67\x72\x79\x20\x68\x61\xC5\x84\x62\x21", "Polish"}, - {"\x44\x6F\x62\x72\x79\x6D\x69\x20\x63\x68\xC4\x99\x63\x69\x61\x6D\x69\x20\x6A\x65\x73\x74\x20\x70\x69\x65\x6B\xC5\x82\x6F\x20\x77\x79\x62\x72\x75\x6B\x6F" - "\x77\x61\x6E\x65\x2E", "Polish"}, - {"\xC3\x8E\xC8\x9B\x69\x20\x6D\x75\x6C\xC8\x9B\x75\x6D\x65\x73\x63\x20\x63\xC4\x83\x20\x61\x69\x20\x61\x6C\x65\x73\x20\x72\x61\x79\x6C\x69\x62\x2E\x0A\xC8\x98" - "\x69\x20\x73\x70\x65\x72\x20\x73\xC4\x83\x20\x61\x69\x20\x6F\x20\x7A\x69\x20\x62\x75\x6E\xC4\x83\x21", "Romanian"}, - {"\xD0\xAD\xD1\x85\x2C\x20\xD1\x87\xD1\x83\xD0\xB6\xD0\xB0\xD0\xBA\x2C\x20\xD0\xBE\xD0\xB1\xD1\x89\xD0\xB8\xD0\xB9\x20\xD1\x81\xD1\x8A\xD1\x91\xD0\xBC\x20" - "\xD1\x86\xD0\xB5\xD0\xBD\x20\xD1\x88\xD0\xBB\xD1\x8F\xD0\xBF\x20\x28\xD1\x8E\xD1\x84\xD1\x82\xD1\x8C\x29\x20\xD0\xB2\xD0\xB4\xD1\x80\xD1\x8B\xD0\xB7\xD0\xB3\x21", "Russian"}, - {"\xD0\xAF\x20\xD0\xBB\xD1\x8E\xD0\xB1\xD0\xBB\xD1\x8E\x20\x72\x61\x79\x6C\x69\x62\x21", "Russian"}, - {"\xD0\x9C\xD0\xBE\xD0\xBB\xD1\x87\xD0\xB8\x2C\x20\xD1\x81\xD0\xBA\xD1\x80\xD1\x8B\xD0\xB2\xD0\xB0\xD0\xB9\xD1\x81\xD1\x8F\x20\xD0\xB8\x20\xD1\x82\xD0\xB0\xD0\xB8" - "\x0A\xD0\x98\x20\xD1\x87\xD1\x83\xD0\xB2\xD1\x81\xD1\x82\xD0\xB2\xD0\xB0\x20\xD0\xB8\x20\xD0\xBC\xD0\xB5\xD1\x87\xD1\x82\xD1\x8B\x20\xD1\x81\xD0\xB2\xD0\xBE\xD0\xB8\x20" - "\xE2\x80\x93\x0A\xD0\x9F\xD1\x83\xD1\x81\xD0\xBA\xD0\xB0\xD0\xB9\x20\xD0\xB2\x20\xD0\xB4\xD1\x83\xD1\x88\xD0\xB5\xD0\xB2\xD0\xBD\xD0\xBE\xD0\xB9\x20\xD0\xB3\xD0\xBB\xD1" - "\x83\xD0\xB1\xD0\xB8\xD0\xBD\xD0\xB5\x0A\xD0\x98\x20\xD0\xB2\xD1\x81\xD1\x85\xD0\xBE\xD0\xB4\xD1\x8F\xD1\x82\x20\xD0\xB8\x20\xD0\xB7\xD0\xB0\xD0\xB9\xD0\xB4\xD1\x83\xD1" - "\x82\x20\xD0\xBE\xD0\xBD\xD0\xB5\x0A\xD0\x9A\xD0\xB0\xD0\xBA\x20\xD0\xB7\xD0\xB2\xD0\xB5\xD0\xB7\xD0\xB4\xD1\x8B\x20\xD1\x8F\xD1\x81\xD0\xBD\xD1\x8B\xD0\xB5\x20\xD0\xB2" - "\x20\xD0\xBD\xD0\xBE\xD1\x87\xD0\xB8\x2D\x0A\xD0\x9B\xD1\x8E\xD0\xB1\xD1\x83\xD0\xB9\xD1\x81\xD1\x8F\x20\xD0\xB8\xD0\xBC\xD0\xB8\x20\xE2\x80\x93\x20\xD0\xB8\x20\xD0\xBC" - "\xD0\xBE\xD0\xBB\xD1\x87\xD0\xB8\x2E", "Russian"}, - {"\x56\x6F\x69\x78\x20\x61\x6D\x62\x69\x67\x75\xC3\xAB\x20\x64\xE2\x80\x99\x75\x6E\x20\x63\xC5\x93\x75\x72\x20\x71\x75\x69\x20\x61\x75\x20\x7A\xC3\xA9\x70" - "\x68\x79\x72\x20\x70\x72\xC3\xA9\x66\xC3\xA8\x72\x65\x20\x6C\x65\x73\x20\x6A\x61\x74\x74\x65\x73\x20\x64\x65\x20\x6B\x69\x77\x69", "French"}, - {"\x42\x65\x6E\x6A\x61\x6D\xC3\xAD\x6E\x20\x70\x69\x64\x69\xC3\xB3\x20\x75\x6E\x61\x20\x62\x65\x62\x69\x64\x61\x20\x64\x65\x20\x6B\x69\x77\x69\x20\x79\x20" - "\x66\x72\x65\x73\x61\x3B\x20\x4E\x6F\xC3\xA9\x2C\x20\x73\x69\x6E\x20\x76\x65\x72\x67\xC3\xBC\x65\x6E\x7A\x61\x2C\x20\x6C\x61\x20\x6D\xC3\xA1\x73\x20\x65\x78" - "\x71\x75\x69\x73\x69\x74\x61\x20\x63\x68\x61\x6D\x70\x61\xC3\xB1\x61\x20\x64\x65\x6C\x20\x6D\x65\x6E\xC3\xBA\x2E", "Spanish"}, - {"\xCE\xA4\xCE\xB1\xCF\x87\xCE\xAF\xCF\x83\xCF\x84\xCE\xB7\x20\xCE\xB1\xCE\xBB\xCF\x8E\xCF\x80\xCE\xB7\xCE\xBE\x20\xCE\xB2\xCE\xB1\xCF\x86\xCE\xAE\xCF\x82\x20" - "\xCF\x88\xCE\xB7\xCE\xBC\xCE\xAD\xCE\xBD\xCE\xB7\x20\xCE\xB3\xCE\xB7\x2C\x20\xCE\xB4\xCF\x81\xCE\xB1\xCF\x83\xCE\xBA\xCE\xB5\xCE\xBB\xCE\xAF\xCE\xB6\xCE\xB5\xCE" - "\xB9\x20\xCF\x85\xCF\x80\xCE\xAD\xCF\x81\x20\xCE\xBD\xCF\x89\xCE\xB8\xCF\x81\xCE\xBF\xCF\x8D\x20\xCE\xBA\xCF\x85\xCE\xBD\xCF\x8C\xCF\x82", "Greek"}, - {"\xCE\x97\x20\xCE\xBA\xCE\xB1\xCE\xBB\xCF\x8D\xCF\x84\xCE\xB5\xCF\x81\xCE\xB7\x20\xCE\xAC\xCE\xBC\xCF\x85\xCE\xBD\xCE\xB1\x20\xCE\xB5\xCE\xAF\xCE\xBD" - "\xCE\xB1\xCE\xB9\x20\xCE\xB7\x20\xCE\xB5\xCF\x80\xCE\xAF\xCE\xB8\xCE\xB5\xCF\x83\xCE\xB7\x2E", "Greek"}, - {"\xCE\xA7\xCF\x81\xCF\x8C\xCE\xBD\xCE\xB9\xCE\xB1\x20\xCE\xBA\xCE\xB1\xCE\xB9\x20\xCE\xB6\xCE\xB1\xCE\xBC\xCE\xAC\xCE\xBD\xCE\xB9\xCE\xB1\x21", "Greek"}, - {"\xCE\xA0\xCF\x8E\xCF\x82\x20\xCF\x84\xCE\xB1\x20\xCF\x80\xCE\xB1\xCF\x82\x20\xCF\x83\xCE\xAE\xCE\xBC\xCE\xB5\xCF\x81\xCE\xB1\x3B", "Greek"}, - - {"\xE6\x88\x91\xE8\x83\xBD\xE5\x90\x9E\xE4\xB8\x8B\xE7\x8E\xBB\xE7\x92\x83\xE8\x80\x8C\xE4\xB8\x8D\xE4\xBC\xA4\xE8\xBA\xAB\xE4\xBD\x93\xE3\x80\x82", "Chinese"}, - {"\xE4\xBD\xA0\xE5\x90\x83\xE4\xBA\x86\xE5\x90\x97\xEF\xBC\x9F", "Chinese"}, - {"\xE4\xB8\x8D\xE4\xBD\x9C\xE4\xB8\x8D\xE6\xAD\xBB\xE3\x80\x82", "Chinese"}, - {"\xE6\x9C\x80\xE8\xBF\x91\xE5\xA5\xBD\xE5\x90\x97\xEF\xBC\x9F", "Chinese"}, - {"\xE5\xA1\x9E\xE7\xBF\x81\xE5\xA4\xB1\xE9\xA9\xAC\xEF\xBC\x8C\xE7\x84\x89\xE7\x9F\xA5\xE9\x9D\x9E\xE7\xA6\x8F\xE3\x80\x82", "Chinese"}, - {"\xE5\x8D\x83\xE5\x86\x9B\xE6\x98\x93\xE5\xBE\x97\x2C\x20\xE4\xB8\x80\xE5\xB0\x86\xE9\x9A\xBE\xE6\xB1\x82", "Chinese"}, - {"\xE4\xB8\x87\xE4\xBA\x8B\xE5\xBC\x80\xE5\xA4\xB4\xE9\x9A\xBE\xE3\x80\x82", "Chinese"}, - {"\xE9\xA3\x8E\xE6\x97\xA0\xE5\xB8\xB8\xE9\xA1\xBA\xEF\xBC\x8C\xE5\x85\xB5\xE6\x97\xA0\xE5\xB8\xB8\xE8\x83\x9C\xE3\x80\x82", "Chinese"}, - {"\xE6\xB4\xBB\xE5\x88\xB0\xE8\x80\x81\xEF\xBC\x8C\xE5\xAD\xA6\xE5\x88\xB0\xE8\x80\x81\xE3\x80\x82", "Chinese"}, - {"\xE4\xB8\x80\xE8\xA8\x80\xE6\x97\xA2\xE5\x87\xBA\xEF\xBC\x8C\xE9\xA9\xB7\xE9\xA9\xAC\xE9\x9A\xBE\xE8\xBF\xBD\xE3\x80\x82", "Chinese"}, - {"\xE8\xB7\xAF\xE9\x81\xA5\xE7\x9F\xA5\xE9\xA9\xAC\xE5\x8A\x9B\xEF\xBC\x8C\xE6\x97\xA5\xE4\xB9\x85\xE8\xA7\x81\xE4\xBA\xBA\xE5\xBF\x83", "Chinese"}, - {"\xE6\x9C\x89\xE7\x90\x86\xE8\xB5\xB0\xE9\x81\x8D\xE5\xA4\xA9\xE4\xB8\x8B\xEF\xBC\x8C\xE6\x97\xA0\xE7\x90\x86\xE5\xAF\xB8\xE6\xAD\xA5\xE9\x9A\xBE\xE8\xA1\x8C\xE3\x80\x82", "Chinese"}, - - {"\xE7\x8C\xBF\xE3\x82\x82\xE6\x9C\xA8\xE3\x81\x8B\xE3\x82\x89\xE8\x90\xBD\xE3\x81\xA1\xE3\x82\x8B", "Japanese"}, - {"\xE4\xBA\x80\xE3\x81\xAE\xE7\x94\xB2\xE3\x82\x88\xE3\x82\x8A\xE5\xB9\xB4\xE3\x81\xAE\xE5\x8A\x9F", "Japanese"}, - {"\xE3\x81\x86\xE3\x82\x89\xE3\x82\x84\xE3\x81\xBE\xE3\x81\x97\x20\x20\xE6\x80\x9D\xE3\x81\xB2\xE5\x88\x87\xE3\x82\x8B\xE6\x99\x82\x20\x20\xE7\x8C\xAB\xE3\x81\xAE\xE6\x81\x8B", "Japanese"}, - {"\xE8\x99\x8E\xE7\xA9\xB4\xE3\x81\xAB\xE5\x85\xA5\xE3\x82\x89\xE3\x81\x9A\xE3\x82\x93\xE3\x81\xB0\xE8\x99\x8E\xE5\xAD\x90\xE3\x82\x92\xE5\xBE\x97\xE3\x81\x9A\xE3\x80\x82", "Japanese"}, - {"\xE4\xBA\x8C\xE5\x85\x8E\xE3\x82\x92\xE8\xBF\xBD\xE3\x81\x86\xE8\x80\x85\xE3\x81\xAF\xE4\xB8\x80\xE5\x85\x8E\xE3\x82\x92\xE3\x82\x82\xE5\xBE\x97\xE3\x81\x9A\xE3\x80\x82", "Japanese"}, - {"\xE9\xA6\xAC\xE9\xB9\xBF\xE3\x81\xAF\xE6\xAD\xBB\xE3\x81\xAA\xE3\x81\xAA\xE3\x81\x8D\xE3\x82\x83\xE6\xB2\xBB\xE3\x82\x89\xE3\x81\xAA\xE3\x81\x84\xE3\x80\x82", "Japanese"}, - {"\xE6\x9E\xAF\xE9\x87\x8E\xE8\xB7\xAF\xE3\x81\xAB\xE3\x80\x80\xE5\xBD\xB1\xE3\x81\x8B\xE3\x81\x95\xE3\x81\xAA\xE3\x82\x8A\xE3\x81\xA6\xE3\x80\x80\xE3\x82\x8F\xE3\x81\x8B\xE3\x82\x8C\xE3\x81\x91\xE3\x82\x8A", "Japanese"}, - {"\xE7\xB9\xB0\xE3\x82\x8A\xE8\xBF\x94\xE3\x81\x97\xE9\xBA\xA6\xE3\x81\xAE\xE7\x95\x9D\xE7\xB8\xAB\xE3\x81\xB5\xE8\x83\xA1\xE8\x9D\xB6\xE5\x93\x89", "Japanese"}, - - {"\xEC\x95\x84\xEB\x93\x9D\xED\x95\x9C\x20\xEB\xB0\x94\xEB\x8B\xA4\x20\xEC\x9C\x84\xEC\x97\x90\x20\xEA\xB0\x88\xEB\xA7\xA4\xEA\xB8\xB0\x20\xEB\x91\x90\xEC\x97\x87\x20" - "\xEB\x82\xA0\xEC\x95\x84\x20\xEB\x8F\x88\xEB\x8B\xA4\x2E\x0A\xEB\x84\x88\xED\x9B\x8C\xEB\x84\x88\xED\x9B\x8C\x20\xEC\x8B\x9C\xEB\xA5\xBC\x20\xEC\x93\xB4\xEB\x8B\xA4\x2E" - "\x20\xEB\xAA\xA8\xEB\xA5\xB4\xEB\x8A\x94\x20\xEB\x82\x98\xEB\x9D\xBC\x20\xEA\xB8\x80\xEC\x9E\x90\xEB\x8B\xA4\x2E\x0A\xEB\x84\x90\xEB\x94\xB0\xEB\x9E\x80\x20\xED\x95\x98" - "\xEB\x8A\x98\x20\xEB\xB3\xB5\xED\x8C\x90\xEC\x97\x90\x20\xEB\x82\x98\xEB\x8F\x84\x20\xEA\xB0\x99\xEC\x9D\xB4\x20\xEC\x8B\x9C\xEB\xA5\xBC\x20\xEC\x93\xB4\xEB\x8B\xA4\x2E", "Korean"}, - {"\xEC\xA0\x9C\x20\xEB\x88\x88\xEC\x97\x90\x20\xEC\x95\x88\xEA\xB2\xBD\xEC\x9D\xB4\xEB\x8B\xA4", "Korean"}, - {"\xEA\xBF\xA9\x20\xEB\xA8\xB9\xEA\xB3\xA0\x20\xEC\x95\x8C\x20\xEB\xA8\xB9\xEB\x8A\x94\xEB\x8B\xA4", "Korean"}, - {"\xEB\xA1\x9C\xEB\xA7\x88\xEB\x8A\x94\x20\xED\x95\x98\xEB\xA3\xA8\xEC\x95\x84\xEC\xB9\xA8\xEC\x97\x90\x20\xEC\x9D\xB4\xEB\xA3\xA8\xEC\x96\xB4\xEC\xA7\x84\x20\xEA\xB2\x83\xEC\x9D\xB4" - "\x20\xEC\x95\x84\xEB\x8B\x88\xEB\x8B\xA4", "Korean"}, - {"\xEA\xB3\xA0\xEC\x83\x9D\x20\xEB\x81\x9D\xEC\x97\x90\x20\xEB\x82\x99\xEC\x9D\xB4\x20\xEC\x98\xA8\xEB\x8B\xA4", "Korean"}, - {"\xEA\xB0\x9C\xEC\xB2\x9C\xEC\x97\x90\xEC\x84\x9C\x20\xEC\x9A\xA9\x20\xEB\x82\x9C\xEB\x8B\xA4", "Korean"}, - {"\xEC\x95\x88\xEB\x85\x95\xED\x95\x98\xEC\x84\xB8\xEC\x9A\x94\x3F", "Korean"}, - {"\xEB\xA7\x8C\xEB\x82\x98\xEC\x84\x9C\x20\xEB\xB0\x98\xEA\xB0\x91\xEC\x8A\xB5\xEB\x8B\x88\xEB\x8B\xA4", "Korean"}, - {"\xED\x95\x9C\xEA\xB5\xAD\xEB\xA7\x90\x20\xED\x95\x98\xEC\x8B\xA4\x20\xEC\xA4\x84\x20\xEC\x95\x84\xEC\x84\xB8\xEC\x9A\x94\x3F", "Korean"}, -}; - -//-------------------------------------------------------------------------------------- -// Module functions declaration -//-------------------------------------------------------------------------------------- -static void RandomizeEmoji(void); // Fills the emoji array with random emojis - -//-------------------------------------------------------------------------------------- -// Global variables -//-------------------------------------------------------------------------------------- -// Arrays that holds the random emojis -struct { - int index; // Index inside `emojiCodepoints` - int message; // Message index - Color color; // Emoji color -} emoji[EMOJI_PER_WIDTH*EMOJI_PER_HEIGHT] = { 0 }; - -static int hovered = -1, selected = -1; - -int main(int argc, char **argv) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT); - InitWindow(screenWidth, screenHeight, "raylib [text] example - unicode"); - - // Load the font resources - // NOTE: fontAsian is for asian languages, - // fontEmoji is the emojis and fontDefault is used for everything else - Font fontDefault = LoadFont("resources/dejavu.fnt"); - Font fontAsian = LoadFont("resources/notoCJK.fnt"); - Font fontEmoji = LoadFont("resources/emoji.fnt"); - - Vector2 hoveredPos = { 0.0f, 0.0f }; - Vector2 selectedPos = { 0.0f, 0.0f }; - - // Set a random set of emojis when starting up - RandomizeEmoji(); - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // Add a new set of emojis when SPACE is pressed - if (IsKeyPressed(KEY_SPACE)) RandomizeEmoji(); - - // Set the selected emoji and copy its text to clipboard - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && (hovered != -1) && (hovered != selected)) - { - selected = hovered; - selectedPos = hoveredPos; - SetClipboardText(messages[emoji[selected].message].text); - } - - Vector2 mouse = GetMousePosition(); - Vector2 pos = { 28.8f, 10.0f }; - hovered = -1; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw random emojis in the background - //------------------------------------------------------------------------------ - for (int i = 0; i < SIZEOF(emoji); ++i) - { - const char *txt = &emojiCodepoints[emoji[i].index]; - Rectangle emojiRect = { pos.x, pos.y, fontEmoji.baseSize, fontEmoji.baseSize }; - - if (!CheckCollisionPointRec(mouse, emojiRect)) - { - DrawTextEx(fontEmoji, txt, pos, fontEmoji.baseSize, 1.0, selected == i ? emoji[i].color : Fade(LIGHTGRAY, 0.4f)); - } - else - { - DrawTextEx(fontEmoji, txt, pos, fontEmoji.baseSize, 1.0, emoji[i].color ); - hovered = i; - hoveredPos = pos; - } - - if ((i != 0) && (i%EMOJI_PER_WIDTH == 0)) { pos.y += fontEmoji.baseSize + 24.25f; pos.x = 28.8f; } - else pos.x += fontEmoji.baseSize + 28.8f; - } - //------------------------------------------------------------------------------ - - // Draw the message when a emoji is selected - //------------------------------------------------------------------------------ - if (selected != -1) - { - const int message = emoji[selected].message; - const int horizontalPadding = 20, verticalPadding = 30; - Font *font = &fontDefault; - - // Set correct font for asian languages - if (TextIsEqual(messages[message].language, "Chinese") || - TextIsEqual(messages[message].language, "Korean") || - TextIsEqual(messages[message].language, "Japanese")) font = &fontAsian; - - // Calculate size for the message box (approximate the height and width) - Vector2 sz = MeasureTextEx(*font, messages[message].text, font->baseSize, 1.0f); - if (sz.x > 300) { sz.y *= sz.x/300; sz.x = 300; } - else if (sz.x < 160) sz.x = 160; - - Rectangle msgRect = { selectedPos.x - 38.8f, selectedPos.y, 2 * horizontalPadding + sz.x, 2 * verticalPadding + sz.y }; - msgRect.y -= msgRect.height; - - // Coordinates for the chat bubble triangle - Vector2 a = { selectedPos.x, msgRect.y + msgRect.height }, b = {a.x + 8, a.y + 10}, c= { a.x + 10, a.y }; - - // Don't go outside the screen - if (msgRect.x < 10) msgRect.x += 28; - if (msgRect.y < 10) - { - msgRect.y = selectedPos.y + 84; - a.y = msgRect.y; - c.y = a.y; - b.y = a.y - 10; - - // Swap values so we can actually render the triangle :( - Vector2 tmp = a; - a = b; - b = tmp; - } - if (msgRect.x + msgRect.width > screenWidth) msgRect.x -= (msgRect.x + msgRect.width) - screenWidth + 10; - - // Draw chat bubble - DrawRectangleRec(msgRect, emoji[selected].color); - DrawTriangle(a, b, c, emoji[selected].color); - - // Draw the main text message - Rectangle textRect = { msgRect.x + horizontalPadding/2, msgRect.y + verticalPadding/2, msgRect.width - horizontalPadding, msgRect.height }; - DrawTextRec(*font, messages[message].text, textRect, font->baseSize, 1.0f, true, WHITE); - - // Draw the info text below the main message - int size = strlen(messages[message].text); - unsigned int len = TextCountCodepoints(messages[message].text); - const char *info = TextFormat("%s %u characters %i bytes", messages[message].language, len, size); - sz = MeasureTextEx(GetFontDefault(), info, 10, 1.0f); - Vector2 pos = { textRect.x + textRect.width - sz.x, msgRect.y + msgRect.height - sz.y - 2 }; - DrawText(info, pos.x, pos.y, 10, RAYWHITE); - } - //------------------------------------------------------------------------------ - - // Draw the info text - DrawText("These emojis have something to tell you, click each to find out!", (screenWidth - 650)/2, screenHeight - 40, 20, GRAY); - DrawText("Each emoji is a unicode character from a font, not a texture... Press [SPACEBAR] to refresh", (screenWidth - 484)/2, screenHeight - 16, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadFont(fontDefault); // Unload font resource - UnloadFont(fontAsian); // Unload font resource - UnloadFont(fontEmoji); // Unload font resource - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -// Fills the emoji array with random emoji (only those emojis present in fontEmoji) -static void RandomizeEmoji(void) -{ - hovered = selected = -1; - int start = GetRandomValue(45, 360); - - for (int i = 0; i < SIZEOF(emoji); ++i) - { - // 0-179 emoji codepoints (from emoji char array) each 4bytes + null char - emoji[i].index = GetRandomValue(0, 179)*5; - - // Generate a random color for this emoji - Vector3 hsv = {(start*(i + 1))%360, 0.6f, 0.85f}; - emoji[i].color = Fade(ColorFromHSV(hsv), 0.8f); - - // Set a random message for this emoji - emoji[i].message = GetRandomValue(0, SIZEOF(messages) - 1); - } -} diff --git a/examples/src/text/text_writing_anim.c b/examples/src/text/text_writing_anim.c deleted file mode 100644 index 2cf2eaa..0000000 --- a/examples/src/text/text_writing_anim.c +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - Text Writing Animation -* -* This example has been created using raylib 2.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim"); - - const char message[128] = "This sample illustrates a text writing\nanimation effect! Check it out! ;)"; - - int framesCounter = 0; - - 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 - //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_SPACE)) framesCounter += 8; - else framesCounter++; - - if (IsKeyPressed(KEY_ENTER)) framesCounter = 0; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText(TextSubtext(message, 0, framesCounter/10), 210, 160, 20, MAROON); - - DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, LIGHTGRAY); - DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, LIGHTGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_background_scrolling.c b/examples/src/textures/textures_background_scrolling.c deleted file mode 100644 index d91b258..0000000 --- a/examples/src/textures/textures_background_scrolling.c +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Background scrolling -* -* This example has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - background scrolling"); - - // NOTE: Be careful, background width must be equal or bigger than screen width - // if not, texture should be draw more than two times for scrolling effect - Texture2D background = LoadTexture("resources/cyberpunk_street_background.png"); - Texture2D midground = LoadTexture("resources/cyberpunk_street_midground.png"); - Texture2D foreground = LoadTexture("resources/cyberpunk_street_foreground.png"); - - float scrollingBack = 0; - float scrollingMid = 0; - float scrollingFore = 0; - - 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 - //---------------------------------------------------------------------------------- - scrollingBack -= 0.1f; - scrollingMid -= 0.5f; - scrollingFore -= 1.0f; - - // NOTE: Texture is scaled twice its size, so it sould be considered on scrolling - if (scrollingBack <= -background.width*2) scrollingBack = 0; - if (scrollingMid <= -midground.width*2) scrollingMid = 0; - if (scrollingFore <= -foreground.width*2) scrollingFore = 0; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(GetColor(0x052c46ff)); - - // Draw background image twice - // NOTE: Texture is scaled twice its size - DrawTextureEx(background, (Vector2){ scrollingBack, 20 }, 0.0f, 2.0f, WHITE); - DrawTextureEx(background, (Vector2){ background.width*2 + scrollingBack, 20 }, 0.0f, 2.0f, WHITE); - - // Draw midground image twice - DrawTextureEx(midground, (Vector2){ scrollingMid, 20 }, 0.0f, 2.0f, WHITE); - DrawTextureEx(midground, (Vector2){ midground.width*2 + scrollingMid, 20 }, 0.0f, 2.0f, WHITE); - - // Draw foreground image twice - DrawTextureEx(foreground, (Vector2){ scrollingFore, 70 }, 0.0f, 2.0f, WHITE); - DrawTextureEx(foreground, (Vector2){ foreground.width*2 + scrollingFore, 70 }, 0.0f, 2.0f, WHITE); - - DrawText("BACKGROUND SCROLLING & PARALLAX", 10, 10, 20, RED); - DrawText("(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", screenWidth - 330, screenHeight - 20, 10, RAYWHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(background); // Unload background texture - UnloadTexture(midground); // Unload midground texture - UnloadTexture(foreground); // Unload foreground texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_bunnymark.c b/examples/src/textures/textures_bunnymark.c deleted file mode 100644 index 6b91d64..0000000 --- a/examples/src/textures/textures_bunnymark.c +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Bunnymark -* -* This example has been created using raylib 1.6 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <stdlib.h> // Required for: malloc(), free() - -#define MAX_BUNNIES 100000 // 100K bunnies limit - -// This is the maximum amount of elements (quads) per batch -// NOTE: This value is defined in [rlgl] module and can be changed there -#define MAX_BATCH_ELEMENTS 8192 - -typedef struct Bunny { - Vector2 position; - Vector2 speed; - Color color; -} Bunny; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - bunnymark"); - - // Load bunny texture - Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png"); - - Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array - - int bunniesCount = 0; // Bunnies counter - - 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 - //---------------------------------------------------------------------------------- - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) - { - // Create more bunnies - for (int i = 0; i < 100; i++) - { - bunnies[bunniesCount].position = GetMousePosition(); - bunnies[bunniesCount].speed.x = (float)GetRandomValue(-250, 250)/60.0f; - bunnies[bunniesCount].speed.y = (float)GetRandomValue(-250, 250)/60.0f; - bunnies[bunniesCount].color = (Color){ GetRandomValue(50, 240), - GetRandomValue(80, 240), - GetRandomValue(100, 240), 255 }; - bunniesCount++; - } - } - - // Update bunnies - for (int i = 0; i < bunniesCount; i++) - { - bunnies[i].position.x += bunnies[i].speed.x; - bunnies[i].position.y += bunnies[i].speed.y; - - if (((bunnies[i].position.x + texBunny.width/2) > GetScreenWidth()) || - ((bunnies[i].position.x + texBunny.width/2) < 0)) bunnies[i].speed.x *= -1; - if (((bunnies[i].position.y + texBunny.height/2) > GetScreenHeight()) || - ((bunnies[i].position.y + texBunny.height/2 - 40) < 0)) bunnies[i].speed.y *= -1; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - for (int i = 0; i < bunniesCount; i++) - { - // NOTE: When internal batch buffer limit is reached (MAX_BATCH_ELEMENTS), - // a draw call is launched and buffer starts being filled again; - // before issuing a draw call, updated vertex data from internal CPU buffer is send to GPU... - // Process of sending data is costly and it could happen that GPU data has not been completely - // processed for drawing while new data is tried to be sent (updating current in-use buffers) - // it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies - DrawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, bunnies[i].color); - } - - DrawRectangle(0, 0, screenWidth, 40, BLACK); - DrawText(FormatText("bunnies: %i", bunniesCount), 120, 10, 20, GREEN); - DrawText(FormatText("batched draw calls: %i", 1 + bunniesCount/MAX_BATCH_ELEMENTS), 320, 10, 20, MAROON); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - free(bunnies); // Unload bunnies data array - - UnloadTexture(texBunny); // Unload bunny texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/textures/textures_image_drawing.c b/examples/src/textures/textures_image_drawing.c deleted file mode 100644 index f5c3c85..0000000 --- a/examples/src/textures/textures_image_drawing.c +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Image loading and drawing on it -* -* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) -* -* This example has been created using raylib 1.4 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - image drawing"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - - Image cat = LoadImage("resources/cat.png"); // Load image in CPU memory (RAM) - ImageCrop(&cat, (Rectangle){ 100, 10, 280, 380 }); // Crop an image piece - ImageFlipHorizontal(&cat); // Flip cropped image horizontally - ImageResize(&cat, 150, 200); // Resize flipped-cropped image - - Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM) - - // Draw one image over the other with a scaling of 1.5f - ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f }); - ImageCrop(&parrots, (Rectangle){ 0, 50, parrots.width, parrots.height - 100 }); // Crop resulting image - - UnloadImage(cat); // Unload image from RAM - - // Load custom font for frawing on image - Font font = LoadFont("resources/custom_jupiter_crash.png"); - - // Draw over image using custom font - ImageDrawTextEx(&parrots, (Vector2){ 300, 230 }, font, "PARROTS & CAT", font.baseSize, -2, WHITE); - - UnloadFont(font); // Unload custom spritefont (already drawn used on image) - - Texture2D texture = LoadTextureFromImage(parrots); // Image converted to texture, uploaded to GPU memory (VRAM) - UnloadImage(parrots); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM - - SetTargetFPS(60); - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, WHITE); - DrawRectangleLines(screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, texture.width, texture.height, DARKGRAY); - - DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, DARKGRAY); - DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_image_generation.c b/examples/src/textures/textures_image_generation.c deleted file mode 100644 index d9a39a2..0000000 --- a/examples/src/textures/textures_image_generation.c +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Procedural images generation -* -* 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) 2O17 Wilhem Barbier (@nounoursheureux) -* -********************************************************************************************/ - -#include "raylib.h" - -#define NUM_TEXTURES 7 // Currently we have 7 generation algorithms - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - procedural images generation"); - - Image verticalGradient = GenImageGradientV(screenWidth, screenHeight, RED, BLUE); - Image horizontalGradient = GenImageGradientH(screenWidth, screenHeight, RED, BLUE); - Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, WHITE, BLACK); - Image checked = GenImageChecked(screenWidth, screenHeight, 32, 32, RED, BLUE); - Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f); - Image perlinNoise = GenImagePerlinNoise(screenWidth, screenHeight, 50, 50, 4.0f); - Image cellular = GenImageCellular(screenWidth, screenHeight, 32); - - Texture2D textures[NUM_TEXTURES]; - textures[0] = LoadTextureFromImage(verticalGradient); - textures[1] = LoadTextureFromImage(horizontalGradient); - textures[2] = LoadTextureFromImage(radialGradient); - textures[3] = LoadTextureFromImage(checked); - textures[4] = LoadTextureFromImage(whiteNoise); - textures[5] = LoadTextureFromImage(perlinNoise); - textures[6] = LoadTextureFromImage(cellular); - - // Unload image data (CPU RAM) - UnloadImage(verticalGradient); - UnloadImage(horizontalGradient); - UnloadImage(radialGradient); - UnloadImage(checked); - UnloadImage(whiteNoise); - UnloadImage(perlinNoise); - UnloadImage(cellular); - - int currentTexture = 0; - - SetTargetFPS(60); - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) - { - // Update - //---------------------------------------------------------------------------------- - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_RIGHT)) - { - currentTexture = (currentTexture + 1)%NUM_TEXTURES; // Cycle between the textures - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTexture(textures[currentTexture], 0, 0, WHITE); - - DrawRectangle(30, 400, 325, 30, Fade(SKYBLUE, 0.5f)); - DrawRectangleLines(30, 400, 325, 30, Fade(WHITE, 0.5f)); - DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL TEXTURES", 40, 410, 10, WHITE); - - switch(currentTexture) - { - case 0: DrawText("VERTICAL GRADIENT", 560, 10, 20, RAYWHITE); break; - case 1: DrawText("HORIZONTAL GRADIENT", 540, 10, 20, RAYWHITE); break; - case 2: DrawText("RADIAL GRADIENT", 580, 10, 20, LIGHTGRAY); break; - case 3: DrawText("CHECKED", 680, 10, 20, RAYWHITE); break; - case 4: DrawText("WHITE NOISE", 640, 10, 20, RED); break; - case 5: DrawText("PERLIN NOISE", 630, 10, 20, RAYWHITE); break; - case 6: DrawText("CELLULAR", 670, 10, 20, RAYWHITE); break; - default: break; - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // Unload textures data (GPU VRAM) - for (int i = 0; i < NUM_TEXTURES; i++) UnloadTexture(textures[i]); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/textures/textures_image_loading.c b/examples/src/textures/textures_image_loading.c deleted file mode 100644 index 265cab4..0000000 --- a/examples/src/textures/textures_image_loading.c +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Image loading and texture creation -* -* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - - Image image = LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM) - Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) - - UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); - - DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_image_processing.c b/examples/src/textures/textures_image_processing.c deleted file mode 100644 index b9ed51d..0000000 --- a/examples/src/textures/textures_image_processing.c +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Image processing -* -* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) -* -* This example has been created using raylib 1.4 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <stdlib.h> // Required for: free() - -#define NUM_PROCESSES 8 - -typedef enum { - NONE = 0, - COLOR_GRAYSCALE, - COLOR_TINT, - COLOR_INVERT, - COLOR_CONTRAST, - COLOR_BRIGHTNESS, - FLIP_VERTICAL, - FLIP_HORIZONTAL -} ImageProcess; - -static const char *processText[] = { - "NO PROCESSING", - "COLOR GRAYSCALE", - "COLOR TINT", - "COLOR INVERT", - "COLOR CONTRAST", - "COLOR BRIGHTNESS", - "FLIP VERTICAL", - "FLIP HORIZONTAL" -}; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - - Image image = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM) - ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update) <-- ISSUE - Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) - - int currentProcess = NONE; - bool textureReload = false; - - Rectangle selectRecs[NUM_PROCESSES]; - - for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40.0f, (float)(50 + 32*i), 150.0f, 30.0f }; - - SetTargetFPS(60); - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_DOWN)) - { - currentProcess++; - if (currentProcess > 7) currentProcess = 0; - textureReload = true; - } - else if (IsKeyPressed(KEY_UP)) - { - currentProcess--; - if (currentProcess < 0) currentProcess = 7; - textureReload = true; - } - - if (textureReload) - { - UnloadImage(image); // Unload current image data - image = LoadImage("resources/parrots.png"); // Re-load image data - - // NOTE: Image processing is a costly CPU process to be done every frame, - // If image processing is required in a frame-basis, it should be done - // with a texture and by shaders - switch (currentProcess) - { - case COLOR_GRAYSCALE: ImageColorGrayscale(&image); break; - case COLOR_TINT: ImageColorTint(&image, GREEN); break; - case COLOR_INVERT: ImageColorInvert(&image); break; - case COLOR_CONTRAST: ImageColorContrast(&image, -40); break; - case COLOR_BRIGHTNESS: ImageColorBrightness(&image, -80); break; - case FLIP_VERTICAL: ImageFlipVertical(&image); break; - case FLIP_HORIZONTAL: ImageFlipHorizontal(&image); break; - default: break; - } - - Color *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit) - UpdateTexture(texture, pixels); // Update texture with new image data - free(pixels); // Unload pixels data from RAM - - textureReload = false; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("IMAGE PROCESSING:", 40, 30, 10, DARKGRAY); - - // Draw rectangles - for (int i = 0; i < NUM_PROCESSES; i++) - { - DrawRectangleRec(selectRecs[i], (i == currentProcess) ? SKYBLUE : LIGHTGRAY); - DrawRectangleLines((int)selectRecs[i].x, (int) selectRecs[i].y, (int) selectRecs[i].width, (int) selectRecs[i].height, (i == currentProcess) ? BLUE : GRAY); - DrawText( processText[i], (int)( selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2), (int) selectRecs[i].y + 11, 10, (i == currentProcess) ? DARKBLUE : DARKGRAY); - } - - DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE); - DrawRectangleLines(screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, texture.width, texture.height, BLACK); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Unload texture from VRAM - UnloadImage(image); // Unload image from RAM - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_image_text.c b/examples/src/textures/textures_image_text.c deleted file mode 100644 index c8dfe45..0000000 --- a/examples/src/textures/textures_image_text.c +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************************* -* -* raylib [texture] example - Image text drawing using TTF generated spritefont -* -* 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) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing"); - - Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM) - - // TTF Font loading with custom generation parameters - Font font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0); - - // Draw over image using custom font - ImageDrawTextEx(&parrots, (Vector2){ 20.0f, 20.0f }, font, "[Parrots font drawing]", (float)font.baseSize, 0.0f, RED); - - Texture2D texture = LoadTextureFromImage(parrots); // Image converted to texture, uploaded to GPU memory (VRAM) - UnloadImage(parrots); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM - - Vector2 position = { (float)(screenWidth/2 - texture.width/2), (float)(screenHeight/2 - texture.height/2 - 20) }; - - bool showFont = false; - - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_SPACE)) showFont = true; - else showFont = false; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - if (!showFont) - { - // Draw texture with text already drawn inside - DrawTextureV(texture, position, WHITE); - - // Draw text directly using sprite font - DrawTextEx(font, "[Parrots font drawing]", (Vector2){ position.x + 20, - position.y + 20 + 280 }, (float)font.baseSize, 0.0f, WHITE); - } - else DrawTexture(font.texture, screenWidth/2 - font.texture.width/2, 50, BLACK); - - DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Texture unloading - - UnloadFont(font); // Unload custom spritefont - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_logo_raylib.c b/examples/src/textures/textures_logo_raylib.c deleted file mode 100644 index de8bb2a..0000000 --- a/examples/src/textures/textures_logo_raylib.c +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Texture loading and drawing -* -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); - - DrawText("this IS a texture!", 360, 370, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_npatch_drawing.c b/examples/src/textures/textures_npatch_drawing.c deleted file mode 100644 index 1c57e2e..0000000 --- a/examples/src/textures/textures_npatch_drawing.c +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - N-patch drawing -* -* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) -* -* This example has been created using raylib 2.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Example contributed by Jorge A. Gomes (@overdev) and reviewed by Ramon Santamaria (@raysan5) -* -* Copyright (c) 2018 Jorge A. Gomes (@overdev) and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - N-patch drawing"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - Texture2D nPatchTexture = LoadTexture("resources/ninepatch_button.png"); - - Vector2 mousePosition = { 0 }; - Vector2 origin = { 0.0f, 0.0f }; - - // Position and size of the n-patches - Rectangle dstRec1 = { 480.0f, 160.0f, 32.0f, 32.0f }; - Rectangle dstRec2 = { 160.0f, 160.0f, 32.0f, 32.0f }; - Rectangle dstRecH = { 160.0f, 93.0f, 32.0f, 32.0f }; - Rectangle dstRecV = { 92.0f, 160.0f, 32.0f, 32.0f }; - - // A 9-patch (NPT_9PATCH) changes its sizes in both axis - NPatchInfo ninePatchInfo1 = { (Rectangle){ 0.0f, 0.0f, 64.0f, 64.0f }, 12, 40, 12, 12, NPT_9PATCH }; - NPatchInfo ninePatchInfo2 = { (Rectangle){ 0.0f, 128.0f, 64.0f, 64.0f }, 16, 16, 16, 16, NPT_9PATCH }; - - // A horizontal 3-patch (NPT_3PATCH_HORIZONTAL) changes its sizes along the x axis only - NPatchInfo h3PatchInfo = { (Rectangle){ 0.0f, 64.0f, 64.0f, 64.0f }, 8, 8, 8, 8, NPT_3PATCH_HORIZONTAL }; - - // A vertical 3-patch (NPT_3PATCH_VERTICAL) changes its sizes along the y axis only - NPatchInfo v3PatchInfo = { (Rectangle){ 0.0f, 192.0f, 64.0f, 64.0f }, 6, 6, 6, 6, NPT_3PATCH_VERTICAL }; - - SetTargetFPS(60); - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - mousePosition = GetMousePosition(); - - // Resize the n-patches based on mouse position - dstRec1.width = mousePosition.x - dstRec1.x; - dstRec1.height = mousePosition.y - dstRec1.y; - dstRec2.width = mousePosition.x - dstRec2.x; - dstRec2.height = mousePosition.y - dstRec2.y; - dstRecH.width = mousePosition.x - dstRecH.x; - dstRecV.height = mousePosition.y - dstRecV.y; - - // Set a minimum width and/or height - if (dstRec1.width < 1.0f) dstRec1.width = 1.0f; - if (dstRec1.width > 300.0f) dstRec1.width = 300.0f; - if (dstRec1.height < 1.0f) dstRec1.height = 1.0f; - if (dstRec2.width < 1.0f) dstRec2.width = 1.0f; - if (dstRec2.width > 300.0f) dstRec2.width = 300.0f; - if (dstRec2.height < 1.0f) dstRec2.height = 1.0f; - if (dstRecH.width < 1.0f) dstRecH.width = 1.0f; - if (dstRecV.height < 1.0f) dstRecV.height = 1.0f; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw the n-patches - DrawTextureNPatch(nPatchTexture, ninePatchInfo2, dstRec2, origin, 0.0f, WHITE); - DrawTextureNPatch(nPatchTexture, ninePatchInfo1, dstRec1, origin, 0.0f, WHITE); - DrawTextureNPatch(nPatchTexture, h3PatchInfo, dstRecH, origin, 0.0f, WHITE); - DrawTextureNPatch(nPatchTexture, v3PatchInfo, dstRecV, origin, 0.0f, WHITE); - - // Draw the source texture - DrawRectangleLines(5, 88, 74, 266, BLUE); - DrawTexture(nPatchTexture, 10, 93, WHITE); - DrawText("TEXTURE", 15, 360, 10, DARKGRAY); - - DrawText("Move the mouse to stretch or shrink the n-patches", 10, 20, 20, DARKGRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(nPatchTexture); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} diff --git a/examples/src/textures/textures_particles_blending.c b/examples/src/textures/textures_particles_blending.c deleted file mode 100644 index 75287ea..0000000 --- a/examples/src/textures/textures_particles_blending.c +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************************* -* -* raylib example - particles blending -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_PARTICLES 200 - -// Particle structure with basic data -typedef struct { - Vector2 position; - Color color; - float alpha; - float size; - float rotation; - bool active; // NOTE: Use it to activate/deactive particle -} Particle; - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending"); - - // Particles pool, reuse them! - Particle mouseTail[MAX_PARTICLES]; - - // Initialize particles - for (int i = 0; i < MAX_PARTICLES; i++) - { - mouseTail[i].position = (Vector2){ 0, 0 }; - mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; - mouseTail[i].alpha = 1.0f; - mouseTail[i].size = (float)GetRandomValue(1, 30)/20.0f; - mouseTail[i].rotation = (float)GetRandomValue(0, 360); - mouseTail[i].active = false; - } - - float gravity = 3.0f; - - Texture2D smoke = LoadTexture("resources/smoke.png"); - - int blending = BLEND_ALPHA; - - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Activate one particle every frame and Update active particles - // NOTE: Particles initial position should be mouse position when activated - // NOTE: Particles fall down with gravity and rotation... and disappear after 2 seconds (alpha = 0) - // NOTE: When a particle disappears, active = false and it can be reused. - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!mouseTail[i].active) - { - mouseTail[i].active = true; - mouseTail[i].alpha = 1.0f; - mouseTail[i].position = GetMousePosition(); - i = MAX_PARTICLES; - } - } - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (mouseTail[i].active) - { - mouseTail[i].position.y += gravity; - mouseTail[i].alpha -= 0.01f; - - if (mouseTail[i].alpha <= 0.0f) mouseTail[i].active = false; - - mouseTail[i].rotation += 5.0f; - } - } - - if (IsKeyPressed(KEY_SPACE)) - { - if (blending == BLEND_ALPHA) blending = BLEND_ADDITIVE; - else blending = BLEND_ALPHA; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(DARKGRAY); - - BeginBlendMode(blending); - - // Draw active particles - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (mouseTail[i].active) DrawTexturePro(smoke, (Rectangle){ 0.0f, 0.0f, (float)smoke.width, (float)smoke.height }, - (Rectangle){ mouseTail[i].position.x, mouseTail[i].position.y, smoke.width*mouseTail[i].size, smoke.height*mouseTail[i].size }, - (Vector2){ (float)(smoke.width*mouseTail[i].size/2.0f), (float)(smoke.height*mouseTail[i].size/2.0f) }, mouseTail[i].rotation, - Fade(mouseTail[i].color, mouseTail[i].alpha)); - } - - EndBlendMode(); - - DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK); - - if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK); - else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(smoke); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_raw_data.c b/examples/src/textures/textures_raw_data.c deleted file mode 100644 index 17604bd..0000000 --- a/examples/src/textures/textures_raw_data.c +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Load textures from raw data -* -* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include <stdlib.h> // Required for: malloc() and free() - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture from raw data"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - - // Load RAW image data (512x512, 32bit RGBA, no file header) - Image fudesumiRaw = LoadImageRaw("resources/fudesumi.raw", 384, 512, UNCOMPRESSED_R8G8B8A8, 0); - Texture2D fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM) - UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data - - // Generate a checked texture by code (1024x1024 pixels) - int width = 960; - int height = 480; - - // Dynamic memory allocation to store pixels data (Color type) - Color *pixels = (Color *)malloc(width*height*sizeof(Color)); - - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x++) - { - if (((x/32+y/32)/1)%2 == 0) pixels[y*width + x] = ORANGE; - else pixels[y*width + x] = GOLD; - } - } - - // Load pixels data into an image structure and create texture - Image checkedIm = LoadImageEx(pixels, width, height); - Texture2D checked = LoadTextureFromImage(checkedIm); - UnloadImage(checkedIm); // Unload CPU (RAM) image data - - // Dynamic memory must be freed after using it - free(pixels); // Unload CPU (RAM) pixels data - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.5f)); - DrawTexture(fudesumi, 430, -30, WHITE); - - DrawText("CHECKED TEXTURE ", 84, 85, 30, BROWN); - DrawText("GENERATED by CODE", 72, 148, 30, BROWN); - DrawText("and RAW IMAGE LOADING", 46, 210, 30, BROWN); - - DrawText("(c) Fudesumi sprite by Eiden Marsal", 310, screenHeight - 20, 10, BROWN); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(fudesumi); // Texture unloading - UnloadTexture(checked); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_rectangle.c b/examples/src/textures/textures_rectangle.c deleted file mode 100644 index 8be647a..0000000 --- a/examples/src/textures/textures_rectangle.c +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Texture loading and drawing a part defined by a rectangle -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2014 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_FRAME_SPEED 15 -#define MIN_FRAME_SPEED 1 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading - - Vector2 position = { 350.0f, 280.0f }; - Rectangle frameRec = { 0.0f, 0.0f, (float)scarfy.width/6, (float)scarfy.height }; - int currentFrame = 0; - - int framesCounter = 0; - int framesSpeed = 8; // Number of spritesheet frames shown by second - - 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 - //---------------------------------------------------------------------------------- - framesCounter++; - - if (framesCounter >= (60/framesSpeed)) - { - framesCounter = 0; - currentFrame++; - - if (currentFrame > 5) currentFrame = 0; - - frameRec.x = (float)currentFrame*(float)scarfy.width/6; - } - - if (IsKeyPressed(KEY_RIGHT)) framesSpeed++; - else if (IsKeyPressed(KEY_LEFT)) framesSpeed--; - - if (framesSpeed > MAX_FRAME_SPEED) framesSpeed = MAX_FRAME_SPEED; - else if (framesSpeed < MIN_FRAME_SPEED) framesSpeed = MIN_FRAME_SPEED; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTexture(scarfy, 15, 40, WHITE); - DrawRectangleLines(15, 40, scarfy.width, scarfy.height, LIME); - DrawRectangleLines(15 + frameRec.x, 40 + frameRec.y, frameRec.width, frameRec.height, RED); - - DrawText("FRAME SPEED: ", 165, 210, 10, DARKGRAY); - DrawText(FormatText("%02i FPS", framesSpeed), 575, 210, 10, DARKGRAY); - DrawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, DARKGRAY); - - for (int i = 0; i < MAX_FRAME_SPEED; i++) - { - if (i < framesSpeed) DrawRectangle(250 + 21*i, 205, 20, 20, RED); - DrawRectangleLines(250 + 21*i, 205, 20, 20, MAROON); - } - - DrawTextureRec(scarfy, frameRec, position, WHITE); // Draw part of the texture - - DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(scarfy); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_sprite_button.c b/examples/src/textures/textures_sprite_button.c deleted file mode 100644 index a5b2d8d..0000000 --- a/examples/src/textures/textures_sprite_button.c +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - sprite button -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2019 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define NUM_FRAMES 3 // Number of frames (rectangles) for the button sprite texture - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - sprite button"); - - InitAudioDevice(); // Initialize audio device - - Sound fxButton = LoadSound("resources/buttonfx.wav"); // Load button sound - Texture2D button = LoadTexture("resources/button.png"); // Load button texture - - // Define frame rectangle for drawing - int frameHeight = button.height/NUM_FRAMES; - Rectangle sourceRec = { 0, 0, button.width, frameHeight }; - - // Define button bounds on screen - Rectangle btnBounds = { screenWidth/2 - button.width/2, screenHeight/2 - button.height/NUM_FRAMES/2, button.width, frameHeight }; - - int btnState = 0; // Button state: 0-NORMAL, 1-MOUSE_HOVER, 2-PRESSED - bool btnAction = false; // Button action should be activated - - Vector2 mousePoint = { 0.0f, 0.0f }; - - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - mousePoint = GetMousePosition(); - btnAction = false; - - // Check button state - if (CheckCollisionPointRec(mousePoint, btnBounds)) - { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) btnState = 2; - else btnState = 1; - - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) btnAction = true; - } - else btnState = 0; - - if (btnAction) - { - PlaySound(fxButton); - - // TODO: Any desired action - } - - // Calculate button frame rectangle to draw depending on button state - sourceRec.y = btnState*frameHeight; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTextureRec(button, sourceRec, (Vector2){ btnBounds.x, btnBounds.y }, WHITE); // Draw button frame - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(button); // Unload button texture - UnloadSound(fxButton); // Unload sound - - CloseAudioDevice(); // Close audio device - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_sprite_explosion.c b/examples/src/textures/textures_sprite_explosion.c deleted file mode 100644 index 58a8f6f..0000000 --- a/examples/src/textures/textures_sprite_explosion.c +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - sprite explosion -* -* This example has been created using raylib 2.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2019 Anata and Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define NUM_FRAMES 8 -#define NUM_LINES 6 - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - sprite explosion"); - - InitAudioDevice(); - - // Load explosion sound - Sound fxBoom = LoadSound("resources/boom.wav"); - - // Load explosion texture - Texture2D explosion = LoadTexture("resources/explosion.png"); - - // Init variables for animation - int frameWidth = explosion.width/NUM_FRAMES; // Sprite one frame rectangle width - int frameHeight = explosion.height/NUM_LINES; // Sprite one frame rectangle height - int currentFrame = 0; - int currentLine = 0; - - Rectangle frameRec = { 0, 0, frameWidth, frameHeight }; - Vector2 position = { 0, 0 }; - - bool active = false; - int framesCounter = 0; - - SetTargetFPS(120); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Check for mouse button pressed and activate explosion (if not active) - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && !active) - { - position = GetMousePosition(); - active = true; - - position.x -= frameWidth/2; - position.y -= frameHeight/2; - - PlaySound(fxBoom); - } - - // Compute explosion animation frames - if (active) - { - framesCounter++; - - if (framesCounter > 2) - { - currentFrame++; - - if (currentFrame >= NUM_FRAMES) - { - currentFrame = 0; - currentLine++; - - if (currentLine >= NUM_LINES) - { - currentLine = 0; - active = false; - } - } - - framesCounter = 0; - } - } - - frameRec.x = frameWidth*currentFrame; - frameRec.y = frameHeight*currentLine; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw explosion required frame rectangle - if (active) DrawTextureRec(explosion, frameRec, position, WHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(explosion); // Unload texture - UnloadSound(fxBoom); // Unload sound - - CloseAudioDevice(); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_srcrec_dstrec.c b/examples/src/textures/textures_srcrec_dstrec.c deleted file mode 100644 index e86b729..0000000 --- a/examples/src/textures/textures_srcrec_dstrec.c +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Texture source and destination rectangles -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - - Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading - - int frameWidth = scarfy.width/6; - int frameHeight = scarfy.height; - - // Source rectangle (part of the texture to use for drawing) - Rectangle sourceRec = { 0.0f, 0.0f, frameWidth, frameHeight }; - - // Destination rectangle (screen rectangle where drawing part of texture) - Rectangle destRec = { screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 }; - - // Origin of the texture (rotation/scale point), it's relative to destination rectangle size - Vector2 origin = { frameWidth, frameHeight }; - - int rotation = 0; - - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - rotation++; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // NOTE: Using DrawTexturePro() we can easily rotate and scale the part of the texture we draw - // sourceRec defines the part of the texture we use for drawing - // destRec defines the rectangle where our texture part will fit (scaling it to fit) - // origin defines the point of the texture used as reference for rotation and scaling - // rotation defines the texture rotation (using origin as rotation point) - DrawTexturePro(scarfy, sourceRec, destRec, origin, (float)rotation, WHITE); - - DrawLine((int)destRec.x, 0, (int)destRec.x, screenHeight, GRAY); - DrawLine(0, (int)destRec.y, screenWidth, (int)destRec.y, GRAY); - - DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(scarfy); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/examples/src/textures/textures_to_image.c b/examples/src/textures/textures_to_image.c deleted file mode 100644 index c0989ba..0000000 --- a/examples/src/textures/textures_to_image.c +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Retrieve image data from texture: GetTextureData() -* -* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) -* -* This example has been created using raylib 1.3 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture to image"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - - Image image = LoadImage("resources/raylib_logo.png"); // Load image data into CPU memory (RAM) - Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (RAM -> VRAM) - UnloadImage(image); // Unload image data from CPU memory (RAM) - - image = GetTextureData(texture); // Retrieve image data from GPU memory (VRAM -> RAM) - UnloadTexture(texture); // Unload texture from GPU memory (VRAM) - - texture = LoadTextureFromImage(image); // Recreate texture from retrieved image data (RAM -> VRAM) - UnloadImage(image); // Unload retrieved image data from CPU memory (RAM) - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); - - DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file |
