Examples renaming and test examples merge

Examples have been renamed for coherence with raylib modules and test
examples have been merged into examples folder.
This commit is contained in:
raysan5 2014-09-21 14:26:42 +02:00
parent 3a0d164a76
commit 5ecb6801fa
84 changed files with 505 additions and 5229 deletions

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

@ -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;
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
Vector2 gamepadMove = { 0, 0 };
InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input");
SetTargetFPS(60); // Set target frames-per-second
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;
}
}

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -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
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile example 01 - basic window
ex02c_color_palette: ex02c_color_palette.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile example 01 - basic window
ex03a_input_keys: ex03a_input_keys.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 - mouse input
core_input_mouse: core_input_mouse.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 - gamepad input
core_input_gamepad: core_input_gamepad.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
endif
# compile example 01 - basic window
ex04a_textures: ex04a_textures.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
ex04b_texture_rectangle: ex04b_texture_rectangle.c
# compile [core] example - generate random values
core_random_values: core_random_values.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile example 01 - basic window
ex05a_sprite_fonts: ex05a_sprite_fonts.c
# compile [core] example - color selection (collision detection)
core_color_select: core_color_select.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile example 01 - basic window
ex05b_rbmf_fonts: ex05b_rbmf_fonts.c
# compile [core] example - 3d mode
core_3d_mode: core_3d_mode.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile example 01 - basic window
ex06a_color_select: ex06a_color_select.c
# 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 example 01 - basic window
ex06b_logo_anim: ex06b_logo_anim.c
# 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 example 01 - basic window
ex06b_shape_select: ex06b_shape_select.c
# compile [shapes] example - raylib color palette
shapes_color_palette: shapes_color_palette.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile example 01 - basic window
ex06c_font_select: ex06c_font_select.c
# 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 example 01 - basic window
ex07a_3d_mode: ex07a_3d_mode.c
# compile [textures] example - raylib logo texture loading
textures_logo_raylib: textures_logo_raylib.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile example 01 - basic window
ex07b_3d_shapes: ex07b_3d_shapes.c
# 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 example 01 - basic window
ex07c_3d_models: ex07c_3d_models.c
# compile [textures] example - texture rectangle drawing
textures_rectangle: textures_rectangle.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile example 01 - basic window
ex08_audio: ex08_audio.c
# 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 [text] example - raylib bitmap fonts (rBMF)
text_rbmf_fonts: text_rbmf_fonts.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - text formatting
text_format_text: text_format_text.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [text] example - font selection program
text_font_select: text_font_select.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - basic geometric 3d shapes
models_geometric_shapes: models_geometric_shapes.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - basic window
models_planes: models_planes.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - billboard usage
models_billboard: models_billboard.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - OBJ model loading
models_obj_loading: models_obj_loading.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - heightmap loading
models_heightmap: models_heightmap.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# compile [models] example - cubesmap loading
models_cubesmap: models_cubesmap.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# 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 [audio] example - music stream playing (OGG)
audio_music_stream: audio_music_stream.c
$(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
# clean everything

View file

@ -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;
}

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View file

@ -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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

64
examples/models_planes.c Normal file
View file

@ -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;
}

BIN
examples/openal32.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Binary file not shown.

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before After
Before After

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -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;
}
}

View file

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Before After
Before After

View file

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB