aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2014-09-21 14:26:42 +0200
committerraysan5 <raysan5@gmail.com>2014-09-21 14:26:42 +0200
commit5ecb6801fa5bf4f59a4459adfda922169523567f (patch)
tree0516a772c0efaccfb9980b5d6620b903ffddc1b2 /examples
parent3a0d164a768a7c4ec1e5f56ddfc005182f8a86eb (diff)
downloadraylib-5ecb6801fa5bf4f59a4459adfda922169523567f.tar.gz
raylib-5ecb6801fa5bf4f59a4459adfda922169523567f.zip
Examples renaming and test examples merge
Examples have been renamed for coherence with raylib modules and test examples have been merged into examples folder.
Diffstat (limited to 'examples')
-rw-r--r--examples/audio_music_stream.c87
-rw-r--r--examples/audio_music_stream.pngbin0 -> 15043 bytes
-rw-r--r--examples/audio_sound_loading.c24
-rw-r--r--examples/audio_sound_loading.pngbin0 -> 15438 bytes
-rw-r--r--examples/core_3d_mode.c20
-rw-r--r--examples/core_3d_mode.png (renamed from examples/ex07a_3d_mode.png)bin8492 -> 8492 bytes
-rw-r--r--examples/core_basic_window.c8
-rw-r--r--examples/core_basic_window.png (renamed from examples/ex01_basic_window.png)bin10297 -> 10297 bytes
-rw-r--r--examples/core_color_select.c38
-rw-r--r--examples/core_color_select.png (renamed from examples/ex06a_color_select.png)bin14328 -> 14328 bytes
-rw-r--r--examples/core_input_gamepad.c25
-rw-r--r--examples/core_input_gamepad.png (renamed from examples/ex03c_input_gamepad.png)bin10840 -> 10840 bytes
-rw-r--r--examples/core_input_keys.c14
-rw-r--r--examples/core_input_keys.png (renamed from examples/ex03a_input_keys.png)bin10379 -> 10379 bytes
-rw-r--r--examples/core_input_mouse.c12
-rw-r--r--examples/core_input_mouse.png (renamed from examples/ex03b_input_mouse.png)bin10644 -> 10644 bytes
-rw-r--r--examples/core_mouse_wheel.c58
-rw-r--r--examples/core_mouse_wheel.pngbin0 -> 15375 bytes
-rw-r--r--examples/core_random_values.c65
-rw-r--r--examples/core_random_values.pngbin0 -> 15247 bytes
-rw-r--r--examples/ex07b_3d_shapes.pngbin24134 -> 0 bytes
-rw-r--r--examples/ex07c_3d_models.pngbin38326 -> 0 bytes
-rw-r--r--examples/ex08_audio.pngbin3543 -> 0 bytes
-rw-r--r--examples/makefile174
-rw-r--r--examples/models_billboard.c73
-rw-r--r--examples/models_cubesmap.c80
-rw-r--r--examples/models_cubesmap.pngbin0 -> 27438 bytes
-rw-r--r--examples/models_geometric_shapes.c10
-rw-r--r--examples/models_geometric_shapes.pngbin0 -> 33973 bytes
-rw-r--r--examples/models_heightmap.c76
-rw-r--r--examples/models_heightmap.pngbin0 -> 31972 bytes
-rw-r--r--examples/models_obj_loading.c37
-rw-r--r--examples/models_obj_models.pngbin0 -> 61860 bytes
-rw-r--r--examples/models_planes.c64
-rw-r--r--examples/openal32.dllbin0 -> 402553 bytes
-rw-r--r--examples/resources/audio/guitar_noodling.oggbin0 -> 506938 bytes
-rw-r--r--examples/resources/audio/tanatana.oggbin0 -> 57328 bytes
-rw-r--r--examples/resources/cubesmap.pngbin0 -> 173 bytes
-rw-r--r--examples/resources/heightmap.pngbin0 -> 1362 bytes
-rw-r--r--examples/resources/mouse.pngbin1773 -> 0 bytes
-rw-r--r--examples/resources/raylib_logo.ddsbin0 -> 87536 bytes
-rw-r--r--examples/resources/raylib_logo_uncompressed.ddsbin0 -> 349652 bytes
-rw-r--r--examples/shapes_basic_shapes.c8
-rw-r--r--examples/shapes_basic_shapes.png (renamed from examples/ex02b_basic_shapes.png)bin26439 -> 26439 bytes
-rw-r--r--examples/shapes_color_palette.c8
-rw-r--r--examples/shapes_colors_palette.png (renamed from examples/ex02c_color_palette.png)bin5230 -> 5230 bytes
-rw-r--r--examples/shapes_logo_raylib.c10
-rw-r--r--examples/shapes_logo_raylib.png (renamed from examples/ex02a_logo_raylib.png)bin12676 -> 12676 bytes
-rw-r--r--examples/shapes_logo_raylib_anim.c35
-rw-r--r--examples/shapes_logo_raylib_anim.png (renamed from examples/ex06b_logo_anim.png)bin4787 -> 4787 bytes
-rw-r--r--examples/text_font_select.c10
-rw-r--r--examples/text_font_select.png (renamed from examples/ex06c_font_select.png)bin3097 -> 3097 bytes
-rw-r--r--examples/text_format_text.c62
-rw-r--r--examples/text_format_text.pngbin0 -> 15481 bytes
-rw-r--r--examples/text_rbmf_fonts.c27
-rw-r--r--examples/text_rbmf_fonts.png (renamed from examples/ex05b_rbmf_fonts.png)bin14877 -> 14877 bytes
-rw-r--r--examples/text_sprite_fonts.c12
-rw-r--r--examples/text_sprite_fonts.png (renamed from examples/ex05a_sprite_fonts.png)bin19567 -> 19567 bytes
-rw-r--r--examples/textures_compressed_dds.c64
-rw-r--r--examples/textures_compressed_dds.pngbin0 -> 15243 bytes
-rw-r--r--examples/textures_image_loading.c63
-rw-r--r--examples/textures_image_loading.pngbin0 -> 17200 bytes
-rw-r--r--examples/textures_logo_raylib.c8
-rw-r--r--examples/textures_logo_raylib.png (renamed from examples/ex04a_textures.png)bin15442 -> 15442 bytes
-rw-r--r--examples/textures_mipmaps.c66
-rw-r--r--examples/textures_mipmaps.pngbin0 -> 17234 bytes
-rw-r--r--examples/textures_rectangle.c23
-rw-r--r--examples/textures_rectangle.png (renamed from examples/ex04b_texture_rectangle.png)bin86779 -> 86779 bytes
-rw-r--r--examples/textures_srcrec_dstrec.c68
-rw-r--r--examples/textures_srcrec_dstrec.pngbin0 -> 19183 bytes
70 files changed, 1115 insertions, 214 deletions
diff --git a/examples/audio_music_stream.c b/examples/audio_music_stream.c
new file mode 100644
index 00000000..0d026506
--- /dev/null
+++ b/examples/audio_music_stream.c
@@ -0,0 +1,87 @@
+/*******************************************************************************************
+*
+* raylib [audio] example - Music playing (streaming)
+*
+* NOTE: This example requires OpenAL Soft library installed
+*
+* 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 (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#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
+
+ PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream
+
+ int framesCounter = 0;
+ float volume = 1.0;
+ float timePlayed = 0;
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ framesCounter++;
+
+ // Testing music fading from one file to another
+/*
+ if (framesCounter > 600) // Wait for 10 seconds (600 frames)
+ {
+ volume -= 0.01; // Decrement music volume level
+
+ // When music volume level equal or lower than 0,
+ // restore volume level and init another music file
+ if (volume <= 0)
+ {
+ volume = 1.0;
+ framesCounter = 0;
+ PlayMusicStream("resources/audio/another_file.ogg");
+ }
+
+ SetMusicVolume(volume);
+ }
+*/
+ timePlayed = GetMusicTimePlayed() / GetMusicTimeLength() * 100 * 4; // We scale by 4 to fit 400 pixels
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("MUSIC SHOULD BE PLAYING!", 255, 200, 20, LIGHTGRAY);
+
+ DrawRectangle(200, 250, 400, 12, LIGHTGRAY);
+ DrawRectangle(200, 250, (int)timePlayed, 12, MAROON);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ 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/audio_music_stream.png b/examples/audio_music_stream.png
new file mode 100644
index 00000000..f8b14e15
--- /dev/null
+++ b/examples/audio_music_stream.png
Binary files differ
diff --git a/examples/audio_sound_loading.c b/examples/audio_sound_loading.c
index d070e95d..68f8dca9 100644
--- a/examples/audio_sound_loading.c
+++ b/examples/audio_sound_loading.c
@@ -1,13 +1,13 @@
/*******************************************************************************************
*
-* raylib example 08 - Audio loading and playing
+* raylib [audio] example - Sound loading and playing
*
-* NOTE: This example requires OpenAL32 dll installed (or in the same folder)
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -20,11 +20,12 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib example 08 - audio loading and playing");
+ InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");
InitAudioDevice(); // Initialize audio device
- Sound fx = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
+ Sound fxWav = LoadSound("resources/audio/weird.wav"); // Load WAV audio file
+ Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file
//--------------------------------------------------------------------------------------
// Main game loop
@@ -32,7 +33,9 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- if (IsKeyPressed(KEY_SPACE)) PlaySound(fx); // Play the sound!
+ if (IsKeyPressed(KEY_SPACE)) PlaySound(fxWav); // Play WAV sound
+
+ if (IsKeyPressed(KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound
//----------------------------------------------------------------------------------
// Draw
@@ -41,7 +44,9 @@ int main()
ClearBackground(RAYWHITE);
- DrawText("Press SPACE to PLAY the SOUND!", 240, 200, 20, LIGHTGRAY);
+ 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();
//----------------------------------------------------------------------------------
@@ -49,7 +54,8 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
- UnloadSound(fx); // Unload sound data
+ UnloadSound(fxWav); // Unload sound data
+ UnloadSound(fxOgg); // Unload sound data
CloseAudioDevice(); // Close audio device
@@ -57,4 +63,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/audio_sound_loading.png b/examples/audio_sound_loading.png
new file mode 100644
index 00000000..24071ce3
--- /dev/null
+++ b/examples/audio_sound_loading.png
Binary files differ
diff --git a/examples/core_3d_mode.c b/examples/core_3d_mode.c
index 984f3fea..e62247f6 100644
--- a/examples/core_3d_mode.c
+++ b/examples/core_3d_mode.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 07a - Initialize 3d mode
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,11 +18,14 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- Vector3 position = { 0.0, 0.0, 0.0 };
-
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
+
+ // Define the camera to look into our 3d world
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
-
- InitWindow(screenWidth, screenHeight, "raylib example 07a - 3d mode");
+
+ Vector3 cubePosition = { 0.0, 0.0, 0.0 };
+
+ //SetTargetFPS(60); // Set our game to run at 60 frames-per-second, but not now...
//--------------------------------------------------------------------------------------
// Main game loop
@@ -41,7 +44,8 @@ int main()
Begin3dMode(camera);
- DrawCube(position, 2, 2, 2, RED);
+ DrawCube(cubePosition, 2, 2, 2, RED);
+ DrawCubeWires(cubePosition, 2, 2, 2, MAROON);
DrawGrid(10.0, 1.0);
@@ -61,4 +65,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex07a_3d_mode.png b/examples/core_3d_mode.png
index de65daeb..de65daeb 100644
--- a/examples/ex07a_3d_mode.png
+++ b/examples/core_3d_mode.png
Binary files differ
diff --git a/examples/core_basic_window.c b/examples/core_basic_window.c
index e3caebb6..2feff985 100644
--- a/examples/core_basic_window.c
+++ b/examples/core_basic_window.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 01 - Basic Window
+* raylib [core] example - Basic window
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,7 +18,7 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib example 01a - basic window");
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
//--------------------------------------------------------------------------------------
// Main game loop
@@ -47,4 +47,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex01_basic_window.png b/examples/core_basic_window.png
index 34618441..34618441 100644
--- a/examples/ex01_basic_window.png
+++ b/examples/core_basic_window.png
Binary files differ
diff --git a/examples/core_color_select.c b/examples/core_color_select.c
index b3714bc8..6648a259 100644
--- a/examples/core_color_select.c
+++ b/examples/core_color_select.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 06a - Color selection by mouse (collision detection)
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -17,29 +17,29 @@ int main()
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 400;
+
+ 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 recs[21]; // Rectangles array
+ Rectangle colorsRecs[21]; // Rectangles array
- // Fills recs data (for every rectangle)
+ // Fills colorsRecs data (for every rectangle)
for (int i = 0; i < 21; i++)
{
- recs[i].x = 20 + 100*(i%7) + 10*(i%7);
- recs[i].y = 40 + 100*(i/7) + 10*(i/7);
- recs[i].width = 100;
- recs[i].height = 100;
+ colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7);
+ colorsRecs[i].y = 40 + 100*(i/7) + 10*(i/7);
+ colorsRecs[i].width = 100;
+ colorsRecs[i].height = 100;
}
- bool selected[21] = { false }; // Selected rectangles indicator
+ bool selected[21] = { false }; // Selected rectangles indicator
Vector2 mousePoint;
- InitWindow(screenWidth, screenHeight, "raylib example 06a - color selection");
-
- SetTargetFPS(60);
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -51,7 +51,7 @@ int main()
for (int i = 0; i < 21; i++) // Iterate along all the rectangles
{
- if (CheckCollisionPointRec(mousePoint, recs[i]))
+ if (CheckCollisionPointRec(mousePoint, colorsRecs[i]))
{
colors[i].a = 120;
@@ -69,15 +69,15 @@ int main()
for (int i = 0; i < 21; i++) // Draw all rectangles
{
- DrawRectangleRec(recs[i], colors[i]);
+ DrawRectangleRec(colorsRecs[i], colors[i]);
// Draw four rectangles around selected rectangle
if (selected[i])
{
- DrawRectangle(recs[i].x, recs[i].y, 100, 10, RAYWHITE); // Square top rectangle
- DrawRectangle(recs[i].x, recs[i].y, 10, 100, RAYWHITE); // Square left rectangle
- DrawRectangle(recs[i].x + 90, recs[i].y, 10, 100, RAYWHITE); // Square right rectangle
- DrawRectangle(recs[i].x, recs[i].y + 90, 100, 10, RAYWHITE); // Square bottom rectangle
+ 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
}
}
@@ -91,4 +91,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex06a_color_select.png b/examples/core_color_select.png
index 93ab83ae..93ab83ae 100644
--- a/examples/ex06a_color_select.png
+++ b/examples/core_color_select.png
Binary files differ
diff --git a/examples/core_input_gamepad.c b/examples/core_input_gamepad.c
index 6b883b42..9ce5b6ff 100644
--- a/examples/core_input_gamepad.c
+++ b/examples/core_input_gamepad.c
@@ -1,11 +1,14 @@
/*******************************************************************************************
*
-* raylib example 03c - Gamepad input
+* raylib [core] example - Gamepad input
+*
+* NOTE: This example requires a Gamepad connected to the system
+* raylib is configured to work with Xbox 360 gamepad, check raylib.h for buttons configuration
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,12 +21,12 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
- Vector2 gamepadMove = { 0, 0 };
-
- InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input");
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
- SetTargetFPS(60); // Set target frames-per-second
+ Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
+ Vector2 gamepadMovement = { 0, 0 };
+
+ SetTargetFPS(60); // Set target frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -33,10 +36,10 @@ int main()
//----------------------------------------------------------------------------------
if (IsGamepadAvailable(GAMEPAD_PLAYER1))
{
- gamepadMove = GetGamepadMovement(GAMEPAD_PLAYER1);
+ gamepadMovement = GetGamepadMovement(GAMEPAD_PLAYER1);
- ballPosition.x += gamepadMove.x;
- ballPosition.y -= gamepadMove.y;
+ ballPosition.x += gamepadMovement.x;
+ ballPosition.y -= gamepadMovement.y;
if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A))
{
@@ -66,4 +69,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex03c_input_gamepad.png b/examples/core_input_gamepad.png
index f7e55658..f7e55658 100644
--- a/examples/ex03c_input_gamepad.png
+++ b/examples/core_input_gamepad.png
Binary files differ
diff --git a/examples/core_input_keys.c b/examples/core_input_keys.c
index 5c9a4aa1..086edd9f 100644
--- a/examples/core_input_keys.c
+++ b/examples/core_input_keys.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 03a - Keyboard input
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,10 +18,10 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
-
- InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input");
-
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
+
+ Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
+
SetTargetFPS(60); // Set target frames-per-second
//--------------------------------------------------------------------------------------
@@ -56,4 +56,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex03a_input_keys.png b/examples/core_input_keys.png
index 48370321..48370321 100644
--- a/examples/ex03a_input_keys.png
+++ b/examples/core_input_keys.png
Binary files differ
diff --git a/examples/core_input_mouse.c b/examples/core_input_mouse.c
index 71aba744..419238ad 100644
--- a/examples/core_input_mouse.c
+++ b/examples/core_input_mouse.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 03b - Mouse input
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,10 +18,10 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- Vector2 ballPosition = { -100.0, -100.0 };
- int mouseX, mouseY;
+ InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
- InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input");
+ int mouseX, mouseY;
+ Vector2 ballPosition = { -100.0, -100.0 };
//---------------------------------------------------------------------------------------
// Main game loop
@@ -59,4 +59,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex03b_input_mouse.png b/examples/core_input_mouse.png
index 76567281..76567281 100644
--- a/examples/ex03b_input_mouse.png
+++ b/examples/core_input_mouse.png
Binary files differ
diff --git a/examples/core_mouse_wheel.c b/examples/core_mouse_wheel.c
new file mode 100644
index 00000000..11b43573
--- /dev/null
+++ b/examples/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 (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#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/core_mouse_wheel.png b/examples/core_mouse_wheel.png
new file mode 100644
index 00000000..26a1f243
--- /dev/null
+++ b/examples/core_mouse_wheel.png
Binary files differ
diff --git a/examples/core_random_values.c b/examples/core_random_values.c
new file mode 100644
index 00000000..9cb10b8c
--- /dev/null
+++ b/examples/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 (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#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/core_random_values.png b/examples/core_random_values.png
new file mode 100644
index 00000000..6dd49475
--- /dev/null
+++ b/examples/core_random_values.png
Binary files differ
diff --git a/examples/ex07b_3d_shapes.png b/examples/ex07b_3d_shapes.png
deleted file mode 100644
index febc421e..00000000
--- a/examples/ex07b_3d_shapes.png
+++ /dev/null
Binary files differ
diff --git a/examples/ex07c_3d_models.png b/examples/ex07c_3d_models.png
deleted file mode 100644
index f6dd01cd..00000000
--- a/examples/ex07c_3d_models.png
+++ /dev/null
Binary files differ
diff --git a/examples/ex08_audio.png b/examples/ex08_audio.png
deleted file mode 100644
index 02eff2c5..00000000
--- a/examples/ex08_audio.png
+++ /dev/null
Binary files differ
diff --git a/examples/makefile b/examples/makefile
index 59b16d70..2a2d62b2 100644
--- a/examples/makefile
+++ b/examples/makefile
@@ -72,24 +72,36 @@ endif
# define all object files required
EXAMPLES = \
- ex01_basic_window \
- ex02a_logo_raylib \
- ex02b_basic_shapes \
- ex02c_color_palette \
- ex03a_input_keys \
- ex03b_input_mouse \
- ex04a_textures \
- ex04b_texture_rectangle \
- ex05a_sprite_fonts \
- ex05b_rbmf_fonts \
- ex06a_color_select \
- ex06b_logo_anim \
- ex06c_font_select \
- ex07a_3d_mode \
- ex07b_3d_shapes \
- ex07c_3d_models \
- ex08_audio
- #ex03c_input_gamepad \
+ core_basic_window \
+ core_input_keys \
+ core_input_mouse \
+ core_mouse_wheel \
+ core_random_values \
+ core_color_select \
+ core_3d_mode \
+ shapes_logo_raylib \
+ shapes_basic_shapes \
+ shapes_color_palette \
+ shapes_logo_raylib_anim \
+ textures_logo_raylib \
+ textures_image_loading \
+ textures_rectangle \
+ textures_compressed_dds \
+ textures_mipmaps \
+ textures_srcrec_dstrec \
+ text_sprite_fonts \
+ text_rbmf_fonts \
+ text_format_text \
+ text_font_select \
+ models_geometric_shapes \
+ models_planes \
+ models_billboard \
+ models_obj_loading \
+ models_heightmap \
+ models_cubesmap \
+ audio_sound_loading \
+ audio_music_stream \
+ #core_input_gamepad \
# typing 'make' will invoke the first target entry in the file,
@@ -99,82 +111,126 @@ default: examples
# compile all examples
examples: $(EXAMPLES)
-# compile example 01 - basic window
-ex01_basic_window: ex01_basic_window.c
+# compile [core] example - basic window
+core_basic_window: core_basic_window.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex02a_logo_raylib: ex02a_logo_raylib.c
+# compile [core] example - keyboard input
+core_input_keys: core_input_keys.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex02b_basic_shapes: ex02b_basic_shapes.c
+# compile [core] example - mouse input
+core_input_mouse: core_input_mouse.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex02c_color_palette: ex02c_color_palette.c
+ifeq ($(PLATFORM),PLATFORM_DESKTOP)
+# compile [core] example - gamepad input
+core_input_gamepad: core_input_gamepad.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+endif
-# compile example 01 - basic window
-ex03a_input_keys: ex03a_input_keys.c
+# compile [core] example - mouse wheel
+core_mouse_wheel: core_mouse_wheel.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex03b_input_mouse: ex03b_input_mouse.c
+# compile [core] example - generate random values
+core_random_values: core_random_values.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-ifeq ($(PLATFORM),PLATFORM_DESKTOP)
-# compile example 01 - basic window
-ex03c_input_gamepad: ex03c_input_gamepad.c
+# compile [core] example - color selection (collision detection)
+core_color_select: core_color_select.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-endif
-
-# compile example 01 - basic window
-ex04a_textures: ex04a_textures.c
+
+# compile [core] example - 3d mode
+core_3d_mode: core_3d_mode.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [shapes] example - raylib logo (with basic shapes)
+shapes_logo_raylib: shapes_logo_raylib.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [shapes] example - basic shapes usage (rectangle, circle, ...)
+shapes_basic_shapes: shapes_basic_shapes.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [shapes] example - raylib color palette
+shapes_color_palette: shapes_color_palette.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [shapes] example - raylib logo animation
+shapes_logo_raylib_anim: shapes_logo_raylib_anim.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [textures] example - raylib logo texture loading
+textures_logo_raylib: textures_logo_raylib.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [textures] example - image loading and conversion to texture
+textures_image_loading: textures_image_loading.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [textures] example - texture rectangle drawing
+textures_rectangle: textures_rectangle.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [textures] example - compressed texture loading (DDS)
+textures_compressed_dds: textures_compressed_dds.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [textures] example - texture mipmaps generation
+textures_mipmaps: textures_mipmaps.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [textures] example - texture source and destination rectangles
+textures_srcrec_dstrec: textures_srcrec_dstrec.c
+ $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
+
+# compile [text] example - sprite fonts loading
+text_sprite_fonts: text_sprite_fonts.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex04b_texture_rectangle: ex04b_texture_rectangle.c
+# compile [text] example - raylib bitmap fonts (rBMF)
+text_rbmf_fonts: text_rbmf_fonts.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex05a_sprite_fonts: ex05a_sprite_fonts.c
+# compile [text] example - text formatting
+text_format_text: text_format_text.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex05b_rbmf_fonts: ex05b_rbmf_fonts.c
+# compile [text] example - font selection program
+text_font_select: text_font_select.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex06a_color_select: ex06a_color_select.c
+# compile [models] example - basic geometric 3d shapes
+models_geometric_shapes: models_geometric_shapes.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex06b_logo_anim: ex06b_logo_anim.c
+# compile [models] example - basic window
+models_planes: models_planes.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex06b_shape_select: ex06b_shape_select.c
+# compile [models] example - billboard usage
+models_billboard: models_billboard.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex06c_font_select: ex06c_font_select.c
+# compile [models] example - OBJ model loading
+models_obj_loading: models_obj_loading.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex07a_3d_mode: ex07a_3d_mode.c
+# compile [models] example - heightmap loading
+models_heightmap: models_heightmap.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex07b_3d_shapes: ex07b_3d_shapes.c
+# compile [models] example - cubesmap loading
+models_cubesmap: models_cubesmap.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex07c_3d_models: ex07c_3d_models.c
+# compile [audio] example - sound loading and playing (WAV and OGG)
+audio_sound_loading: audio_sound_loading.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
-# compile example 01 - basic window
-ex08_audio: ex08_audio.c
+# compile [audio] example - music stream playing (OGG)
+audio_music_stream: audio_music_stream.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# clean everything
diff --git a/examples/models_billboard.c b/examples/models_billboard.c
new file mode 100644
index 00000000..19054c36
--- /dev/null
+++ b/examples/models_billboard.c
@@ -0,0 +1,73 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Drawing billboards
+*
+* This example has been created using raylib 1.2 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#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 = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
+
+ Texture2D lena = LoadTexture("resources/lena.png"); // Our texture for billboard
+ Rectangle eyesRec = { 225, 240, 155, 50 }; // Part of the texture to draw
+ Vector3 billPosition = { 0.0, 0.0, 0.0 }; // Position where draw billboard
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsKeyDown(KEY_LEFT)) camera.position.x -= 0.2;
+ if (IsKeyDown(KEY_RIGHT)) camera.position.x += 0.2;
+ if (IsKeyDown(KEY_UP)) camera.position.y -= 0.2;
+ if (IsKeyDown(KEY_DOWN)) camera.position.y += 0.2;
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ Begin3dMode(camera);
+
+ //DrawBillboard(camera, lena, billPosition, 1.0, WHITE);
+ DrawBillboardRec(camera, lena, eyesRec, billPosition, 4.0, WHITE);
+
+ DrawGrid(10.0, 1.0); // Draw a grid
+
+ End3dMode();
+
+ DrawFPS(10, 10);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(lena); // Unload texture
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/models_cubesmap.c b/examples/models_cubesmap.c
new file mode 100644
index 00000000..ff113483
--- /dev/null
+++ b/examples/models_cubesmap.c
@@ -0,0 +1,80 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Cubesmap loading and drawing
+*
+* This example has been created using raylib 1.2 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#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 = {{ 7.0, 7.0, 7.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
+
+ Image img = LoadImage("resources/cubesmap.png"); // Load cubesmap image (RAM)
+ Texture2D texture = CreateTexture(img, false); // Convert image to texture (VRAM)
+ Model map = LoadCubesmap(img); // Load cubesmap model
+ SetModelTexture(&map, texture); // Bind texture to model
+ Vector3 mapPosition = { -1, 0.0, -1 }; // Set model position
+
+ UnloadImage(img); // Unload cubesmap image from RAM, already uploaded to VRAM
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsKeyDown(KEY_UP)) camera.position.y += 0.2f;
+ else if (IsKeyDown(KEY_DOWN)) camera.position.y -= 0.2f;
+
+ if (IsKeyDown(KEY_RIGHT)) camera.position.z += 0.2f;
+ else if (IsKeyDown(KEY_LEFT)) camera.position.z -= 0.2f;
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ Begin3dMode(camera);
+
+ DrawModel(map, mapPosition, 1.0f, MAROON);
+
+ DrawGrid(10.0, 1.0);
+
+ DrawGizmo(mapPosition);
+
+ End3dMode();
+
+ 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/models_cubesmap.png b/examples/models_cubesmap.png
new file mode 100644
index 00000000..f686ba21
--- /dev/null
+++ b/examples/models_cubesmap.png
Binary files differ
diff --git a/examples/models_geometric_shapes.c b/examples/models_geometric_shapes.c
index a25daed5..b5243fb1 100644
--- a/examples/models_geometric_shapes.c
+++ b/examples/models_geometric_shapes.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 07b - Draw some basic 3d shapes (cube, sphere, cylinder...)
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,11 +18,11 @@ int main()
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.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
- InitWindow(screenWidth, screenHeight, "raylib example 07b - 3d shapes");
-
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -72,4 +72,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/models_geometric_shapes.png b/examples/models_geometric_shapes.png
new file mode 100644
index 00000000..6076b429
--- /dev/null
+++ b/examples/models_geometric_shapes.png
Binary files differ
diff --git a/examples/models_heightmap.c b/examples/models_heightmap.c
new file mode 100644
index 00000000..644f9723
--- /dev/null
+++ b/examples/models_heightmap.c
@@ -0,0 +1,76 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Heightmap loading and drawing
+*
+* 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 (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
+
+ // Define the camera to look into our 3d world
+ Camera camera = {{ 10.0, 12.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
+
+ Image img = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
+ Texture2D texture = CreateTexture(img, false); // Convert image to texture (VRAM)
+ Model map = LoadHeightmap(img, 4); // Load heightmap model
+ SetModelTexture(&map, texture); // Bind texture to model
+ Vector3 mapPosition = { -4, 0.0, -4 }; // Set model position
+
+ UnloadImage(img); // Unload heightmap image from RAM, already uploaded to VRAM
+
+ 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(map, mapPosition, 0.5f, MAROON);
+
+ DrawGrid(10.0, 1.0);
+
+ DrawGizmo(mapPosition);
+
+ End3dMode();
+
+ 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/models_heightmap.png b/examples/models_heightmap.png
new file mode 100644
index 00000000..a32ec954
--- /dev/null
+++ b/examples/models_heightmap.png
Binary files differ
diff --git a/examples/models_obj_loading.c b/examples/models_obj_loading.c
index 90bccf8a..3c2da62f 100644
--- a/examples/models_obj_loading.c
+++ b/examples/models_obj_loading.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 07c - Load and draw a 3d model (OBJ)
+* raylib [models] example - Load and draw a 3d model (OBJ)
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,18 +18,17 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- Vector3 position = { 0.0, 0.0, 0.0 };
-
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
+
// Define the camera to look into our 3d world
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
-
- InitWindow(screenWidth, screenHeight, "raylib example 07c - 3d models");
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
-
- Texture2D texture = LoadTexture("resources/catsham.png");
- Model cat = LoadModel("resources/cat.obj");
- SetModelTexture(&cat, texture); // Link texture to model
+
+ Texture2D texture = LoadTexture("resources/catsham.png"); // Load model texture
+ Model cat = LoadModel("resources/cat.obj"); // Load OBJ model
+ SetModelTexture(&cat, texture); // Bind texture to model
+ Vector3 catPosition = { 0.0, 0.0, 0.0 }; // Set model position
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -37,10 +36,10 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- if (IsKeyDown(KEY_LEFT)) position.x -= 0.2;
- if (IsKeyDown(KEY_RIGHT)) position.x += 0.2;
- if (IsKeyDown(KEY_UP)) position.z -= 0.2;
- if (IsKeyDown(KEY_DOWN)) position.z += 0.2;
+ if (IsKeyDown(KEY_LEFT)) catPosition.x -= 0.2;
+ if (IsKeyDown(KEY_RIGHT)) catPosition.x += 0.2;
+ if (IsKeyDown(KEY_UP)) catPosition.z -= 0.2;
+ if (IsKeyDown(KEY_DOWN)) catPosition.z += 0.2;
//----------------------------------------------------------------------------------
// Draw
@@ -51,11 +50,11 @@ int main()
Begin3dMode(camera);
- DrawModel(cat, position, 0.1f, WHITE); // Draw 3d model with texture
+ DrawModel(cat, catPosition, 0.1f, WHITE); // Draw 3d model with texture
DrawGrid(10.0, 1.0); // Draw a grid
- DrawGizmo(position);
+ DrawGizmo(catPosition); // Draw gizmo
End3dMode();
@@ -74,4 +73,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/models_obj_models.png b/examples/models_obj_models.png
new file mode 100644
index 00000000..da49c457
--- /dev/null
+++ b/examples/models_obj_models.png
Binary files differ
diff --git a/examples/models_planes.c b/examples/models_planes.c
new file mode 100644
index 00000000..4ddded21
--- /dev/null
+++ b/examples/models_planes.c
@@ -0,0 +1,64 @@
+/*******************************************************************************************
+*
+* raylib [models] example - Draw 3d planes
+*
+* This example has been created using raylib 1.2 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d planes");
+
+ // Define the camera to look into our 3d world
+ Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update your variables here
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ Begin3dMode(camera);
+
+ DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 4, 4 }, (Vector3){ 0, 45, 0 }, RED);
+ //DrawPlaneEx((Vector3){ 0, 8, 0 }, (Vector2){ 2, 1 }, (Vector3){ 0, 0, 0 }, 4, 4, SKYBLUE);
+
+ DrawGrid(10.0, 1.0);
+
+ 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/openal32.dll b/examples/openal32.dll
new file mode 100644
index 00000000..71ced6a2
--- /dev/null
+++ b/examples/openal32.dll
Binary files differ
diff --git a/examples/resources/audio/guitar_noodling.ogg b/examples/resources/audio/guitar_noodling.ogg
new file mode 100644
index 00000000..f5022040
--- /dev/null
+++ b/examples/resources/audio/guitar_noodling.ogg
Binary files differ
diff --git a/examples/resources/audio/tanatana.ogg b/examples/resources/audio/tanatana.ogg
new file mode 100644
index 00000000..90b1795a
--- /dev/null
+++ b/examples/resources/audio/tanatana.ogg
Binary files differ
diff --git a/examples/resources/cubesmap.png b/examples/resources/cubesmap.png
new file mode 100644
index 00000000..87b95d50
--- /dev/null
+++ b/examples/resources/cubesmap.png
Binary files differ
diff --git a/examples/resources/heightmap.png b/examples/resources/heightmap.png
new file mode 100644
index 00000000..c17050fc
--- /dev/null
+++ b/examples/resources/heightmap.png
Binary files differ
diff --git a/examples/resources/mouse.png b/examples/resources/mouse.png
deleted file mode 100644
index 543f32b3..00000000
--- a/examples/resources/mouse.png
+++ /dev/null
Binary files differ
diff --git a/examples/resources/raylib_logo.dds b/examples/resources/raylib_logo.dds
new file mode 100644
index 00000000..b558bc15
--- /dev/null
+++ b/examples/resources/raylib_logo.dds
Binary files differ
diff --git a/examples/resources/raylib_logo_uncompressed.dds b/examples/resources/raylib_logo_uncompressed.dds
new file mode 100644
index 00000000..2b40a205
--- /dev/null
+++ b/examples/resources/raylib_logo_uncompressed.dds
Binary files differ
diff --git a/examples/shapes_basic_shapes.c b/examples/shapes_basic_shapes.c
index 0e7298ac..655f996b 100644
--- a/examples/shapes_basic_shapes.c
+++ b/examples/shapes_basic_shapes.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 02b - Draw basic shapes 2d (rectangle, circle, line...)
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,7 +18,7 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib example 02b - basic shapes drawing");
+ InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
//--------------------------------------------------------------------------------------
// Main game loop
@@ -67,4 +67,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex02b_basic_shapes.png b/examples/shapes_basic_shapes.png
index 03ecf2ec..03ecf2ec 100644
--- a/examples/ex02b_basic_shapes.png
+++ b/examples/shapes_basic_shapes.png
Binary files differ
diff --git a/examples/shapes_color_palette.c b/examples/shapes_color_palette.c
index a8114e0f..ec39e642 100644
--- a/examples/shapes_color_palette.c
+++ b/examples/shapes_color_palette.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 02c - Draw raylib custom color palette
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,7 +18,7 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib example 02c - raylib color palette");
+ InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib color palette");
//--------------------------------------------------------------------------------------
// Main game loop
@@ -92,4 +92,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex02c_color_palette.png b/examples/shapes_colors_palette.png
index dd3cf4a5..dd3cf4a5 100644
--- a/examples/ex02c_color_palette.png
+++ b/examples/shapes_colors_palette.png
Binary files differ
diff --git a/examples/shapes_logo_raylib.c b/examples/shapes_logo_raylib.c
index bd13890f..669de4bd 100644
--- a/examples/shapes_logo_raylib.c
+++ b/examples/shapes_logo_raylib.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 02a - Draw raylib logo
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,7 +18,7 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib example 02a - raylib logo");
+ InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes");
//--------------------------------------------------------------------------------------
// Main game loop
@@ -37,7 +37,7 @@ int main()
DrawRectangle(screenWidth/2 - 128, screenHeight/2 - 128, 256, 256, BLACK);
DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112, 224, 224, RAYWHITE);
- DrawText("raylib", 356, 273, 50, BLACK);
+ DrawText("raylib", screenWidth/2 - 44, screenHeight/2 + 48, 50, BLACK);
DrawText("this is NOT a texture!", 350, 370, 10, GRAY);
@@ -51,4 +51,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex02a_logo_raylib.png b/examples/shapes_logo_raylib.png
index 6b385f7c..6b385f7c 100644
--- a/examples/ex02a_logo_raylib.png
+++ b/examples/shapes_logo_raylib.png
Binary files differ
diff --git a/examples/shapes_logo_raylib_anim.c b/examples/shapes_logo_raylib_anim.c
index 54e41eb9..830787c8 100644
--- a/examples/shapes_logo_raylib_anim.c
+++ b/examples/shapes_logo_raylib_anim.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 06b - raylib Logo Animation
+* raylib [shapes] example - raylib logo animation
*
-* This example has been created using raylib 1.0 (www.raylib.com)
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,6 +18,8 @@ int main()
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;
@@ -30,13 +32,12 @@ int main()
int bottomSideRecWidth = 16;
int rightSideRecHeight = 16;
- char raylib[8] = " "; // raylib text array, max 8 letters
+ char raylib[8] = " \0"; // raylib text array, max 8 letters
int state = 0; // Tracking animation states (State Machine)
-
+
float alpha = 1.0; // Useful for fading
-
- InitWindow(screenWidth, screenHeight, "raylib example 06b - raylib logo animation");
+
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@@ -115,10 +116,13 @@ int main()
bottomSideRecWidth = 16;
rightSideRecHeight = 16;
- for (int i = 0; i < 8; i++) raylib[i] = ' ';
+ for (int i = 0; i < 7; i++) raylib[i] = ' ';
+
+ raylib[7] = '\0'; // Last character is end-of-line
+
alpha = 1.0;
- state = 0; // Return to State 0
+ state = 0; // Return to State 0
}
}
//----------------------------------------------------------------------------------
@@ -148,10 +152,15 @@ int main()
}
else if (state == 3)
{
- DrawRectangle(logoPositionX, logoPositionY, 256, 256, Fade(BLACK, alpha));
+ 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(raylib, 356, 273, 50, Fade(BLACK, alpha));
+
+ DrawText(raylib, screenWidth/2 - 44, screenHeight/2 + 48, 50, Fade(BLACK, alpha));
}
else if (state == 4)
{
@@ -168,4 +177,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex06b_logo_anim.png b/examples/shapes_logo_raylib_anim.png
index 103dfc4a..103dfc4a 100644
--- a/examples/ex06b_logo_anim.png
+++ b/examples/shapes_logo_raylib_anim.png
Binary files differ
diff --git a/examples/text_font_select.c b/examples/text_font_select.c
index 5e58f15f..0ddda8ef 100644
--- a/examples/text_font_select.c
+++ b/examples/text_font_select.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 06c - Font selection...
+* raylib [text] example - Font selector
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,7 +18,7 @@ int main()
int screenWidth = 800;
int screenHeight = 150;
- InitWindow(screenWidth, screenHeight, "raylib example 06c - font selection");
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - font selector");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont fonts[8]; // SpriteFont array
@@ -52,7 +52,7 @@ int main()
int framesCounter = 0; // Useful to count frames button is 'active' = clicked
- SetTargetFPS(60);
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -141,4 +141,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex06c_font_select.png b/examples/text_font_select.png
index 27bf9432..27bf9432 100644
--- a/examples/ex06c_font_select.png
+++ b/examples/text_font_select.png
Binary files differ
diff --git a/examples/text_format_text.c b/examples/text_format_text.c
new file mode 100644
index 00000000..b9034b46
--- /dev/null
+++ b/examples/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 (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#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/text_format_text.png b/examples/text_format_text.png
new file mode 100644
index 00000000..cf9a1dda
--- /dev/null
+++ b/examples/text_format_text.png
Binary files differ
diff --git a/examples/text_rbmf_fonts.c b/examples/text_rbmf_fonts.c
index 1dbcdcc3..788e27b8 100644
--- a/examples/text_rbmf_fonts.c
+++ b/examples/text_rbmf_fonts.c
@@ -1,11 +1,14 @@
/*******************************************************************************************
*
-* raylib example 05b - raylib bitmap font (rbmf) loading and using
+* raylib [text] example - raylib bitmap font (rbmf) 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.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,17 +21,17 @@ int main()
int screenWidth = 560;
int screenHeight = 800;
- InitWindow(screenWidth, screenHeight, "raylib example 05b - rBMF fonts");
+ InitWindow(screenWidth, screenHeight, "raylib [text] example - rBMF fonts");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
- SpriteFont font1 = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading
- SpriteFont font2 = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading
- SpriteFont font3 = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading
- SpriteFont font4 = LoadSpriteFont("resources/fonts/setback.rbmf"); // SpriteFont loading
- SpriteFont font5 = LoadSpriteFont("resources/fonts/romulus.rbmf"); // SpriteFont loading
- SpriteFont font6 = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading
- SpriteFont font7 = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading
- SpriteFont font8 = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading
+ SpriteFont font1 = LoadSpriteFont("resources/fonts/alagard.rbmf"); // rBMF font loading
+ SpriteFont font2 = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // rBMF font loading
+ SpriteFont font3 = LoadSpriteFont("resources/fonts/mecha.rbmf"); // rBMF font loading
+ SpriteFont font4 = LoadSpriteFont("resources/fonts/setback.rbmf"); // rBMF font loading
+ SpriteFont font5 = LoadSpriteFont("resources/fonts/romulus.rbmf"); // rBMF font loading
+ SpriteFont font6 = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // rBMF font loading
+ SpriteFont font7 = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // rBMF font loading
+ SpriteFont font8 = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // rBMF font loading
//--------------------------------------------------------------------------------------
// Main game loop
@@ -73,4 +76,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex05b_rbmf_fonts.png b/examples/text_rbmf_fonts.png
index 58f6d83f..58f6d83f 100644
--- a/examples/ex05b_rbmf_fonts.png
+++ b/examples/text_rbmf_fonts.png
Binary files differ
diff --git a/examples/text_sprite_fonts.c b/examples/text_sprite_fonts.c
index 60a10c19..77273e4f 100644
--- a/examples/text_sprite_fonts.c
+++ b/examples/text_sprite_fonts.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 05a - SpriteFont loading and drawing some text with it
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -17,13 +17,13 @@ int main()
//--------------------------------------------------------------------------------------
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";
-
- InitWindow(screenWidth, screenHeight, "raylib example 05a - sprite fonts");
-
+
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
SpriteFont font1 = LoadSpriteFont("resources/fonts/custom_mecha.png"); // SpriteFont loading
SpriteFont font2 = LoadSpriteFont("resources/fonts/custom_alagard.png"); // SpriteFont loading
@@ -74,4 +74,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex05a_sprite_fonts.png b/examples/text_sprite_fonts.png
index 1bd4aa03..1bd4aa03 100644
--- a/examples/ex05a_sprite_fonts.png
+++ b/examples/text_sprite_fonts.png
Binary files differ
diff --git a/examples/textures_compressed_dds.c b/examples/textures_compressed_dds.c
new file mode 100644
index 00000000..d1d59f21
--- /dev/null
+++ b/examples/textures_compressed_dds.c
@@ -0,0 +1,64 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - DDS Texture loading and drawing (compressed and uncompressed)
+*
+* NOTE: This example requires raylib OpenGL 3.3+ or ES2 versions for compressed texture,
+* OpenGL 1.1 does not support compressed textures, only uncompressed version.
+*
+* This example has been created using raylib 1.2 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] example - DDS texture loading and drawing");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+ //Texture2D texture = LoadTexture("resources/raylib_logo.dds"); // Texture loading (compressed)
+ Texture2D texture = LoadTexture("resources/raylib_logo_uncompressed.dds"); // Texture loading (uncompressed)
+
+ 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);
+
+ DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
+
+ DrawText("this may be a compressed texture!", 320, 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/textures_compressed_dds.png b/examples/textures_compressed_dds.png
new file mode 100644
index 00000000..89922bae
--- /dev/null
+++ b/examples/textures_compressed_dds.png
Binary files differ
diff --git a/examples/textures_image_loading.c b/examples/textures_image_loading.c
new file mode 100644
index 00000000..c2929d9c
--- /dev/null
+++ b/examples/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.1 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#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 img = LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM)
+ Texture2D texture = CreateTexture(img, false); // Image converted to texture, GPU memory (VRAM)
+
+ UnloadImage(img); // 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/textures_image_loading.png b/examples/textures_image_loading.png
new file mode 100644
index 00000000..410103a5
--- /dev/null
+++ b/examples/textures_image_loading.png
Binary files differ
diff --git a/examples/textures_logo_raylib.c b/examples/textures_logo_raylib.c
index 60604594..23ee75ad 100644
--- a/examples/textures_logo_raylib.c
+++ b/examples/textures_logo_raylib.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 04a - Texture loading and drawing
+* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,7 +18,7 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib example 04a - texture loading and drawing");
+ 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
@@ -55,4 +55,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex04a_textures.png b/examples/textures_logo_raylib.png
index c18bf880..c18bf880 100644
--- a/examples/ex04a_textures.png
+++ b/examples/textures_logo_raylib.png
Binary files differ
diff --git a/examples/textures_mipmaps.c b/examples/textures_mipmaps.c
new file mode 100644
index 00000000..889303a4
--- /dev/null
+++ b/examples/textures_mipmaps.c
@@ -0,0 +1,66 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Texture loading with mipmaps, mipmaps generation
+*
+* NOTE: On OpenGL 1.1, mipmaps are calculated 'manually', original image must be power-of-two
+* On OpenGL 3.3 and ES2, mipmaps are generated automatically
+*
+* 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 (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture mipmaps generation");
+
+ // NOTE: To generate mipmaps for an image, image must be loaded first and converted to texture
+ // with mipmaps option set to true on CreateTexture()
+
+ Image image = LoadImage("resources/raylib_logo.png"); // Load image to CPU memory (RAM)
+ Texture2D texture = CreateTexture(image, true); // Create texture and generate mipmaps
+
+ UnloadImage(image); // Once texture has been created, we can unload image data 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 - 30, WHITE);
+
+ DrawText("this IS a texture with mipmaps! really!", 210, 360, 20, 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/textures_mipmaps.png b/examples/textures_mipmaps.png
new file mode 100644
index 00000000..d8f2448c
--- /dev/null
+++ b/examples/textures_mipmaps.png
Binary files differ
diff --git a/examples/textures_rectangle.c b/examples/textures_rectangle.c
index 5836e7a9..95caf0a4 100644
--- a/examples/textures_rectangle.c
+++ b/examples/textures_rectangle.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 04b - Texture loading and drawing a part defined by a rectangle
+* raylib [textures] example - Texture loading and drawing a part defined by a rectangle
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -17,21 +17,17 @@ int main()
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle");
const char textLine1[] = "Lena image is a standard test image which has been in use since 1973.";
- const char textLine2[] = "It comprises 512x512 pixels, and was originally cropped from the centerfold";
- const char textLine3[] = "of November 1972 issue of Playboy magazine. The image is probably the most";
- const char textLine4[] = "widely used test image for all sorts of image processing algorithms.";
+ const char textLine2[] = "It comprises 512x512 pixels, and it is probably the most widely used";
+ const char textLine3[] = "test image for all sorts of image processing algorithms.";
- InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle");
-
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D texture = LoadTexture("resources/lena.png"); // Texture loading
- Color halfTrans = WHITE;
- halfTrans.a = 30;
-
- Rectangle eyesRec = { 225, 240, 155, 50 };
+ Rectangle eyesRec = { 225, 240, 155, 50 }; // Part of the texture to draw
Vector2 position = { 369, 241 };
//--------------------------------------------------------------------------------------
@@ -51,14 +47,13 @@ int main()
DrawText("LENA", 220, 100, 20, PINK);
- DrawTexture(texture, screenWidth/2 - 256, 0, halfTrans); // Draw background image
+ DrawTexture(texture, screenWidth/2 - 256, 0, Fade(WHITE, 0.1f)); // Draw background image
DrawTextureRec(texture, eyesRec, position, WHITE); // Draw eyes part of image
DrawText(textLine1, 220, 140, 10, DARKGRAY);
DrawText(textLine2, 220, 160, 10, DARKGRAY);
DrawText(textLine3, 220, 180, 10, DARKGRAY);
- DrawText(textLine4, 220, 200, 10, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
@@ -72,4 +67,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file
diff --git a/examples/ex04b_texture_rectangle.png b/examples/textures_rectangle.png
index ff206365..ff206365 100644
--- a/examples/ex04b_texture_rectangle.png
+++ b/examples/textures_rectangle.png
Binary files differ
diff --git a/examples/textures_srcrec_dstrec.c b/examples/textures_srcrec_dstrec.c
new file mode 100644
index 00000000..27d9610e
--- /dev/null
+++ b/examples/textures_srcrec_dstrec.c
@@ -0,0 +1,68 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Texture source and destination rectangles
+*
+* 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 (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#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 texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
+
+ // NOTE: Source rectangle (part of the texture to use for drawing)
+ Rectangle sourceRec = { 128, 128, 128, 128 };
+
+ // NOTE: Destination rectangle (screen rectangle where drawing part of texture)
+ Rectangle destRec = { screenWidth/2, screenHeight/2, 256, 256 };
+
+ // NOTE: Origin of the texture in case of rotation, it's relative to destination rectangle size
+ Vector2 origin = { 128, 128 };
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update your variables here
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ // NOTE: Using DrawTexturePro() we can easily rotate and scale the part of the texture we draw
+ DrawTexturePro(texture, sourceRec, destRec, origin, 45, LIGHTGRAY);
+
+ DrawLine(destRec.x, 0, destRec.x, screenHeight, RED);
+ DrawLine(0, destRec.y, screenWidth, destRec.y, RED);
+
+ 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/textures_srcrec_dstrec.png b/examples/textures_srcrec_dstrec.png
new file mode 100644
index 00000000..95b7130e
--- /dev/null
+++ b/examples/textures_srcrec_dstrec.png
Binary files differ