summaryrefslogtreecommitdiffhomepage
path: root/examples/src
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2017-07-24 19:45:46 +0200
committerraysan5 <[email protected]>2017-07-24 19:45:46 +0200
commit46ad8ae6eefc76a2e1f0ce88cdef2b919bb2d936 (patch)
treefae44589bea3de03639b0ce88d0adc29044ed062 /examples/src
downloadraylib.com-46ad8ae6eefc76a2e1f0ce88cdef2b919bb2d936.tar.gz
raylib.com-46ad8ae6eefc76a2e1f0ce88cdef2b919bb2d936.zip
Added webpage
Moved from @raysan5/raylib/docs
Diffstat (limited to 'examples/src')
-rw-r--r--examples/src/audio/audio_module_playing.c141
-rw-r--r--examples/src/audio/audio_music_stream.c93
-rw-r--r--examples/src/audio/audio_raw_stream.c114
-rw-r--r--examples/src/audio/audio_sound_loading.c67
-rw-r--r--examples/src/core/core_2d_camera.c139
-rw-r--r--examples/src/core/core_3d_camera_first_person.c92
-rw-r--r--examples/src/core/core_3d_camera_free.c82
-rw-r--r--examples/src/core/core_3d_mode.c72
-rw-r--r--examples/src/core/core_3d_picking.c104
-rw-r--r--examples/src/core/core_basic_window.c54
-rw-r--r--examples/src/core/core_color_select.c94
-rw-r--r--examples/src/core/core_drop_files.c76
-rw-r--r--examples/src/core/core_gestures_detection.c115
-rw-r--r--examples/src/core/core_input_gamepad.c194
-rw-r--r--examples/src/core/core_input_keys.c59
-rw-r--r--examples/src/core/core_input_mouse.c61
-rw-r--r--examples/src/core/core_mouse_wheel.c58
-rw-r--r--examples/src/core/core_random_values.c65
-rw-r--r--examples/src/core/core_storage_values.c85
-rw-r--r--examples/src/core/core_vr_simulator.c84
-rw-r--r--examples/src/core/core_world_screen.c74
-rw-r--r--examples/src/models/models_billboard.c70
-rw-r--r--examples/src/models/models_box_collisions.c121
-rw-r--r--examples/src/models/models_cubicmap.c85
-rw-r--r--examples/src/models/models_geometric_shapes.c75
-rw-r--r--examples/src/models/models_heightmap.c80
-rw-r--r--examples/src/models/models_mesh_picking.c195
-rw-r--r--examples/src/models/models_obj_loading.c75
-rw-r--r--examples/src/physac/physics_demo.c128
-rw-r--r--examples/src/physac/physics_friction.c143
-rw-r--r--examples/src/physac/physics_movement.c129
-rw-r--r--examples/src/physac/physics_restitution.c122
-rw-r--r--examples/src/physac/physics_shatter.c114
-rw-r--r--examples/src/shaders/shaders_custom_uniform.c121
-rw-r--r--examples/src/shaders/shaders_model_shader.c93
-rw-r--r--examples/src/shaders/shaders_postprocessing.c180
-rw-r--r--examples/src/shaders/shaders_shapes_textures.c109
-rw-r--r--examples/src/shapes/shapes_basic_shapes.c72
-rw-r--r--examples/src/shapes/shapes_colors_palette.c97
-rw-r--r--examples/src/shapes/shapes_lines_bezier.c59
-rw-r--r--examples/src/shapes/shapes_logo_raylib.c56
-rw-r--r--examples/src/shapes/shapes_logo_raylib_anim.c160
-rw-r--r--examples/src/text/text_bmfont_ttf.c68
-rw-r--r--examples/src/text/text_bmfont_unordered.c65
-rw-r--r--examples/src/text/text_format_text.c62
-rw-r--r--examples/src/text/text_input_box.c116
-rw-r--r--examples/src/text/text_raylib_fonts.c103
-rw-r--r--examples/src/text/text_sprite_fonts.c77
-rw-r--r--examples/src/text/text_ttf_loading.c130
-rw-r--r--examples/src/text/text_writing_anim.c62
-rw-r--r--examples/src/textures/textures_image_drawing.c78
-rw-r--r--examples/src/textures/textures_image_loading.c63
-rw-r--r--examples/src/textures/textures_image_processing.c154
-rw-r--r--examples/src/textures/textures_logo_raylib.c57
-rw-r--r--examples/src/textures/textures_particles_blending.c135
-rw-r--r--examples/src/textures/textures_raw_data.c95
-rw-r--r--examples/src/textures/textures_rectangle.c99
-rw-r--r--examples/src/textures/textures_srcrec_dstrec.c81
-rw-r--r--examples/src/textures/textures_to_image.c68
59 files changed, 5720 insertions, 0 deletions
diff --git a/examples/src/audio/audio_module_playing.c b/examples/src/audio/audio_module_playing.c
new file mode 100644
index 0000000..671a119
--- /dev/null
+++ b/examples/src/audio/audio_module_playing.c
@@ -0,0 +1,141 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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/mini1111.xm");
+
+ 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
new file mode 100644
index 0000000..f9fe23d
--- /dev/null
+++ b/examples/src/audio/audio_music_stream.c
@@ -0,0 +1,93 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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;
+ //----------------------------------------------------------------------------------
+
+ // 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
new file mode 100644
index 0000000..80c83e9
--- /dev/null
+++ b/examples/src/audio/audio_raw_stream.c
@@ -0,0 +1,114 @@
+/*******************************************************************************************
+*
+* 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 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#include <stdlib.h> // Required for: malloc(), free()
+#include <math.h> // Required for: sinf()
+
+#define MAX_SAMPLES 22050
+#define MAX_SAMPLES_PER_UPDATE 4096
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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);
+
+ // Generate samples data from sine wave
+ short *data = (short *)malloc(sizeof(short)*MAX_SAMPLES);
+
+ // TODO: Review data generation, it seems data is discontinued for loop,
+ // for that reason, there is a clip everytime audio stream is looped...
+ for (int i = 0; i < MAX_SAMPLES; i++)
+ {
+ data[i] = (short)(sinf(((2*PI*(float)i)/2)*DEG2RAD)*32000);
+ }
+
+ PlayAudioStream(stream); // Start processing stream buffer (no data loaded currently)
+
+ int totalSamples = MAX_SAMPLES;
+ int samplesLeft = totalSamples;
+
+ 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
+ //----------------------------------------------------------------------------------
+
+ // Refill audio stream if required
+ // NOTE: Every update we check if stream data has been already consumed and we update
+ // buffer with new data from the generated samples, we upload data at a rate (MAX_SAMPLES_PER_UPDATE),
+ // but notice that at some point we update < MAX_SAMPLES_PER_UPDATE data...
+ if (IsAudioBufferProcessed(stream))
+ {
+ int numSamples = 0;
+ if (samplesLeft >= MAX_SAMPLES_PER_UPDATE) numSamples = MAX_SAMPLES_PER_UPDATE;
+ else numSamples = samplesLeft;
+
+ UpdateAudioStream(stream, data + (totalSamples - samplesLeft), numSamples);
+
+ samplesLeft -= numSamples;
+
+ // Reset samples feeding (loop audio)
+ if (samplesLeft <= 0) samplesLeft = totalSamples;
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("SINE WAVE SHOULD BE PLAYING!", 240, 140, 20, LIGHTGRAY);
+
+ // NOTE: Draw a part of the sine wave (only screen width, proportional values)
+ for (int i = 0; i < GetScreenWidth(); i++)
+ {
+ position.x = i;
+ position.y = 250 + 50*data[i]/32000;
+
+ DrawPixelV(position, RED);
+ }
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ free(data); // Unload sine wave data
+
+ 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;
+} \ No newline at end of file
diff --git a/examples/src/audio/audio_sound_loading.c b/examples/src/audio/audio_sound_loading.c
new file mode 100644
index 0000000..00e5832
--- /dev/null
+++ b/examples/src/audio/audio_sound_loading.c
@@ -0,0 +1,67 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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);
+ //--------------------------------------------------------------------------------------
+
+ // 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
new file mode 100644
index 0000000..f2f219e
--- /dev/null
+++ b/examples/src/core/core_2d_camera.c
@@ -0,0 +1,139 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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;
+
+ camera.target = (Vector2){ player.x + 20, player.y + 20 };
+ camera.offset = (Vector2){ 0, 0 };
+ camera.rotation = 0.0f;
+ camera.zoom = 1.0f;
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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);
+
+ Begin2dMode(camera);
+
+ DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY);
+
+ for (int i = 0; i < MAX_BUILDINGS; i++) DrawRectangleRec(buildings[i], buildColors[i]);
+
+ DrawRectangleRec(player, RED);
+
+ DrawRectangle(camera.target.x, -500, 1, screenHeight*4, GREEN);
+ DrawRectangle(-500, camera.target.y, screenWidth*4, 1, GREEN);
+
+ End2dMode();
+
+ 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
new file mode 100644
index 0000000..3998af8
--- /dev/null
+++ b/examples/src/core/core_3d_camera_first_person.c
@@ -0,0 +1,92 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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 = {{ 4.0f, 2.0f, 4.0f }, { 0.0f, 1.8f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 60.0f };
+
+ // 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);
+
+ Begin3dMode(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);
+ }
+
+ End3dMode();
+
+ 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
new file mode 100644
index 0000000..d446e14
--- /dev/null
+++ b/examples/src/core/core_3d_camera_free.c
@@ -0,0 +1,82 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
+
+ // 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
+
+ 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);
+
+ Begin3dMode(camera);
+
+ DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
+ DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
+
+ DrawGrid(10, 1.0f);
+
+ End3dMode();
+
+ 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_mode.c b/examples/src/core/core_3d_mode.c
new file mode 100644
index 0000000..5f76165
--- /dev/null
+++ b/examples/src/core/core_3d_mode.c
@@ -0,0 +1,72 @@
+/*******************************************************************************************
+*
+* raylib [core] example - Initialize 3d 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
+
+ // Define the camera to look into our 3d world
+ Camera camera;
+ 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
+
+ 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);
+
+ Begin3dMode(camera);
+
+ DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
+ DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
+
+ DrawGrid(10, 1.0f);
+
+ End3dMode();
+
+ 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
new file mode 100644
index 0000000..bd5c334
--- /dev/null
+++ b/examples/src/core/core_3d_picking.c
@@ -0,0 +1,104 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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
+
+ Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
+ Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
+
+ Ray ray; // 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))
+ {
+ // NOTE: This function is NOT WORKING properly!
+ 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);
+
+ Begin3dMode(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);
+
+ End3dMode();
+
+ 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;
+} \ No newline at end of file
diff --git a/examples/src/core/core_basic_window.c b/examples/src/core/core_basic_window.c
new file mode 100644
index 0000000..1db38c9
--- /dev/null
+++ b/examples/src/core/core_basic_window.c
@@ -0,0 +1,54 @@
+/*******************************************************************************************
+*
+* raylib [core] example - Basic window
+*
+* Welcome to 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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_color_select.c b/examples/src/core/core_color_select.c
new file mode 100644
index 0000000..002a693
--- /dev/null
+++ b/examples/src/core/core_color_select.c
@@ -0,0 +1,94 @@
+/*******************************************************************************************
+*
+* raylib [core] example - Color selection by mouse (collision detection)
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - color selection (collision detection)");
+
+ Color colors[21] = { DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN,
+ GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW,
+ GREEN, SKYBLUE, PURPLE, BEIGE };
+
+ Rectangle colorsRecs[21]; // Rectangles array
+
+ // Fills colorsRecs data (for every rectangle)
+ for (int i = 0; i < 21; i++)
+ {
+ colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7);
+ colorsRecs[i].y = 60 + 100*(i/7) + 10*(i/7);
+ colorsRecs[i].width = 100;
+ colorsRecs[i].height = 100;
+ }
+
+ bool selected[21] = { false }; // Selected rectangles indicator
+
+ 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 < 21; i++) // Iterate along all the rectangles
+ {
+ if (CheckCollisionPointRec(mousePoint, colorsRecs[i]))
+ {
+ colors[i].a = 120;
+
+ if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) selected[i] = !selected[i];
+ }
+ else colors[i].a = 255;
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ for (int i = 0; i < 21; i++) // Draw all rectangles
+ {
+ DrawRectangleRec(colorsRecs[i], colors[i]);
+
+ // Draw four rectangles around selected rectangle
+ if (selected[i])
+ {
+ DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 100, 10, RAYWHITE); // Square top rectangle
+ DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 10, 100, RAYWHITE); // Square left rectangle
+ DrawRectangle(colorsRecs[i].x + 90, colorsRecs[i].y, 10, 100, RAYWHITE); // Square right rectangle
+ DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + 90, 100, 10, RAYWHITE); // Square bottom rectangle
+ }
+ }
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/src/core/core_drop_files.c b/examples/src/core/core_drop_files.c
new file mode 100644
index 0000000..5c1501b
--- /dev/null
+++ b/examples/src/core/core_drop_files.c
@@ -0,0 +1,76 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files");
+
+ int count = 0;
+ char **droppedFiles = { 0 };
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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_gestures_detection.c b/examples/src/core/core_gestures_detection.c
new file mode 100644
index 0000000..63a1e6b
--- /dev/null
+++ b/examples/src/core/core_gestures_detection.c
@@ -0,0 +1,115 @@
+/*******************************************************************************************
+*
+* raylib [core] example - 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection");
+
+ 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);
+ //--------------------------------------------------------------------------------------
+
+ // 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_gamepad.c b/examples/src/core/core_input_gamepad.c
new file mode 100644
index 0000000..64520a4
--- /dev/null
+++ b/examples/src/core/core_input_gamepad.c
@@ -0,0 +1,194 @@
+/*******************************************************************************************
+*
+* 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 1.6 (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"
+
+// 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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);
+ //--------------------------------------------------------------------------------------
+
+ // 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_XBOX_BUTTON_HOME)) DrawCircle(394, 89, 19, RED);
+
+ // Draw buttons: basic
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_START)) DrawCircle(436, 150, 9, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_SELECT)) DrawCircle(352, 150, 9, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_X)) DrawCircle(501, 151, 15, BLUE);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_A)) DrawCircle(536, 187, 15, LIME);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_B)) DrawCircle(572, 151, 15, MAROON);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_Y)) DrawCircle(536, 115, 15, GOLD);
+
+ // Draw buttons: d-pad
+ DrawRectangle(317, 202, 19, 71, BLACK);
+ DrawRectangle(293, 228, 69, 19, BLACK);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_UP)) DrawRectangle(317, 202, 19, 26, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_DOWN)) DrawRectangle(317, 202 + 45, 19, 26, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_LEFT)) DrawRectangle(292, 228, 25, 19, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_RIGHT)) DrawRectangle(292 + 44, 228, 26, 19, RED);
+
+ // Draw buttons: left-right back
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_LB)) DrawCircle(259, 61, 20, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_XBOX_BUTTON_RB)) DrawCircle(536, 61, 20, RED);
+
+ // Draw axis: left joystick
+ DrawCircle(259, 152, 39, BLACK);
+ DrawCircle(259, 152, 34, LIGHTGRAY);
+ DrawCircle(259 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_X)*20),
+ 152 - (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_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_XBOX_AXIS_RIGHT_X)*20),
+ 237 - (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RIGHT_Y)*20), 25, BLACK);
+
+ // Draw axis: left-right triggers
+ DrawRectangle(170, 30, 15, 70, GRAY);
+ DrawRectangle(604, 30, 15, 70, GRAY);
+ DrawRectangle(170, 30, 15, (((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LT))/2.0f)*70), RED);
+ DrawRectangle(604, 30, 15, (((1.0f + GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RT))/2.0f)*70), RED);
+
+ //DrawText(FormatText("Xbox axis LT: %02.02f", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LT)), 10, 40, 10, BLACK);
+ //DrawText(FormatText("Xbox axis RT: %02.02f", GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_RT)), 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_PS3_BUTTON_PS)) DrawCircle(396, 222, 13, RED);
+
+ // Draw buttons: basic
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_SELECT)) DrawRectangle(328, 170, 32, 13, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_START)) DrawTriangle((Vector2){ 436, 168 }, (Vector2){ 436, 185 }, (Vector2){ 464, 177 }, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_TRIANGLE)) DrawCircle(557, 144, 13, LIME);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_CIRCLE)) DrawCircle(586, 173, 13, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_CROSS)) DrawCircle(557, 203, 13, VIOLET);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_SQUARE)) DrawCircle(527, 173, 13, PINK);
+
+ // Draw buttons: d-pad
+ DrawRectangle(225, 132, 24, 84, BLACK);
+ DrawRectangle(195, 161, 84, 25, BLACK);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_UP)) DrawRectangle(225, 132, 24, 29, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_DOWN)) DrawRectangle(225, 132 + 54, 24, 30, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_LEFT)) DrawRectangle(195, 161, 30, 25, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_RIGHT)) DrawRectangle(195 + 54, 161, 30, 25, RED);
+
+ // Draw buttons: left-right back buttons
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_L1)) DrawCircle(239, 82, 20, RED);
+ if (IsGamepadButtonDown(GAMEPAD_PLAYER1, GAMEPAD_PS3_BUTTON_R1)) DrawCircle(557, 82, 20, RED);
+
+ // Draw axis: left joystick
+ DrawCircle(319, 255, 35, BLACK);
+ DrawCircle(319, 255, 31, LIGHTGRAY);
+ DrawCircle(319 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_LEFT_X)*20),
+ 255 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_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_PS3_AXIS_RIGHT_X)*20),
+ 255 + (GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_RIGHT_Y)*20), 25, BLACK);
+
+ // Draw axis: left-right triggers
+ DrawRectangle(169, 48, 15, 70, GRAY);
+ DrawRectangle(611, 48, 15, 70, GRAY);
+ DrawRectangle(169, 48, 15, (((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_L2))/2.0f)*70), RED);
+ DrawRectangle(611, 48, 15, (((1.0f - GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_PS3_AXIS_R2))/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_keys.c b/examples/src/core/core_input_keys.c
new file mode 100644
index 0000000..b230524
--- /dev/null
+++ b/examples/src/core/core_input_keys.c
@@ -0,0 +1,59 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
+
+ Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
+
+ SetTargetFPS(60); // Set target frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8f;
+ if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8f;
+ if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8f;
+ if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8f;
+ //----------------------------------------------------------------------------------
+
+ // 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
new file mode 100644
index 0000000..24d2dfc
--- /dev/null
+++ b/examples/src/core/core_input_mouse.c
@@ -0,0 +1,61 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
+
+ Vector2 ballPosition = { -100.0f, -100.0f };
+ Color ballColor = DARKBLUE;
+
+ SetTargetFPS(60);
+ //---------------------------------------------------------------------------------------
+
+ // 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_mouse_wheel.c b/examples/src/core/core_mouse_wheel.c
new file mode 100644
index 0000000..6a5252e
--- /dev/null
+++ b/examples/src/core/core_mouse_wheel.c
@@ -0,0 +1,58 @@
+/*******************************************************************************************
+*
+* raylib [core] examples - Mouse wheel
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel");
+
+ int boxPositionY = screenHeight/2 - 40;
+ int scrollSpeed = 4; // Scrolling speed in pixels
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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_random_values.c b/examples/src/core/core_random_values.c
new file mode 100644
index 0000000..06e550d
--- /dev/null
+++ b/examples/src/core/core_random_values.c
@@ -0,0 +1,65 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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
new file mode 100644
index 0000000..43f0882
--- /dev/null
+++ b/examples/src/core/core_storage_values.c
@@ -0,0 +1,85 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values");
+
+ int score = 0;
+ int hiscore = 0;
+
+ int framesCounter = 0;
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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
new file mode 100644
index 0000000..69e0f84
--- /dev/null
+++ b/examples/src/core/core_vr_simulator.c
@@ -0,0 +1,84 @@
+/*******************************************************************************************
+*
+* 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"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 1080;
+ int screenHeight = 600;
+
+ // NOTE: screenWidth/screenHeight should match VR device aspect ratio
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - vr simulator");
+
+ InitVrSimulator(HMD_OCULUS_RIFT_CV1); // Init VR simulator (Oculus Rift CV1 parameters)
+
+ // 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
+
+ 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();
+
+ Begin3dMode(camera);
+
+ DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
+ DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
+
+ DrawGrid(40, 1.0f);
+
+ End3dMode();
+
+ EndVrDrawing();
+
+ DrawFPS(10, 10);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ 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_world_screen.c b/examples/src/core/core_world_screen.c
new file mode 100644
index 0000000..f8c53c7
--- /dev/null
+++ b/examples/src/core/core_world_screen.c
@@ -0,0 +1,74 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
+
+ // Define the camera to look into our 3d world
+ Camera camera = {{ 10.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
+
+ 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);
+
+ Begin3dMode(camera);
+
+ DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
+ DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
+
+ DrawGrid(10, 1.0f);
+
+ End3dMode();
+
+ 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_billboard.c b/examples/src/models/models_billboard.c
new file mode 100644
index 0000000..bca9faf
--- /dev/null
+++ b/examples/src/models/models_billboard.c
@@ -0,0 +1,70 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");
+
+ // Define the camera to look into our 3d world
+ Camera camera = {{ 5.0f, 4.0f, 5.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
+
+ 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);
+
+ Begin3dMode(camera);
+
+ DrawBillboard(camera, bill, billPosition, 2.0f, WHITE);
+
+ DrawGrid(10, 1.0f); // Draw a grid
+
+ End3dMode();
+
+ 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
new file mode 100644
index 0000000..69cec41
--- /dev/null
+++ b/examples/src/models/models_box_collisions.c
@@ -0,0 +1,121 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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 };
+
+ 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);
+
+ Begin3dMode(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
+
+ End3dMode();
+
+ 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
new file mode 100644
index 0000000..0e61302
--- /dev/null
+++ b/examples/src/models/models_cubicmap.c
@@ -0,0 +1,85 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Cubicmap loading and drawing
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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 };
+
+ Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
+ Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
+ Model map = LoadCubicmap(image); // Load cubicmap model (generate model from image)
+
+ // NOTE: By default each cube is mapped to one part of texture atlas
+ Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
+ map.material.texDiffuse = 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);
+
+ Begin3dMode(camera);
+
+ DrawModel(map, mapPosition, 1.0f, WHITE);
+
+ End3dMode();
+
+ 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(map); // 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
new file mode 100644
index 0000000..a13a1f3
--- /dev/null
+++ b/examples/src/models/models_geometric_shapes.c
@@ -0,0 +1,75 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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 }, 45.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);
+
+ Begin3dMode(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
+
+ End3dMode();
+
+ 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
new file mode 100644
index 0000000..10069e0
--- /dev/null
+++ b/examples/src/models/models_heightmap.c
@@ -0,0 +1,80 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Heightmap loading and drawing
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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 };
+
+ Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
+ Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
+ Model map = LoadHeightmap(image, (Vector3){ 16, 8, 16 }); // Load heightmap model with defined size
+ map.material.texDiffuse = texture; // Set map diffuse texture
+ Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Set model position (depends on model scaling!)
+
+ 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);
+
+ Begin3dMode(camera);
+
+ // NOTE: Model is scaled to 1/4 of its original size (128x128 units)
+ DrawModel(map, mapPosition, 1.0f, RED);
+
+ DrawGrid(20, 1.0f);
+
+ End3dMode();
+
+ 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(map); // Unload model
+
+ 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
new file mode 100644
index 0000000..0b5247e
--- /dev/null
+++ b/examples/src/models/models_mesh_picking.c
@@ -0,0 +1,195 @@
+/*******************************************************************************************
+*
+* 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 3.40282347E+38F // Maximum value of a float, defined in <float.h>
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
+
+ // Define the camera to look into our 3d world
+ Camera camera;
+ camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 2.3f, 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
+
+ Ray ray; // Picking ray
+
+ Model tower = LoadModel("resources/tower.obj"); // Load OBJ model
+ Texture2D texture = LoadTexture("resources/tower.png"); // Load model texture
+ tower.material.texDiffuse = texture; // Set model diffuse texture
+
+ Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position
+ BoundingBox towerBBox = CalculateBoundingBox(tower.mesh);
+ 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;
+ 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 = VectorBarycenter(nearestHit.hitPosition, ta, tb, tc);
+ hitTriangle = true;
+ }
+ else hitTriangle = false;
+
+ RayHitInfo meshHitInfo;
+
+ // Check ray collision against bounding box first, before trying the full ray-mesh test
+ if (CheckCollisionRayBox(ray, towerBBox))
+ {
+ hitMeshBBox = true;
+
+ // Check ray collision against mesh
+ meshHitInfo = GetCollisionRayMesh(ray, &tower.mesh);
+
+ if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance))
+ {
+ nearestHit = meshHitInfo;
+ cursorColor = ORANGE;
+ hitObjectName = "Mesh";
+ }
+
+ } hitMeshBBox = false;
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ Begin3dMode(camera);
+
+ // Draw the tower
+ DrawModel(tower, towerPos, 1.0, 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.hitPosition, 0.3, 0.3, 0.3, cursorColor);
+ DrawCubeWires(nearestHit.hitPosition, 0.3, 0.3, 0.3, RED);
+
+ Vector3 normalEnd;
+ normalEnd.x = nearestHit.hitPosition.x + nearestHit.hitNormal.x;
+ normalEnd.y = nearestHit.hitPosition.y + nearestHit.hitNormal.y;
+ normalEnd.z = nearestHit.hitPosition.z + nearestHit.hitNormal.z;
+
+ DrawLine3D(nearestHit.hitPosition, normalEnd, RED);
+ }
+
+ DrawRay(ray, MAROON);
+
+ DrawGrid(100, 1.0f);
+
+ End3dMode();
+
+ // 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.hitPosition.x,
+ nearestHit.hitPosition.y,
+ nearestHit.hitPosition.z), 10, ypos + 15, 10, BLACK);
+
+ DrawText(FormatText("Hit Norm: %3.2f %3.2f %3.2f",
+ nearestHit.hitNormal.x,
+ nearestHit.hitNormal.y,
+ nearestHit.hitNormal.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);
+
+ 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
new file mode 100644
index 0000000..50d42d2
--- /dev/null
+++ b/examples/src/models/models_obj_loading.c
@@ -0,0 +1,75 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
+
+ // Define the camera to look into our 3d world
+ Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
+
+ Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
+ Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
+ dwarf.material.texDiffuse = texture; // Set dwarf model 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);
+
+ Begin3dMode(camera);
+
+ DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
+
+ DrawGrid(10, 1.0f); // Draw a grid
+
+ DrawGizmo(position); // Draw gizmo
+
+ End3dMode();
+
+ DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
+
+ DrawFPS(10, 10);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(texture); // Unload texture
+ UnloadModel(dwarf); // Unload model
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/src/physac/physics_demo.c b/examples/src/physac/physics_demo.c
new file mode 100644
index 0000000..5558836
--- /dev/null
+++ b/examples/src/physac/physics_demo.c
@@ -0,0 +1,128 @@
+/*******************************************************************************************
+*
+* 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 $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
+* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
+*
+* Copyright (c) 2017 Victor Fisac
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#define PHYSAC_IMPLEMENTATION
+#include "physac.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ SetConfigFlags(FLAG_MSAA_4X_HINT);
+ InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics demo");
+ SetTargetFPS(60);
+
+ // 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 }, 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)
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsKeyPressed('R')) // Reset physics input
+ {
+ ResetPhysics();
+
+ floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
+ floor->enabled = false;
+
+ circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10);
+ circle->enabled = false;
+ }
+
+ // 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(); // Uninitialize 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
new file mode 100644
index 0000000..6ce1d40
--- /dev/null
+++ b/examples/src/physac/physics_friction.c
@@ -0,0 +1,143 @@
+/*******************************************************************************************
+*
+* 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 $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
+* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
+*
+* Copyright (c) 2017 Victor Fisac
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#define PHYSAC_IMPLEMENTATION
+#include "physac.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ SetConfigFlags(FLAG_MSAA_4X_HINT);
+ InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics friction");
+ SetTargetFPS(60);
+
+ // 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);
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ 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(); // Uninitialize 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
new file mode 100644
index 0000000..534997b
--- /dev/null
+++ b/examples/src/physac/physics_movement.c
@@ -0,0 +1,129 @@
+/*******************************************************************************************
+*
+* 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 $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
+* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
+*
+* Copyright (c) 2017 Victor Fisac
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#define PHYSAC_IMPLEMENTATION
+#include "physac.h"
+
+#define VELOCITY 0.5f
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ SetConfigFlags(FLAG_MSAA_4X_HINT);
+ InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics movement");
+ SetTargetFPS(60);
+
+ // 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
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ 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(); // Uninitialize 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
new file mode 100644
index 0000000..0809697
--- /dev/null
+++ b/examples/src/physac/physics_restitution.c
@@ -0,0 +1,122 @@
+/*******************************************************************************************
+*
+* 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 $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
+* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
+*
+* Copyright (c) 2017 Victor Fisac
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#define PHYSAC_IMPLEMENTATION
+#include "physac.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ SetConfigFlags(FLAG_MSAA_4X_HINT);
+ InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics restitution");
+ SetTargetFPS(60);
+
+ // 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;
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ 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(); // Uninitialize 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
new file mode 100644
index 0000000..b237bfc
--- /dev/null
+++ b/examples/src/physac/physics_shatter.c
@@ -0,0 +1,114 @@
+/*******************************************************************************************
+*
+* 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 $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread
+* -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition
+*
+* Copyright (c) 2017 Victor Fisac
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#define PHYSAC_IMPLEMENTATION
+#include "physac.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ SetConfigFlags(FLAG_MSAA_4X_HINT);
+ InitWindow(screenWidth, screenHeight, "Physac [raylib] - Body shatter");
+ SetTargetFPS(60);
+
+ // Physac logo drawing position
+ int logoX = screenWidth - MeasureText("Physac", 30) - 10;
+ int logoY = 15;
+
+ // Initialize physics and default physics bodies
+ InitPhysics();
+ SetPhysicsGravity(0, 0);
+
+ // Create random polygon physics body to shatter
+ PhysicsBody body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsKeyPressed('R')) // Reset physics input
+ {
+ ResetPhysics();
+
+ // Create random polygon physics body to shatter
+ body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
+ }
+
+ 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(); // Uninitialize 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
new file mode 100644
index 0000000..89f87df
--- /dev/null
+++ b/examples/src/shaders/shaders_custom_uniform.c
@@ -0,0 +1,121 @@
+/*******************************************************************************************
+*
+* 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"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
+
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable");
+
+ // Define the camera to look into our 3d world
+ Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
+
+ Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
+ Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
+ dwarf.material.texDiffuse = texture; // Set dwarf model diffuse texture
+
+ Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
+
+ Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
+ "resources/shaders/glsl330/swirl.fs"); // Load postpro shader
+
+ // 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, 2);
+
+ UpdateCamera(&camera); // Update camera
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ BeginTextureMode(target); // Enable drawing to texture
+
+ Begin3dMode(camera);
+
+ DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
+
+ DrawGrid(10, 1.0f); // Draw a grid
+
+ End3dMode();
+
+ 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();
+
+ DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
+
+ DrawFPS(10, 10);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadShader(shader); // Unload shader
+ UnloadTexture(texture); // Unload texture
+ UnloadModel(dwarf); // 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_model_shader.c b/examples/src/shaders/shaders_model_shader.c
new file mode 100644
index 0000000..51e9c1b
--- /dev/null
+++ b/examples/src/shaders/shaders_model_shader.c
@@ -0,0 +1,93 @@
+/*******************************************************************************************
+*
+* 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"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
+
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader");
+
+ // Define the camera to look into our 3d world
+ Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
+
+ Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
+ Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
+ Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
+ "resources/shaders/glsl330/grayscale.fs"); // Load model shader
+
+ dwarf.material.shader = shader; // Set shader effect to 3d model
+ dwarf.material.texDiffuse = 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);
+
+ Begin3dMode(camera);
+
+ DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
+
+ DrawGrid(10, 1.0f); // Draw a grid
+
+ End3dMode();
+
+ DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
+
+ DrawText(FormatText("Camera position: (%.2f, %.2f, %.2f)", camera.position.x, camera.position.y, camera.position.z), 600, 20, 10, BLACK);
+ DrawText(FormatText("Camera target: (%.2f, %.2f, %.2f)", camera.target.x, camera.target.y, camera.target.z), 600, 40, 10, GRAY);
+
+ DrawFPS(10, 10);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadShader(shader); // Unload shader
+ UnloadTexture(texture); // Unload texture
+ UnloadModel(dwarf); // Unload model
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/src/shaders/shaders_postprocessing.c b/examples/src/shaders/shaders_postprocessing.c
new file mode 100644
index 0000000..bb239ef
--- /dev/null
+++ b/examples/src/shaders/shaders_postprocessing.c
@@ -0,0 +1,180 @@
+/*******************************************************************************************
+*
+* 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
+ #define DEFAULT_VERTEX_SHADER "resources/shaders/glsl330/base.vs"
+#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
+ #define GLSL_VERSION 100
+ #define DEFAULT_VERTEX_SHADER "resources/shaders/glsl100/base.vs"
+#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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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 = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
+
+ Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
+ Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
+ dwarf.material.texDiffuse = texture; // Set dwarf 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];
+
+ shaders[FX_GRAYSCALE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
+ shaders[FX_POSTERIZATION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/posterization.fs", GLSL_VERSION));
+ shaders[FX_DREAM_VISION] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/dream_vision.fs", GLSL_VERSION));
+ shaders[FX_PIXELIZER] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/pixelizer.fs", GLSL_VERSION));
+ shaders[FX_CROSS_HATCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_hatching.fs", GLSL_VERSION));
+ shaders[FX_CROSS_STITCHING] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/cross_stitching.fs", GLSL_VERSION));
+ shaders[FX_PREDATOR_VIEW] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/predator.fs", GLSL_VERSION));
+ shaders[FX_SCANLINES] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/scanlines.fs", GLSL_VERSION));
+ shaders[FX_FISHEYE] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/fisheye.fs", GLSL_VERSION));
+ shaders[FX_SOBEL] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/sobel.fs", GLSL_VERSION));
+ shaders[FX_BLOOM] = LoadShader(DEFAULT_VERTEX_SHADER, FormatText("resources/shaders/glsl%i/bloom.fs", GLSL_VERSION));
+ shaders[FX_BLUR] = LoadShader(DEFAULT_VERTEX_SHADER, 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
+
+ Begin3dMode(camera);
+
+ DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
+
+ DrawGrid(10, 1.0f); // Draw a grid
+
+ End3dMode();
+
+ 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();
+
+ DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f));
+
+ DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY);
+
+ 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(dwarf); // 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_shapes_textures.c b/examples/src/shaders/shaders_shapes_textures.c
new file mode 100644
index 0000000..40e99a8
--- /dev/null
+++ b/examples/src/shaders/shaders_shapes_textures.c
@@ -0,0 +1,109 @@
+/*******************************************************************************************
+*
+* 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"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders");
+
+ Texture2D fudesumi = LoadTexture("resources/fudesumi.png");
+
+ // NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
+ Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
+ "resources/shaders/glsl330/grayscale.fs");
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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);
+ DrawRectangleGradient(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/shapes/shapes_basic_shapes.c b/examples/src/shapes/shapes_basic_shapes.c
new file mode 100644
index 0000000..6b2719f
--- /dev/null
+++ b/examples/src/shapes/shapes_basic_shapes.c
@@ -0,0 +1,72 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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);
+
+ DrawLine(18, 42, screenWidth - 18, 42, BLACK);
+
+ DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
+ DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE);
+ DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE);
+
+ DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
+ DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
+ DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE);
+
+ DrawTriangle((Vector2){screenWidth/4*3, 80},
+ (Vector2){screenWidth/4*3 - 60, 150},
+ (Vector2){screenWidth/4*3 + 60, 150}, VIOLET);
+
+ DrawTriangleLines((Vector2){screenWidth/4*3, 160},
+ (Vector2){screenWidth/4*3 - 20, 230},
+ (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
+
+ DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
+
+ 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
new file mode 100644
index 0000000..dcab862
--- /dev/null
+++ b/examples/src/shapes/shapes_colors_palette.c
@@ -0,0 +1,97 @@
+/*******************************************************************************************
+*
+* raylib [shapes] example - Draw raylib custom color palette
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib color palette");
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update your variables here
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("raylib color palette", 28, 42, 20, BLACK);
+
+ DrawRectangle(26, 80, 100, 100, DARKGRAY);
+ DrawRectangle(26, 188, 100, 100, GRAY);
+ DrawRectangle(26, 296, 100, 100, LIGHTGRAY);
+ DrawRectangle(134, 80, 100, 100, MAROON);
+ DrawRectangle(134, 188, 100, 100, RED);
+ DrawRectangle(134, 296, 100, 100, PINK);
+ DrawRectangle(242, 80, 100, 100, ORANGE);
+ DrawRectangle(242, 188, 100, 100, GOLD);
+ DrawRectangle(242, 296, 100, 100, YELLOW);
+ DrawRectangle(350, 80, 100, 100, DARKGREEN);
+ DrawRectangle(350, 188, 100, 100, LIME);
+ DrawRectangle(350, 296, 100, 100, GREEN);
+ DrawRectangle(458, 80, 100, 100, DARKBLUE);
+ DrawRectangle(458, 188, 100, 100, BLUE);
+ DrawRectangle(458, 296, 100, 100, SKYBLUE);
+ DrawRectangle(566, 80, 100, 100, DARKPURPLE);
+ DrawRectangle(566, 188, 100, 100, VIOLET);
+ DrawRectangle(566, 296, 100, 100, PURPLE);
+ DrawRectangle(674, 80, 100, 100, DARKBROWN);
+ DrawRectangle(674, 188, 100, 100, BROWN);
+ DrawRectangle(674, 296, 100, 100, BEIGE);
+
+
+ DrawText("DARKGRAY", 65, 166, 10, BLACK);
+ DrawText("GRAY", 93, 274, 10, BLACK);
+ DrawText("LIGHTGRAY", 61, 382, 10, BLACK);
+ DrawText("MAROON", 186, 166, 10, BLACK);
+ DrawText("RED", 208, 274, 10, BLACK);
+ DrawText("PINK", 204, 382, 10, BLACK);
+ DrawText("ORANGE", 295, 166, 10, BLACK);
+ DrawText("GOLD", 310, 274, 10, BLACK);
+ DrawText("YELLOW", 300, 382, 10, BLACK);
+ DrawText("DARKGREEN", 382, 166, 10, BLACK);
+ DrawText("LIME", 420, 274, 10, BLACK);
+ DrawText("GREEN", 410, 382, 10, BLACK);
+ DrawText("DARKBLUE", 498, 166, 10, BLACK);
+ DrawText("BLUE", 526, 274, 10, BLACK);
+ DrawText("SKYBLUE", 505, 382, 10, BLACK);
+ DrawText("DARKPURPLE", 592, 166, 10, BLACK);
+ DrawText("VIOLET", 621, 274, 10, BLACK);
+ DrawText("PURPLE", 620, 382, 10, BLACK);
+ DrawText("DARKBROWN", 705, 166, 10, BLACK);
+ DrawText("BROWN", 733, 274, 10, BLACK);
+ DrawText("BEIGE", 737, 382, 10, 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_lines_bezier.c b/examples/src/shapes/shapes_lines_bezier.c
new file mode 100644
index 0000000..f413345
--- /dev/null
+++ b/examples/src/shapes/shapes_lines_bezier.c
@@ -0,0 +1,59 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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);
+ //--------------------------------------------------------------------------------------
+
+ // 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
new file mode 100644
index 0000000..be94988
--- /dev/null
+++ b/examples/src/shapes/shapes_logo_raylib.c
@@ -0,0 +1,56 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes");
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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
new file mode 100644
index 0000000..c6d3796
--- /dev/null
+++ b/examples/src/shapes/shapes_logo_raylib_anim.c
@@ -0,0 +1,160 @@
+/*******************************************************************************************
+*
+* raylib [shapes] example - raylib logo animation
+*
+* 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) 2014 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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);
+ //--------------------------------------------------------------------------------------
+
+ // 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(SubText("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/text/text_bmfont_ttf.c b/examples/src/text/text_bmfont_ttf.c
new file mode 100644
index 0000000..0778fd1
--- /dev/null
+++ b/examples/src/text/text_bmfont_ttf.c
@@ -0,0 +1,68 @@
+/*******************************************************************************************
+*
+* raylib [text] example - BMFont and TTF SpriteFonts 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading");
+
+ const char msgBm[64] = "THIS IS AN AngelCode SPRITE FONT";
+ const char msgTtf[64] = "THIS SPRITE FONT has been GENERATED from a TTF";
+
+ // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
+ SpriteFont fontBm = LoadSpriteFont("resources/bmfont.fnt"); // BMFont (AngelCode)
+ SpriteFont fontTtf = LoadSpriteFont("resources/pixantiqua.ttf"); // TTF font
+
+ Vector2 fontPosition;
+
+ fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.baseSize, 0).x/2;
+ fontPosition.y = screenHeight/2 - fontBm.baseSize/2 - 80;
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update variables here...
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawTextEx(fontBm, msgBm, fontPosition, fontBm.baseSize, 0, MAROON);
+ DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.baseSize*0.8f, 2, LIME);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadSpriteFont(fontBm); // AngelCode SpriteFont unloading
+ UnloadSpriteFont(fontTtf); // TTF SpriteFont unloading
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/src/text/text_bmfont_unordered.c b/examples/src/text/text_bmfont_unordered.c
new file mode 100644
index 0000000..01561be
--- /dev/null
+++ b/examples/src/text/text_bmfont_unordered.c
@@ -0,0 +1,65 @@
+/*******************************************************************************************
+*
+* raylib [text] example - BMFont unordered chars loading and drawing
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont unordered loading and drawing");
+
+ // NOTE: Using chars outside the [32..127] limits!
+ // NOTE: If a character is not found in the font, it just renders a space
+ const char msg[256] = "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
+
+ // NOTE: Loaded font has an unordered list of characters (chars in the range 32..255)
+ SpriteFont font = LoadSpriteFont("resources/pixantiqua.fnt"); // BMFont (AngelCode)
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update variables here...
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("Font name: PixAntiqua", 40, 50, 20, GRAY);
+ DrawText(FormatText("Font base size: %i", font.baseSize), 40, 80, 20, GRAY);
+ DrawText(FormatText("Font chars number: %i", font.charsCount), 40, 110, 20, GRAY);
+
+ DrawTextEx(font, msg, (Vector2){ 40, 180 }, font.baseSize, 0, MAROON);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadSpriteFont(font); // AngelCode SpriteFont unloading
+
+ 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
new file mode 100644
index 0000000..ca28be7
--- /dev/null
+++ b/examples/src/text/text_format_text.c
@@ -0,0 +1,62 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting");
+
+ int score = 100020;
+ int hiscore = 200450;
+ int lives = 5;
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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
new file mode 100644
index 0000000..54eebf4
--- /dev/null
+++ b/examples/src/text/text_input_box.c
@@ -0,0 +1,116 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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);
+ //--------------------------------------------------------------------------------------
+
+ // 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 (key == 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
new file mode 100644
index 0000000..6d8ef2b
--- /dev/null
+++ b/examples/src/text/text_raylib_fonts.c
@@ -0,0 +1,103 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+ SpriteFont fonts[MAX_FONTS];
+
+ fonts[0] = LoadSpriteFont("resources/fonts/alagard.png");
+ fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.png");
+ fonts[2] = LoadSpriteFont("resources/fonts/mecha.png");
+ fonts[3] = LoadSpriteFont("resources/fonts/setback.png");
+ fonts[4] = LoadSpriteFont("resources/fonts/romulus.png");
+ fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.png");
+ fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.png");
+ fonts[7] = LoadSpriteFont("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 };
+ //--------------------------------------------------------------------------------------
+
+ // 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
+ //--------------------------------------------------------------------------------------
+
+ // SpriteFonts unloading
+ for (int i = 0; i < MAX_FONTS; i++) UnloadSpriteFont(fonts[i]);
+
+ 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
new file mode 100644
index 0000000..aefbfd1
--- /dev/null
+++ b/examples/src/text/text_sprite_fonts.c
@@ -0,0 +1,77 @@
+/*******************************************************************************************
+*
+* raylib [text] example - SpriteFont 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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)
+ SpriteFont font1 = LoadSpriteFont("resources/custom_mecha.png"); // SpriteFont loading
+ SpriteFont font2 = LoadSpriteFont("resources/custom_alagard.png"); // SpriteFont loading
+ SpriteFont font3 = LoadSpriteFont("resources/custom_jupiter_crash.png"); // SpriteFont 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;
+
+ //--------------------------------------------------------------------------------------
+
+ // 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
+ //--------------------------------------------------------------------------------------
+ UnloadSpriteFont(font1); // SpriteFont unloading
+ UnloadSpriteFont(font2); // SpriteFont unloading
+ UnloadSpriteFont(font3); // SpriteFont 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
new file mode 100644
index 0000000..02b7f95
--- /dev/null
+++ b/examples/src/text/text_ttf_loading.c
@@ -0,0 +1,130 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading");
+
+ const char msg[50] = "TTF SpriteFont";
+
+ // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
+
+ // TTF SpriteFont loading with custom generation parameters
+ SpriteFont font = LoadSpriteFontEx("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 + 50 };
+ Vector2 textSize;
+
+ SetTextureFilter(font.texture, FILTER_POINT);
+ int currentFontFilter = 0; // FILTER_POINT
+
+ int count = 0;
+ char **droppedFiles;
+
+ SetTargetFPS(60);
+ //--------------------------------------------------------------------------------------
+
+ // 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())
+ {
+ droppedFiles = GetDroppedFiles(&count);
+
+ if (count == 1) // Only support one ttf file dropped
+ {
+ UnloadSpriteFont(font);
+ font = LoadSpriteFontEx(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
+ //--------------------------------------------------------------------------------------
+ UnloadSpriteFont(font); // SpriteFont unloading
+
+ ClearDroppedFiles(); // Clear internal buffers
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/src/text/text_writing_anim.c b/examples/src/text/text_writing_anim.c
new file mode 100644
index 0000000..5563b56
--- /dev/null
+++ b/examples/src/text/text_writing_anim.c
@@ -0,0 +1,62 @@
+/*******************************************************************************************
+*
+* raylib [text] example - Text Writing Animation
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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);
+ //--------------------------------------------------------------------------------------
+
+ // 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(SubText(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_image_drawing.c b/examples/src/textures/textures_image_drawing.c
new file mode 100644
index 0000000..1c6a1fb
--- /dev/null
+++ b/examples/src/textures/textures_image_drawing.c
@@ -0,0 +1,78 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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
+
+ 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_loading.c b/examples/src/textures/textures_image_loading.c
new file mode 100644
index 0000000..54c7358
--- /dev/null
+++ b/examples/src/textures/textures_image_loading.c
@@ -0,0 +1,63 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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
new file mode 100644
index 0000000..58b746e
--- /dev/null
+++ b/examples/src/textures/textures_image_processing.c
@@ -0,0 +1,154 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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)
+ 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, 50 + 32*i, 150, 30 };
+
+ 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++)
+ {
+ if (i == currentProcess)
+ {
+ DrawRectangleRec(selectRecs[i], SKYBLUE);
+ DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE);
+ DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKBLUE);
+ }
+ else
+ {
+ DrawRectangleRec(selectRecs[i], LIGHTGRAY);
+ DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY);
+ DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, 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_logo_raylib.c b/examples/src/textures/textures_logo_raylib.c
new file mode 100644
index 0000000..f2f9312
--- /dev/null
+++ b/examples/src/textures/textures_logo_raylib.c
@@ -0,0 +1,57 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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_particles_blending.c b/examples/src/textures/textures_particles_blending.c
new file mode 100644
index 0000000..842ac77
--- /dev/null
+++ b/examples/src/textures/textures_particles_blending.c
@@ -0,0 +1,135 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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 = 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, 0, smoke.width, smoke.height },
+ (Rectangle){ mouseTail[i].position.x, mouseTail[i].position.y, smoke.width*mouseTail[i].size, smoke.height*mouseTail[i].size },
+ (Vector2){ smoke.width*mouseTail[i].size/2, smoke.height*mouseTail[i].size/2 }, 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
new file mode 100644
index 0000000..b038792
--- /dev/null
+++ b/examples/src/textures/textures_raw_data.c
@@ -0,0 +1,95 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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 = 1024;
+ int height = 1024;
+
+ // 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*height + x] = ORANGE;
+ else pixels[y*height + 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, 100, 30, BROWN);
+ DrawText("GENERATED by CODE", 72, 164, 30, BROWN);
+ DrawText("and RAW IMAGE LOADING", 46, 226, 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
new file mode 100644
index 0000000..c90db8a
--- /dev/null
+++ b/examples/src/textures/textures_rectangle.c
@@ -0,0 +1,99 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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, 0, scarfy.width/6, 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 = currentFrame*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_srcrec_dstrec.c b/examples/src/textures/textures_srcrec_dstrec.c
new file mode 100644
index 0000000..53ffd1d
--- /dev/null
+++ b/examples/src/textures/textures_srcrec_dstrec.c
@@ -0,0 +1,81 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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;
+
+ // NOTE: Source rectangle (part of the texture to use for drawing)
+ Rectangle sourceRec = { 0, 0, frameWidth, frameHeight };
+
+ // NOTE: Destination rectangle (screen rectangle where drawing part of texture)
+ Rectangle destRec = { screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 };
+
+ // NOTE: 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, rotation, WHITE);
+
+ DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY);
+ DrawLine(0, destRec.y, screenWidth, 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
new file mode 100644
index 0000000..37c3b5a
--- /dev/null
+++ b/examples/src/textures/textures_to_image.c
@@ -0,0 +1,68 @@
+/*******************************************************************************************
+*
+* 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()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ 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