Examples renaming and test examples merge
Examples have been renamed for coherence with raylib modules and test examples have been merged into examples folder.
|
@ -1,10 +1,10 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Music playing (streaming)
|
||||
* raylib [audio] example - Music playing (streaming)
|
||||
*
|
||||
* NOTE: This test requires OpenAL32 dll installed (or in the same folder)
|
||||
* NOTE: This example requires OpenAL Soft library installed
|
||||
*
|
||||
* This test has been created using raylib 1.1 (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) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
|
@ -20,18 +20,17 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - music playing (streaming)");
|
||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
|
||||
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
PlayMusicStream("resources/audio/deserve_to_be_loved.ogg"); // Load Music file
|
||||
PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream
|
||||
|
||||
int framesCounter = 0;
|
||||
float volume = 1.0;
|
||||
|
||||
float timePlayed = 0;
|
||||
|
||||
SetTargetFPS(60);
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@ -41,17 +40,19 @@ int main()
|
|||
//----------------------------------------------------------------------------------
|
||||
framesCounter++;
|
||||
|
||||
// Testing music fading
|
||||
// Testing music fading from one file to another
|
||||
/*
|
||||
if (framesCounter > 600)
|
||||
if (framesCounter > 600) // Wait for 10 seconds (600 frames)
|
||||
{
|
||||
volume -= 0.01;
|
||||
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 = -600;
|
||||
PlayMusicStream("resources/audio/destiny.ogg");
|
||||
framesCounter = 0;
|
||||
PlayMusicStream("resources/audio/another_file.ogg");
|
||||
}
|
||||
|
||||
SetMusicVolume(volume);
|
BIN
examples/audio_music_stream.png
Normal file
After Width: | Height: | Size: 15 KiB |
|
@ -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
|
||||
|
||||
|
|
BIN
examples/audio_sound_loading.png
Normal file
After Width: | Height: | Size: 15 KiB |
|
@ -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);
|
||||
|
||||
|
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
@ -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
|
||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
@ -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)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -18,28 +18,28 @@ 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
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
@ -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,10 +21,10 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
|
||||
Vector2 gamepadMove = { 0, 0 };
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input");
|
||||
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
|
||||
Vector2 gamepadMovement = { 0, 0 };
|
||||
|
||||
SetTargetFPS(60); // Set target frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -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))
|
||||
{
|
||||
|
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
@ -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,9 +18,9 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input");
|
||||
Vector2 ballPosition = { screenWidth/2, screenHeight/2 };
|
||||
|
||||
SetTargetFPS(60); // Set target frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
@ -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
|
||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Texture loading with mipmaps, mipmaps generation
|
||||
* 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)
|
||||
|
@ -18,14 +18,12 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - texture mipmaps");
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel");
|
||||
|
||||
Image image = LoadImage("resources/raylib_logo.png");
|
||||
Texture2D texture = CreateTexture(image, true);
|
||||
|
||||
// NOTE: With OpenGL 3.3 mipmaps generation works great (automatic generation)
|
||||
// NOTE: With OpenGL 1.1 mipmaps generation works great too! (manual generation)
|
||||
int boxPositionY = screenHeight/2 - 40;
|
||||
int scrollSpeed = 4; // Scrolling speed in pixels
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@ -33,7 +31,7 @@ int main()
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
boxPositionY -= (GetMouseWheelMove()*scrollSpeed);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
@ -42,7 +40,10 @@ int main()
|
|||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawTexture(texture, 0, 0, WHITE);
|
||||
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();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -50,8 +51,6 @@ int main()
|
|||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Texture unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
BIN
examples/core_mouse_wheel.png
Normal file
After Width: | Height: | Size: 15 KiB |
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Testing GetRandomValue()
|
||||
* raylib [core] example - Generate random values
|
||||
*
|
||||
* 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,13 +18,13 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
int framesCounter = 0;
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values");
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - Random numbers");
|
||||
int framesCounter = 0; // Variable used to count frames
|
||||
|
||||
int randValue = GetRandomValue(-8,5);
|
||||
int randValue = GetRandomValue(-8,5); // Get a random integer number between -8 and 5 (both included)
|
||||
|
||||
SetTargetFPS(60);
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@ -34,7 +34,8 @@ int main()
|
|||
//----------------------------------------------------------------------------------
|
||||
framesCounter++;
|
||||
|
||||
if ((framesCounter/60)%2)
|
||||
// Every two seconds (120 frames) a new random value is generated
|
||||
if (((framesCounter/120)%2) == 1)
|
||||
{
|
||||
randValue = GetRandomValue(-8,5);
|
||||
framesCounter = 0;
|
||||
|
@ -47,7 +48,9 @@ int main()
|
|||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText(FormatText("%i", randValue), 120, 120, 60, LIGHTGRAY);
|
||||
DrawText("Every 2 seconds a new random value is generated:", 130, 100, 20, MAROON);
|
||||
|
||||
DrawText(FormatText("%i", randValue), 360, 180, 80, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
BIN
examples/core_random_values.png
Normal file
After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 3.5 KiB |
|
@ -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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Testing DrawBillboard() and DrawBillboardRec()
|
||||
* raylib [models] example - Drawing billboards
|
||||
*
|
||||
* This test has been created using raylib 1.0 (www.raylib.com)
|
||||
* 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)
|
||||
|
@ -18,19 +18,16 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 };
|
||||
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 }};
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - Billboards");
|
||||
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
|
||||
|
||||
Texture2D texture = LoadTexture("resources/raylib_logo.png");
|
||||
Texture2D lena = LoadTexture("resources/lena.png");
|
||||
|
||||
Rectangle eyesRec = { 225, 240, 155, 50 };
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@ -52,8 +49,8 @@ int main()
|
|||
|
||||
Begin3dMode(camera);
|
||||
|
||||
//DrawBillboard(camera, texture, position, 2.0, WHITE);
|
||||
DrawBillboardRec(camera, lena, eyesRec, position, 4.0, WHITE);
|
||||
//DrawBillboard(camera, lena, billPosition, 1.0, WHITE);
|
||||
DrawBillboardRec(camera, lena, eyesRec, billPosition, 4.0, WHITE);
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
|
||||
|
@ -67,7 +64,6 @@ int main()
|
|||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadTexture(lena); // Unload texture
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
|
@ -1,15 +1,15 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Testing Heightmap Loading and Drawing
|
||||
* raylib [models] example - Cubesmap loading and drawing
|
||||
*
|
||||
* This test has been created using raylib 1.0 (www.raylib.com)
|
||||
* 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"
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -18,19 +18,18 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector3 position = { 0.5, 0.0, 0.5 };
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 7.0, 6.0, 7.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
Camera camera = {{ 7.0, 7.0, 7.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - Heightmap loading and drawing");
|
||||
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
|
||||
|
||||
Image img = LoadImage("resources/cubesmap.png");
|
||||
Model map = LoadCubesmap(img);
|
||||
Texture2D texture = CreateTexture(img, false);
|
||||
UnloadImage(img);
|
||||
|
||||
SetModelTexture(&map, texture);
|
||||
UnloadImage(img); // Unload cubesmap image from RAM, already uploaded to VRAM
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -55,13 +54,11 @@ int main()
|
|||
|
||||
Begin3dMode(camera);
|
||||
|
||||
//DrawCube(position, 1.0f, 1.0f, 1.0f, RED);
|
||||
DrawModel(map, mapPosition, 1.0f, MAROON);
|
||||
|
||||
DrawModel(map, position, 1.0f, MAROON);
|
||||
DrawGrid(10.0, 1.0);
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
|
||||
DrawGizmo(position);
|
||||
DrawGizmo(mapPosition);
|
||||
|
||||
End3dMode();
|
||||
|
BIN
examples/models_cubesmap.png
Normal file
After Width: | Height: | Size: 27 KiB |
|
@ -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
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
BIN
examples/models_geometric_shapes.png
Normal file
After Width: | Height: | Size: 33 KiB |
|
@ -1,8 +1,8 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Load and draw a 3d model (OBJ)
|
||||
* raylib [models] example - Heightmap loading and drawing
|
||||
*
|
||||
* This test has been created using raylib 1.1 (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) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
|
@ -18,17 +18,18 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 };
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
||||
|
||||
// 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 }};
|
||||
Camera camera = {{ 10.0, 12.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - 3d models in OpenGL 3.3+");
|
||||
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
|
||||
|
||||
Texture2D texture = LoadTexture("resources/catwhite.png");
|
||||
Model cat = LoadModel("resources/cat.obj");
|
||||
|
||||
SetModelTexture(&cat, texture);
|
||||
UnloadImage(img); // Unload heightmap image from RAM, already uploaded to VRAM
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -38,10 +39,7 @@ 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;
|
||||
// ...
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
@ -52,12 +50,11 @@ int main()
|
|||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawModel(cat, position, 0.1f, BEIGE); // OK_GL11, OK_GL33
|
||||
//DrawModelWires(cat, position, 0.1f, RED); // OK_GL11, OK_GL33
|
||||
DrawModel(map, mapPosition, 0.5f, MAROON);
|
||||
|
||||
DrawGrid(10.0, 1.0); // Draw a grid
|
||||
DrawGrid(10.0, 1.0);
|
||||
|
||||
DrawGizmo(position);
|
||||
DrawGizmo(mapPosition);
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
@ -70,7 +67,7 @@ int main()
|
|||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(cat); // Unload model
|
||||
UnloadModel(map); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
BIN
examples/models_heightmap.png
Normal file
After Width: | Height: | Size: 31 KiB |
|
@ -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");
|
||||
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
|
||||
|
||||
Texture2D texture = LoadTexture("resources/catsham.png");
|
||||
Model cat = LoadModel("resources/cat.obj");
|
||||
SetModelTexture(&cat, texture); // Link texture to model
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// 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();
|
||||
|
||||
|
|
BIN
examples/models_obj_models.png
Normal file
After Width: | Height: | Size: 60 KiB |
|
@ -1,8 +1,8 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Testing Heightmap Loading and Drawing
|
||||
* raylib [models] example - Draw 3d planes
|
||||
*
|
||||
* This test has been created using raylib 1.0 (www.raylib.com)
|
||||
* 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)
|
||||
|
@ -18,19 +18,10 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
Vector3 position = { 0.0, 0.0, 0.0 };
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d planes");
|
||||
|
||||
// Define the camera to look into our 3d world
|
||||
Camera camera = {{ 12.0, 10.0, 12.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - Heightmap loading and drawing");
|
||||
|
||||
Image img = LoadImage("resources/heightmap.png");
|
||||
Model map = LoadHeightmap(img, 4);
|
||||
Texture2D texture = CreateTexture(img, false);
|
||||
UnloadImage(img);
|
||||
|
||||
SetModelTexture(&map, texture);
|
||||
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
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -40,7 +31,7 @@ int main()
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// ...
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
@ -51,11 +42,10 @@ int main()
|
|||
|
||||
Begin3dMode(camera);
|
||||
|
||||
DrawModel(map, position, 0.5f, MAROON);
|
||||
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); // Draw a grid
|
||||
|
||||
DrawGizmo(position);
|
||||
DrawGrid(10.0, 1.0);
|
||||
|
||||
End3dMode();
|
||||
|
||||
|
@ -67,9 +57,6 @@ int main()
|
|||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Unload texture
|
||||
UnloadModel(map); // Unload model
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
BIN
examples/openal32.dll
Normal file
BIN
examples/resources/audio/guitar_noodling.ogg
Normal file
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.7 KiB |
BIN
examples/resources/raylib_logo.dds
Normal file
BIN
examples/resources/raylib_logo_uncompressed.dds
Normal 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
|
||||
|
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
@ -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
|
||||
|
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
@ -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);
|
||||
|
||||
|
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
@ -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,7 +116,10 @@ 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
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
@ -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
|
||||
|
|
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Testing FormatText() function
|
||||
* raylib [text] example - Text formatting
|
||||
*
|
||||
* This test 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,12 +18,12 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting");
|
||||
|
||||
int score = 100020;
|
||||
int hiscore = 200450;
|
||||
int lives = 5;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - FormatText()");
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -41,13 +41,13 @@ int main()
|
|||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText(FormatText("Score: %08i", score), 80, 80, 20, RED);
|
||||
DrawText(FormatText("Score: %08i", score), 200, 80, 20, RED);
|
||||
|
||||
DrawText(FormatText("HiScore: %08i", hiscore), 80, 120, 20, GREEN);
|
||||
DrawText(FormatText("HiScore: %08i", hiscore), 200, 120, 20, GREEN);
|
||||
|
||||
DrawText(FormatText("Lives: %02i", lives), 80, 160, 40, BLUE);
|
||||
DrawText(FormatText("Lives: %02i", lives), 200, 160, 40, BLUE);
|
||||
|
||||
DrawText(FormatText("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 80, 220, 20, BLACK);
|
||||
DrawText(FormatText("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 200, 220, 20, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
BIN
examples/text_format_text.png
Normal file
After Width: | Height: | Size: 15 KiB |
|
@ -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
|
||||
|
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
@ -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)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -18,12 +18,12 @@ 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
|
||||
|
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
@ -1,8 +1,11 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - DDS Texture loading and drawing (compressed and uncompressed)
|
||||
* raylib [textures] example - DDS Texture loading and drawing (compressed and uncompressed)
|
||||
*
|
||||
* This test has been created using raylib 1.1 (www.raylib.com)
|
||||
* 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)
|
||||
|
@ -18,18 +21,13 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - DDS texture loading and drawing");
|
||||
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
|
||||
//Texture2D texture = LoadTexture("resources/raylib_logo_uncompressed.dds"); // Texture loading
|
||||
//Texture2D texture = LoadTexture("resources/raylib_logo.dds"); // Texture loading (compressed)
|
||||
Texture2D texture = LoadTexture("resources/raylib_logo_uncompressed.dds"); // Texture loading (uncompressed)
|
||||
|
||||
Image image = LoadImage("resources/raylib_logo_uncompressed.dds");
|
||||
Texture2D texture = CreateTexture(image, false);
|
||||
|
||||
// NOTE: With OpenGL 3.3 mipmaps generation works great
|
||||
|
||||
SetTargetFPS(60);
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
|
@ -49,7 +47,7 @@ int main()
|
|||
|
||||
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
|
||||
|
||||
DrawText("this IS a texture!", 360, 370, 10, GRAY);
|
||||
DrawText("this may be a compressed texture!", 320, 370, 10, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -57,7 +55,7 @@ int main()
|
|||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
//UnloadTexture(texture); // Texture unloading
|
||||
UnloadTexture(texture); // Texture unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
BIN
examples/textures_compressed_dds.png
Normal file
After Width: | Height: | Size: 15 KiB |
|
@ -1,11 +1,13 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Testing LoadImage() and CreateTexture()
|
||||
* raylib [textures] example - Image loading and texture creation
|
||||
*
|
||||
* This test has been created using raylib 1.0 (www.raylib.com)
|
||||
* 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) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -18,13 +20,14 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - Image loading");
|
||||
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");
|
||||
Texture2D texture = CreateTexture(img, false);
|
||||
UnloadImage(img);
|
||||
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
|
||||
|
@ -43,7 +46,7 @@ int main()
|
|||
|
||||
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
|
||||
|
||||
DrawText("this IS a texture!", 360, 370, 10, GRAY);
|
||||
DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
BIN
examples/textures_image_loading.png
Normal file
After Width: | Height: | Size: 17 KiB |
|
@ -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
|
||||
|
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
66
examples/textures_mipmaps.c
Normal 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;
|
||||
}
|
BIN
examples/textures_mipmaps.png
Normal file
After Width: | Height: | Size: 17 KiB |
|
@ -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)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
|
@ -18,20 +18,16 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
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.";
|
||||
InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle");
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib example 04b - 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 it is probably the most widely used";
|
||||
const char textLine3[] = "test image for all sorts of image processing algorithms.";
|
||||
|
||||
// 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();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
@ -1,8 +1,8 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Texture loading and drawing with pro parameters (rotation, origin, scale...)
|
||||
* raylib [textures] example - Texture source and destination rectangles
|
||||
*
|
||||
* This test has been created using raylib 1.1 (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) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||
|
@ -18,16 +18,19 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - texture pro");
|
||||
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
|
||||
|
||||
Vector2 position = { 200, 100 };
|
||||
|
||||
// NOTE: Source rectangle (part of the texture to use for drawing)
|
||||
Rectangle sourceRec = { 128, 128, 128, 128 };
|
||||
Rectangle destRec = { 128, 128, 128, 128 };
|
||||
Vector2 origin = { 64, 64 }; // NOTE: origin is relative to destRec size
|
||||
|
||||
// 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
|
||||
|
@ -44,9 +47,8 @@ int main()
|
|||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
//DrawTextureEx(texture, position, 45, 1, MAROON);
|
||||
|
||||
DrawTexturePro(texture, sourceRec, destRec, origin, 45, GREEN);
|
||||
// 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);
|
BIN
examples/textures_srcrec_dstrec.png
Normal file
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 308 KiB |
Before Width: | Height: | Size: 302 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.7 KiB |
|
@ -1,57 +0,0 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - Testing GetMouseWheelMove()
|
||||
*
|
||||
* This test 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)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib test - Mouse wheel");
|
||||
|
||||
int positionY = 0;
|
||||
int scrollSpeed = 4; // Scrolling speed in pixels
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
positionY -= (GetMouseWheelMove()*scrollSpeed);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawRectangle(200, positionY, 80, 80, MAROON);
|
||||
|
||||
DrawText(FormatText("%i", positionY), 10, 10, 20, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib test - OGG audio loading and playing
|
||||
*
|
||||
* NOTE: This test requires OpenAL32 dll installed (or in the same folder)
|
||||
*
|
||||
* 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 test - ogg audio loading and playing");
|
||||
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
Sound fx = LoadSound("resources/audio/0564.ogg"); // Load audio file
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KEY_SPACE)) PlaySound(fx); // Play the sound!
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("Press SPACE to PLAY the SOUND!", 240, 200, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadSound(fx); // Unload sound data
|
||||
|
||||
CloseAudioDevice(); // Close audio device
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|