From 6ac5d3bc06913469f6e32f68a4c356e1c1da24b8 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 28 Aug 2015 14:14:52 +0200 Subject: Remove file --- examples/openal32.dll | Bin 402553 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/openal32.dll (limited to 'examples') diff --git a/examples/openal32.dll b/examples/openal32.dll deleted file mode 100644 index 71ced6a2..00000000 Binary files a/examples/openal32.dll and /dev/null differ -- cgit v1.2.3 From ca402e9d360d519e37e2fb1d8073ebec56b0014c Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 28 Aug 2015 14:16:28 +0200 Subject: New examples added (with some resources) --- examples/core_3d_camera_free.c | 75 ++++++++++++++++++++++++++++++++++ examples/core_3d_camera_free.png | Bin 0 -> 25106 bytes examples/core_3d_picking.c | 31 +++++++++----- examples/core_3d_picking.png | Bin 0 -> 23100 bytes examples/models_cubicmap.c | 42 +++++++++++-------- examples/models_cubicmap.png | Bin 27438 -> 412536 bytes examples/models_heightmap.c | 29 +++++++------ examples/models_heightmap.png | Bin 31972 -> 123602 bytes examples/models_obj_loading.c | 2 +- examples/models_obj_loading.png | Bin 61860 -> 127720 bytes examples/resources/cubicmap.png | Bin 173 -> 201 bytes examples/resources/cubicmap_atlas.png | Bin 0 -> 37225 bytes examples/resources/guybrush.png | Bin 0 -> 85247 bytes examples/resources/heightmap.png | Bin 1362 -> 10920 bytes examples/text_font_select.png | Bin 3097 -> 16261 bytes examples/text_format_text.c | 2 +- examples/text_rbmf_fonts.c | 2 +- examples/text_rbmf_fonts.png | Bin 14877 -> 19458 bytes examples/textures_rectangle.c | 46 ++++++++++++--------- examples/textures_rectangle.png | Bin 76980 -> 109993 bytes examples/textures_srcrec_dstrec.c | 31 ++++++++------ examples/textures_srcrec_dstrec.png | Bin 19183 -> 48478 bytes 22 files changed, 184 insertions(+), 76 deletions(-) create mode 100644 examples/core_3d_camera_free.c create mode 100644 examples/core_3d_camera_free.png create mode 100644 examples/core_3d_picking.png create mode 100644 examples/resources/cubicmap_atlas.png create mode 100644 examples/resources/guybrush.png (limited to 'examples') diff --git a/examples/core_3d_camera_free.c b/examples/core_3d_camera_free.c new file mode 100644 index 00000000..9e123b04 --- /dev/null +++ b/examples/core_3d_camera_free.c @@ -0,0 +1,75 @@ +/******************************************************************************************* +* +* raylib [core] example - Initialize 3d camera free +* +* This example has been created using raylib 1.3 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); + + // Define the camera to look into our 3d world + Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + + Vector3 cubePosition = { 0.0, 0.0, 0.0 }; + + SetCameraMode(CAMERA_FREE); // Set a free camera mode + SetCameraPosition(camera.position); // Set internal camera position to match our camera position + SetCameraTarget(camera.target); // Set internal camera target to match our camera target + + 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 + //---------------------------------------------------------------------------------- + camera = UpdateCamera(0); // Update internal camera and our camera + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(WHITE); + + Begin3dMode(camera); + + DrawCube(cubePosition, 2, 2, 2, RED); + DrawCubeWires(cubePosition, 2, 2, 2, MAROON); + + DrawGrid(10.0, 1.0); + + End3dMode(); + + DrawText("Free camera default controls:", 20, 20, 10, GRAY); + DrawText("- Mouse Wheel to Zoom in-out", 40, 50, 10, DARKGRAY); + DrawText("- Mouse Wheel Pressed to Pan", 40, 70, 10, DARKGRAY); + DrawText("- Alt + Mouse Wheel Pressed to Rotate", 40, 90, 10, DARKGRAY); + DrawText("- Alt + Ctrl + Mouse Wheel Pressed for Smooth Zoom", 40, 110, 10, DARKGRAY); + DrawText("- Z to zoom to (0, 0, 0)", 40, 130, 10, DARKGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/core_3d_camera_free.png b/examples/core_3d_camera_free.png new file mode 100644 index 00000000..afb5a7c5 Binary files /dev/null and b/examples/core_3d_camera_free.png differ diff --git a/examples/core_3d_picking.c b/examples/core_3d_picking.c index a7a96fa9..056dcd65 100644 --- a/examples/core_3d_picking.c +++ b/examples/core_3d_picking.c @@ -2,7 +2,7 @@ * * raylib [core] example - Picking in 3d mode * -* This example has been created using raylib 1.0 (www.raylib.com) +* This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) @@ -23,23 +23,30 @@ int main() // 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 }}; - Vector3 cubePosition = { 0.0, 0.0, 0.0 }; + Vector3 cubePosition = { 0.0, 1.0, 0.0 }; - Ray pickingLine; + Ray ray; // Picking line ray - SetCameraMode(CAMERA_FREE); + SetCameraMode(CAMERA_FREE); // Set a free camera mode + SetCameraPosition(camera.position); // Set internal camera position to match our camera position - SetTargetFPS(60); + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- - camera = UpdateCamera(0); + camera = UpdateCamera(0); // Update internal camera and our camera - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pickingLine = GetMouseRay(GetMousePosition(), camera); + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + { + // NOTE: This function is NOT WORKING properly! + ray = GetMouseRay(GetMousePosition(), camera); + + // TODO: Check collision between ray and box + } //---------------------------------------------------------------------------------- // Draw @@ -50,14 +57,16 @@ int main() Begin3dMode(camera); - DrawCube(cubePosition, 2, 2, 2, RED); - DrawCubeWires(cubePosition, 2, 2, 2, MAROON); + DrawCube(cubePosition, 2, 2, 2, GRAY); + DrawCubeWires(cubePosition, 2, 2, 2, DARKGRAY); DrawGrid(10.0, 1.0); - DrawRay(pickingLine, MAROON); + DrawRay(ray, MAROON); End3dMode(); + + DrawText("Try selecting the box with mouse!", 240, 10, 20, GRAY); DrawFPS(10, 10); diff --git a/examples/core_3d_picking.png b/examples/core_3d_picking.png new file mode 100644 index 00000000..828c41a8 Binary files /dev/null and b/examples/core_3d_picking.png differ diff --git a/examples/models_cubicmap.c b/examples/models_cubicmap.c index 62f7b076..e1f2e7df 100644 --- a/examples/models_cubicmap.c +++ b/examples/models_cubicmap.c @@ -2,7 +2,7 @@ * * raylib [models] example - Cubicmap loading and drawing * -* This example has been created using raylib 1.2 (www.raylib.com) +* This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) @@ -21,15 +21,22 @@ int main() 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 }}; + Camera camera = {{ 16.0, 14.0, 16.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; - Image image = LoadImage("resources/cubicmap.png"); // Load cubesmap image (RAM) - Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) + Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) + Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM) Model map = LoadCubicmap(image); // Load cubicmap model (generate model from image) - SetModelTexture(&map, texture); // Bind texture to model - Vector3 mapPosition = { -1, 0.0, -1 }; // Set model position + + // NOTE: By default each cube is mapped to one part of texture atlas + Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture + SetModelTexture(&map, texture); // Bind texture to map model + + Vector3 mapPosition = { -16, 0.0, -8 }; // Set model position UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM + + SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode + SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -39,11 +46,7 @@ int main() { // 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; + camera = UpdateCamera(0); // Update internal camera and our camera //---------------------------------------------------------------------------------- // Draw @@ -54,13 +57,15 @@ int main() Begin3dMode(camera); - DrawModel(map, mapPosition, 1.0f, MAROON); - - DrawGrid(10.0, 1.0); - - DrawGizmo(mapPosition); + DrawModel(map, mapPosition, 1.0f, WHITE); End3dMode(); + + DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE); + DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); + + DrawText("cubicmap image used to", 658, 90, 10, GRAY); + DrawText("generate map 3d model", 658, 104, 10, GRAY); DrawFPS(10, 10); @@ -70,8 +75,9 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Unload texture - UnloadModel(map); // Unload model + UnloadTexture(cubicmap); // Unload cubicmap texture + UnloadTexture(texture); // Unload map texture + UnloadModel(map); // Unload map model CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/models_cubicmap.png b/examples/models_cubicmap.png index f686ba21..9cb854cb 100644 Binary files a/examples/models_cubicmap.png and b/examples/models_cubicmap.png differ diff --git a/examples/models_heightmap.c b/examples/models_heightmap.c index a23656a5..297ada32 100644 --- a/examples/models_heightmap.c +++ b/examples/models_heightmap.c @@ -2,10 +2,10 @@ * * raylib [models] example - Heightmap loading and drawing * -* This example has been created using raylib 1.1 (www.raylib.com) +* This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -20,16 +20,19 @@ int main() 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 }}; + // Define our custom camera to look into our 3d world + Camera camera = {{ 24.0, 18.0, 24.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) - Model map = LoadHeightmap(image, 4); // Load heightmap model + Model map = LoadHeightmap(image, 32); // Load heightmap model SetModelTexture(&map, texture); // Bind texture to model - Vector3 mapPosition = { -4, 0.0, -4 }; // Set model position + Vector3 mapPosition = { -16, 0.0, -16 }; // Set model position (depends on model scaling!) - UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM + UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM + + SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode + SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -39,7 +42,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - // ... + camera = UpdateCamera(0); // Update internal camera and our camera //---------------------------------------------------------------------------------- // Draw @@ -50,13 +53,13 @@ int main() Begin3dMode(camera); - DrawModel(map, mapPosition, 0.5f, MAROON); - - DrawGrid(10.0, 1.0); - - DrawGizmo(mapPosition); + // NOTE: Model is scaled to 1/4 of its original size (128x128 units) + DrawModel(map, mapPosition, 1/4.0f, RED); End3dMode(); + + DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE); + DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN); DrawFPS(10, 10); diff --git a/examples/models_heightmap.png b/examples/models_heightmap.png index a32ec954..9ed04586 100644 Binary files a/examples/models_heightmap.png and b/examples/models_heightmap.png differ diff --git a/examples/models_obj_loading.c b/examples/models_obj_loading.c index 55501f65..ef024356 100644 --- a/examples/models_obj_loading.c +++ b/examples/models_obj_loading.c @@ -2,7 +2,7 @@ * * raylib [models] example - Load and draw a 3d model (OBJ) * -* This example has been created using raylib 1.0 (www.raylib.com) +* This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2014 Ramon Santamaria (@raysan5) diff --git a/examples/models_obj_loading.png b/examples/models_obj_loading.png index da49c457..560348b4 100644 Binary files a/examples/models_obj_loading.png and b/examples/models_obj_loading.png differ diff --git a/examples/resources/cubicmap.png b/examples/resources/cubicmap.png index 87b95d50..b361c018 100644 Binary files a/examples/resources/cubicmap.png and b/examples/resources/cubicmap.png differ diff --git a/examples/resources/cubicmap_atlas.png b/examples/resources/cubicmap_atlas.png new file mode 100644 index 00000000..7ddfc83a Binary files /dev/null and b/examples/resources/cubicmap_atlas.png differ diff --git a/examples/resources/guybrush.png b/examples/resources/guybrush.png new file mode 100644 index 00000000..32c9dced Binary files /dev/null and b/examples/resources/guybrush.png differ diff --git a/examples/resources/heightmap.png b/examples/resources/heightmap.png index c17050fc..fe30f679 100644 Binary files a/examples/resources/heightmap.png and b/examples/resources/heightmap.png differ diff --git a/examples/text_font_select.png b/examples/text_font_select.png index 27bf9432..65040df6 100644 Binary files a/examples/text_font_select.png and b/examples/text_font_select.png differ diff --git a/examples/text_format_text.c b/examples/text_format_text.c index 516e3ecf..ca28be74 100644 --- a/examples/text_format_text.c +++ b/examples/text_format_text.c @@ -5,7 +5,7 @@ * 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) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/text_rbmf_fonts.c b/examples/text_rbmf_fonts.c index a521862b..74e3da6b 100644 --- a/examples/text_rbmf_fonts.c +++ b/examples/text_rbmf_fonts.c @@ -8,7 +8,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/text_rbmf_fonts.png b/examples/text_rbmf_fonts.png index 58f6d83f..c047c503 100644 Binary files a/examples/text_rbmf_fonts.png and b/examples/text_rbmf_fonts.png differ diff --git a/examples/textures_rectangle.c b/examples/textures_rectangle.c index c0fb0d97..61cce9fb 100644 --- a/examples/textures_rectangle.c +++ b/examples/textures_rectangle.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -20,15 +20,12 @@ int main() 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 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 + Texture2D guybrush = LoadTexture("resources/guybrush.png"); // Texture loading - Rectangle eyesRec = { 225, 240, 155, 50 }; // Part of the texture to draw - Vector2 position = { 369, 241 }; + Vector2 position = { 350, 240 }; + Rectangle frameRec = { 0, 0, guybrush.width/7, guybrush.height }; + int currentFrame = 0; //-------------------------------------------------------------------------------------- // Main game loop @@ -36,7 +33,14 @@ int main() { // Update //---------------------------------------------------------------------------------- - // TODO: Update your variables here + if (IsKeyPressed(KEY_RIGHT)) + { + currentFrame++; + + if (currentFrame > 6) currentFrame = 0; + + frameRec.x = currentFrame*guybrush.width/7; + } //---------------------------------------------------------------------------------- // Draw @@ -45,15 +49,19 @@ int main() ClearBackground(RAYWHITE); - DrawText("LENA", 220, 100, 20, PINK); - - 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); + DrawTexture(guybrush, 35, 40, WHITE); + DrawRectangleLines(35, 40, guybrush.width, guybrush.height, LIME); + + DrawTextureRec(guybrush, frameRec, position, WHITE); // Draw part of the texture + + DrawRectangleLines(35 + frameRec.x, 40 + frameRec.y, frameRec.width, frameRec.height, RED); + + DrawText("PRESS RIGHT KEY to", 540, 310, 10, GRAY); + DrawText("CHANGE DRAWING RECTANGLE", 520, 330, 10, GRAY); + + DrawText("Guybrush Ulysses Threepwood,", 100, 300, 10, GRAY); + DrawText("main character of the Monkey Island series", 80, 320, 10, GRAY); + DrawText("of computer adventure games by LucasArts.", 80, 340, 10, GRAY); EndDrawing(); //---------------------------------------------------------------------------------- @@ -61,7 +69,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Texture unloading + UnloadTexture(guybrush); // Texture unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/textures_rectangle.png b/examples/textures_rectangle.png index fb434a8e..d89404ab 100644 Binary files a/examples/textures_rectangle.png and b/examples/textures_rectangle.png differ diff --git a/examples/textures_srcrec_dstrec.c b/examples/textures_srcrec_dstrec.c index 1f0b56e2..72a209fb 100644 --- a/examples/textures_srcrec_dstrec.c +++ b/examples/textures_srcrec_dstrec.c @@ -5,7 +5,7 @@ * 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) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -21,16 +21,23 @@ int main() 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 + Texture2D guybrush = LoadTexture("resources/guybrush.png"); // Texture loading + int frameWidth = guybrush.width/7; + int frameHeight = guybrush.height; + // NOTE: Source rectangle (part of the texture to use for drawing) - Rectangle sourceRec = { 128, 128, 128, 128 }; + Rectangle sourceRec = { 0, 0, frameWidth, frameHeight }; // 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 }; + Rectangle destRec = { screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 }; + + // NOTE: Origin of the texture (rotation/scale point), it's relative to destination rectangle size + Vector2 origin = { frameWidth, frameHeight }; + + int rotation = 0; + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop @@ -38,7 +45,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - // TODO: Update your variables here + rotation++; //---------------------------------------------------------------------------------- // Draw @@ -48,10 +55,10 @@ int main() 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); + DrawTexturePro(guybrush, sourceRec, destRec, origin, rotation, WHITE); - DrawLine(destRec.x, 0, destRec.x, screenHeight, RED); - DrawLine(0, destRec.y, screenWidth, destRec.y, RED); + DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY); + DrawLine(0, destRec.y, screenWidth, destRec.y, GRAY); EndDrawing(); //---------------------------------------------------------------------------------- @@ -59,7 +66,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Texture unloading + UnloadTexture(guybrush); // Texture unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/textures_srcrec_dstrec.png b/examples/textures_srcrec_dstrec.png index 95b7130e..7459d6ec 100644 Binary files a/examples/textures_srcrec_dstrec.png and b/examples/textures_srcrec_dstrec.png differ -- cgit v1.2.3 From 773360caa334cb7db668fcfae98299033afd58a8 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 28 Aug 2015 14:16:42 +0200 Subject: Removed resources --- examples/resources/lena.png | Bin 473831 -> 0 bytes examples/resources/raylib_logo.dds | Bin 87536 -> 0 bytes examples/resources/raylib_logo_uncompressed.dds | Bin 349652 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/resources/lena.png delete mode 100644 examples/resources/raylib_logo.dds delete mode 100644 examples/resources/raylib_logo_uncompressed.dds (limited to 'examples') diff --git a/examples/resources/lena.png b/examples/resources/lena.png deleted file mode 100644 index 59ef68aa..00000000 Binary files a/examples/resources/lena.png and /dev/null differ diff --git a/examples/resources/raylib_logo.dds b/examples/resources/raylib_logo.dds deleted file mode 100644 index b558bc15..00000000 Binary files a/examples/resources/raylib_logo.dds and /dev/null differ diff --git a/examples/resources/raylib_logo_uncompressed.dds b/examples/resources/raylib_logo_uncompressed.dds deleted file mode 100644 index 2b40a205..00000000 Binary files a/examples/resources/raylib_logo_uncompressed.dds and /dev/null differ -- cgit v1.2.3 From 324259ef8e9a758aafa89ff7cf101037defa92a9 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 28 Aug 2015 14:17:03 +0200 Subject: Remove crappy example --- examples/models_planes.c | 63 ------------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 examples/models_planes.c (limited to 'examples') diff --git a/examples/models_planes.c b/examples/models_planes.c deleted file mode 100644 index 58b5137e..00000000 --- a/examples/models_planes.c +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************************* -* -* 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 }, RED); // Draw a plane XZ - - DrawGrid(10.0, 1.0); - - End3dMode(); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file -- cgit v1.2.3 From 12581c1721a3cbca990766cb98b78211b59074be Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 28 Aug 2015 14:17:35 +0200 Subject: Changed mail address by twitter user Probably more useful... --- examples/audio_sound_loading.c | 2 +- examples/core_3d_mode.c | 2 +- examples/core_basic_window_web.c | 2 +- examples/core_color_select.c | 2 +- examples/core_input_gamepad.c | 2 +- examples/core_input_keys.c | 2 +- examples/core_input_mouse.c | 2 +- examples/core_mouse_wheel.c | 2 +- examples/core_random_values.c | 2 +- examples/models_custom_shader.c | 86 -------------------------------------- examples/models_geometric_shapes.c | 2 +- examples/shapes_basic_shapes.c | 2 +- examples/shapes_colors_palette.c | 2 +- examples/shapes_logo_raylib.c | 2 +- examples/shapes_logo_raylib_anim.c | 2 +- examples/text_sprite_fonts.c | 2 +- examples/textures_logo_raylib.c | 2 +- 17 files changed, 16 insertions(+), 102 deletions(-) delete mode 100644 examples/models_custom_shader.c (limited to 'examples') diff --git a/examples/audio_sound_loading.c b/examples/audio_sound_loading.c index 359af0af..1376a27d 100644 --- a/examples/audio_sound_loading.c +++ b/examples/audio_sound_loading.c @@ -7,7 +7,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_3d_mode.c b/examples/core_3d_mode.c index 2275058d..c38da256 100644 --- a/examples/core_3d_mode.c +++ b/examples/core_3d_mode.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_basic_window_web.c b/examples/core_basic_window_web.c index b35c07e6..65650b1a 100644 --- a/examples/core_basic_window_web.c +++ b/examples/core_basic_window_web.c @@ -15,7 +15,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_color_select.c b/examples/core_color_select.c index a2a79ed9..118dc88a 100644 --- a/examples/core_color_select.c +++ b/examples/core_color_select.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_input_gamepad.c b/examples/core_input_gamepad.c index 384ef989..64be4cd8 100644 --- a/examples/core_input_gamepad.c +++ b/examples/core_input_gamepad.c @@ -8,7 +8,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_input_keys.c b/examples/core_input_keys.c index 442ae840..99d5e516 100644 --- a/examples/core_input_keys.c +++ b/examples/core_input_keys.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_input_mouse.c b/examples/core_input_mouse.c index eeef8c7a..c64b421e 100644 --- a/examples/core_input_mouse.c +++ b/examples/core_input_mouse.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_mouse_wheel.c b/examples/core_mouse_wheel.c index 08c2ee1e..6a5252ee 100644 --- a/examples/core_mouse_wheel.c +++ b/examples/core_mouse_wheel.c @@ -5,7 +5,7 @@ * 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) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_random_values.c b/examples/core_random_values.c index 20989ee1..98e0e91e 100644 --- a/examples/core_random_values.c +++ b/examples/core_random_values.c @@ -5,7 +5,7 @@ * 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) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/models_custom_shader.c b/examples/models_custom_shader.c deleted file mode 100644 index 5430ed65..00000000 --- a/examples/models_custom_shader.c +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************************* -* -* 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) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) -* -********************************************************************************************/ - -#include "raylib.h" - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 1280; - int screenHeight = 720; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - custom shader"); - - // 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 texture = LoadTexture("resources/catsham.png"); // Load model texture - Shader shader = LoadShader("resources/shaders/custom.vs", "resources/shaders/custom.fs"); - //Shader poste = LoadShader("resources/shaders/custom.vs", "resources/shaders/pixel.fs"); - - Model cat = LoadModel("resources/cat.obj"); // Load OBJ model - - SetModelTexture(&cat, texture); // Bind texture to model - //SetModelShader(&cat, poste); - - Vector3 catPosition = { 0.0, 0.0, 0.0 }; // Set model position - - SetPostproShader(shader); - - 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)) 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 - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - Begin3dMode(camera); - - DrawModel(cat, catPosition, 0.1f, WHITE); // Draw 3d model with texture - - DrawGrid(10.0, 1.0); // Draw a grid - - DrawGizmo(catPosition); // Draw gizmo - - End3dMode(); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(texture); // Unload texture - UnloadModel(cat); // Unload model - UnloadShader(shader); - //UnloadShader(poste); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/examples/models_geometric_shapes.c b/examples/models_geometric_shapes.c index 3a649a3a..e2d41dcd 100644 --- a/examples/models_geometric_shapes.c +++ b/examples/models_geometric_shapes.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/shapes_basic_shapes.c b/examples/shapes_basic_shapes.c index 4ae9f4df..4b14af89 100644 --- a/examples/shapes_basic_shapes.c +++ b/examples/shapes_basic_shapes.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/shapes_colors_palette.c b/examples/shapes_colors_palette.c index 926dcdf8..3e161114 100644 --- a/examples/shapes_colors_palette.c +++ b/examples/shapes_colors_palette.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/shapes_logo_raylib.c b/examples/shapes_logo_raylib.c index a9e5104a..3dd8fbf3 100644 --- a/examples/shapes_logo_raylib.c +++ b/examples/shapes_logo_raylib.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/shapes_logo_raylib_anim.c b/examples/shapes_logo_raylib_anim.c index cd3a4aa6..d0831378 100644 --- a/examples/shapes_logo_raylib_anim.c +++ b/examples/shapes_logo_raylib_anim.c @@ -5,7 +5,7 @@ * 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) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/text_sprite_fonts.c b/examples/text_sprite_fonts.c index e27e8c08..423fa250 100644 --- a/examples/text_sprite_fonts.c +++ b/examples/text_sprite_fonts.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/textures_logo_raylib.c b/examples/textures_logo_raylib.c index f4aeb738..2ebf0867 100644 --- a/examples/textures_logo_raylib.c +++ b/examples/textures_logo_raylib.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2014 Ramon Santamaria (@raysan5) * ********************************************************************************************/ -- cgit v1.2.3 From ea45223f1ff0f0f3ebe7535548829681d2a7fa7d Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 28 Aug 2015 18:07:39 +0200 Subject: New examples added --- examples/core_3d_camera_free.c | 2 +- examples/core_3d_picking.c | 2 +- examples/core_drop_files.c | 74 ++++++++++++++ examples/core_drop_files.png | Bin 0 -> 4682 bytes examples/models_billboard.c | 29 +++--- examples/models_billboard.png | Bin 0 -> 53998 bytes examples/models_cubicmap.c | 2 +- examples/models_heightmap.c | 2 +- examples/resources/billboard.png | Bin 0 -> 22439 bytes examples/resources/smoke.png | Bin 0 -> 15427 bytes examples/textures_particles_trail_blending.c | 132 +++++++++++++++++++++++++ examples/textures_particles_trail_blending.png | Bin 0 -> 358260 bytes examples/textures_to_image.c | 68 +++++++++++++ examples/textures_to_image.png | Bin 0 -> 17200 bytes 14 files changed, 292 insertions(+), 19 deletions(-) create mode 100644 examples/core_drop_files.c create mode 100644 examples/core_drop_files.png create mode 100644 examples/models_billboard.png create mode 100644 examples/resources/billboard.png create mode 100644 examples/resources/smoke.png create mode 100644 examples/textures_particles_trail_blending.c create mode 100644 examples/textures_particles_trail_blending.png create mode 100644 examples/textures_to_image.c create mode 100644 examples/textures_to_image.png (limited to 'examples') diff --git a/examples/core_3d_camera_free.c b/examples/core_3d_camera_free.c index 9e123b04..b54a99c1 100644 --- a/examples/core_3d_camera_free.c +++ b/examples/core_3d_camera_free.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* Copyright (c) 2015 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/core_3d_picking.c b/examples/core_3d_picking.c index 056dcd65..28503570 100644 --- a/examples/core_3d_picking.c +++ b/examples/core_3d_picking.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ diff --git a/examples/core_drop_files.c b/examples/core_drop_files.c new file mode 100644 index 00000000..5802e48f --- /dev/null +++ b/examples/core_drop_files.c @@ -0,0 +1,74 @@ +/******************************************************************************************* +* +* raylib [core] example - Windows drop files +* +* This example has been created using raylib 1.3 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files"); + + int count = 0; + char **droppedFiles; + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + if (IsFileDropped()) + { + droppedFiles = GetDroppedFiles(&count); + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + if (count == 0) DrawText("Drop your files to this window!", 100, 40, 20, DARKGRAY); + else + { + DrawText("Dropped files:", 100, 40, 20, DARKGRAY); + + for (int i = 0; i < count; i++) + { + if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f)); + else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f)); + + DrawText(droppedFiles[i], 120, 100 + 40*i, 10, GRAY); + } + + DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY); + } + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + ClearDroppedFiles(); // Clear internal buffers + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/core_drop_files.png b/examples/core_drop_files.png new file mode 100644 index 00000000..d46c44cf Binary files /dev/null and b/examples/core_drop_files.png differ diff --git a/examples/models_billboard.c b/examples/models_billboard.c index a58ec7d7..511d61ce 100644 --- a/examples/models_billboard.c +++ b/examples/models_billboard.c @@ -2,10 +2,10 @@ * * raylib [models] example - Drawing billboards * -* This example has been created using raylib 1.2 (www.raylib.com) +* This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2015 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -21,24 +21,24 @@ int main() 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 }}; + Camera camera = {{ 5.0, 4.0, 5.0 }, { 0.0, 2.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 + Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard + Vector3 billPosition = { 0.0, 2.0, 0.0 }; // Position where draw billboard + + SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode + SetCameraPosition(camera.position); // Set internal camera position to match our camera position + SetCameraTarget(camera.target); // Set internal camera target to match our camera target - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + 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; + camera = UpdateCamera(0); // Update internal camera and our camera //---------------------------------------------------------------------------------- // Draw @@ -49,8 +49,7 @@ int main() Begin3dMode(camera); - //DrawBillboard(camera, lena, billPosition, 1.0, WHITE); - DrawBillboardRec(camera, lena, eyesRec, billPosition, 4.0, WHITE); + DrawBillboard(camera, bill, billPosition, 2.0f, WHITE); DrawGrid(10.0, 1.0); // Draw a grid @@ -64,7 +63,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadTexture(lena); // Unload texture + UnloadTexture(bill); // Unload texture CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/models_billboard.png b/examples/models_billboard.png new file mode 100644 index 00000000..f1ed9239 Binary files /dev/null and b/examples/models_billboard.png differ diff --git a/examples/models_cubicmap.c b/examples/models_cubicmap.c index e1f2e7df..3b20907b 100644 --- a/examples/models_cubicmap.c +++ b/examples/models_cubicmap.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ diff --git a/examples/models_heightmap.c b/examples/models_heightmap.c index 297ada32..7de31a8e 100644 --- a/examples/models_heightmap.c +++ b/examples/models_heightmap.c @@ -5,7 +5,7 @@ * This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* Copyright (c) 2015 Ramon Santamaria (@raysan5) * ********************************************************************************************/ diff --git a/examples/resources/billboard.png b/examples/resources/billboard.png new file mode 100644 index 00000000..e2fe398d Binary files /dev/null and b/examples/resources/billboard.png differ diff --git a/examples/resources/smoke.png b/examples/resources/smoke.png new file mode 100644 index 00000000..7bad8c68 Binary files /dev/null and b/examples/resources/smoke.png differ diff --git a/examples/textures_particles_trail_blending.c b/examples/textures_particles_trail_blending.c new file mode 100644 index 00000000..1e7abf7e --- /dev/null +++ b/examples/textures_particles_trail_blending.c @@ -0,0 +1,132 @@ +/******************************************************************************************* +* +* raylib example - particles trail blending +* +* This example has been created using raylib 1.3 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2015 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +#define MAX_PARTICLES 200 + +typedef struct { + Vector2 position; + Color color; + float alpha; + float size; + float rotation; + bool active; // NOTE: Use it to activate/deactive particle +} Particle; + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles trail blending"); + + // Particles pool, reuse them! + Particle mouseTail[MAX_PARTICLES]; + + // Initialize particles + for (int i = 0; i < MAX_PARTICLES; i++) + { + mouseTail[i].position = (Vector2){ 0, 0 }; + mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; + mouseTail[i].alpha = 1.0f; + mouseTail[i].size = (float)GetRandomValue(1, 30)/20; + mouseTail[i].rotation = GetRandomValue(0, 360); + mouseTail[i].active = false; + } + + float gravity = 3; + + Texture2D smoke = LoadTexture("resources/smoke.png"); + + int blending = BLEND_ALPHA; + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + + // Activate one particle every frame and Update active particles + // NOTE: Particles initial position should be mouse position when activated + // NOTE: Particles fall down with gravity and rotation... and disappear after 2 seconds (alpha = 0) + // NOTE: When a particle disappears, active = false and it can be reused. + for (int i = 0; i < MAX_PARTICLES; i++) + { + if (!mouseTail[i].active) + { + mouseTail[i].active = true; + mouseTail[i].alpha = 1.0f; + mouseTail[i].position = GetMousePosition(); + i = MAX_PARTICLES; + } + } + + for (int i = 0; i < MAX_PARTICLES; i++) + { + if (mouseTail[i].active) + { + mouseTail[i].position.y += gravity; + mouseTail[i].alpha -= 0.01f; + + if (mouseTail[i].alpha <= 0.0f) mouseTail[i].active = false; + + mouseTail[i].rotation += 5; + } + } + + if (IsKeyPressed(KEY_SPACE)) + { + if (blending == BLEND_ALPHA) blending = BLEND_ADDITIVE; + else blending = BLEND_ALPHA; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(DARKGRAY); + + SetBlendMode(blending); + + // Draw active particles + for (int i = 0; i < MAX_PARTICLES; i++) + { + if (mouseTail[i].active) DrawTexturePro(smoke, (Rectangle){ 0, 0, smoke.width, smoke.height }, + (Rectangle){ mouseTail[i].position.x, mouseTail[i].position.y, smoke.width*mouseTail[i].size, smoke.height*mouseTail[i].size }, + (Vector2){ smoke.width*mouseTail[i].size/2, smoke.height*mouseTail[i].size/2 }, mouseTail[i].rotation, + Fade(mouseTail[i].color, mouseTail[i].alpha)); + } + + DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, RAYWHITE); + + if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, RAYWHITE); + else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadTexture(smoke); + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/textures_particles_trail_blending.png b/examples/textures_particles_trail_blending.png new file mode 100644 index 00000000..b0c40fd2 Binary files /dev/null and b/examples/textures_particles_trail_blending.png differ diff --git a/examples/textures_to_image.c b/examples/textures_to_image.c new file mode 100644 index 00000000..3ea8e017 --- /dev/null +++ b/examples/textures_to_image.c @@ -0,0 +1,68 @@ +/******************************************************************************************* +* +* raylib [textures] example - Retrieve image data from texture: GetTextureData() +* +* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) +* +* This example has been created using raylib 1.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 to image"); + + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) + + Image image = LoadImage("resources/raylib_logo.png"); // Load image data into CPU memory (RAM) + Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (RAM -> VRAM) + UnloadImage(image); // Unload image data from CPU memory (RAM) + + image = GetTextureData(texture); // Retrieve image data from GPU memory (VRAM -> RAM) + UnloadTexture(texture); // Unload texture from GPU memory (VRAM) + + texture = LoadTextureFromImage(image); // Recreate texture from retrieved image data (RAM -> VRAM) + UnloadImage(image); // Unload retrieved image data from CPU memory (RAM) + //--------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); + + DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadTexture(texture); // Texture unloading + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/textures_to_image.png b/examples/textures_to_image.png new file mode 100644 index 00000000..410103a5 Binary files /dev/null and b/examples/textures_to_image.png differ -- cgit v1.2.3 From ecd6f77de7aeea28c512302fade8b4470a7bf2bf Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sat, 29 Aug 2015 17:01:56 +0200 Subject: New textures loading examples --- examples/resources/texture_formats/sonic.png | Bin 0 -> 116512 bytes .../resources/texture_formats/sonic_A1R5G5B5.dds | Bin 0 -> 524416 bytes .../resources/texture_formats/sonic_A4R4G4B4.dds | Bin 0 -> 524416 bytes .../resources/texture_formats/sonic_A8R8G8B8.dds | Bin 0 -> 1048704 bytes .../texture_formats/sonic_ASTC_4x4_ldr.astc | Bin 0 -> 262160 bytes .../texture_formats/sonic_ASTC_8x8_ldr.astc | Bin 0 -> 65552 bytes .../resources/texture_formats/sonic_DXT1_RGB.dds | Bin 0 -> 131200 bytes .../resources/texture_formats/sonic_DXT1_RGBA.dds | Bin 0 -> 131200 bytes .../resources/texture_formats/sonic_DXT3_RGBA.dds | Bin 0 -> 262272 bytes .../resources/texture_formats/sonic_DXT5_RGBA.dds | Bin 0 -> 262272 bytes .../resources/texture_formats/sonic_ETC1_RGB.ktx | Bin 0 -> 131140 bytes .../resources/texture_formats/sonic_ETC1_RGB.pkm | Bin 0 -> 131088 bytes .../texture_formats/sonic_ETC2_EAC_RGBA.ktx | Bin 0 -> 262212 bytes .../texture_formats/sonic_ETC2_EAC_RGBA.old.pkm | Bin 0 -> 262160 bytes .../texture_formats/sonic_ETC2_EAC_RGBA.pkm | Bin 0 -> 262160 bytes .../resources/texture_formats/sonic_ETC2_RGB.ktx | Bin 0 -> 131140 bytes .../resources/texture_formats/sonic_ETC2_RGB.pkm | Bin 0 -> 131088 bytes .../resources/texture_formats/sonic_GRAYSCALE.pvr | Bin 0 -> 262211 bytes examples/resources/texture_formats/sonic_L8A8.pvr | Bin 0 -> 524355 bytes .../resources/texture_formats/sonic_PVRT_RGB.pvr | Bin 0 -> 131139 bytes .../resources/texture_formats/sonic_PVRT_RGBA.pvr | Bin 0 -> 131139 bytes .../texture_formats/sonic_PVRT_RGBA_2bpp.pvr | Bin 0 -> 65603 bytes .../texture_formats/sonic_PVRT_RGB_2bpp.pvr | Bin 0 -> 65603 bytes .../resources/texture_formats/sonic_R4G4B4A4.pvr | Bin 0 -> 524355 bytes .../resources/texture_formats/sonic_R5G5B5A1.pvr | Bin 0 -> 524355 bytes .../resources/texture_formats/sonic_R5G6B5.dds | Bin 0 -> 524416 bytes .../resources/texture_formats/sonic_R5G6B5.pvr | Bin 0 -> 524355 bytes .../resources/texture_formats/sonic_R8G8B8.pvr | Bin 0 -> 786499 bytes .../resources/texture_formats/sonic_R8G8B8A8.pvr | Bin 0 -> 1048643 bytes .../resources/texture_formats/sonic_R8G8B8A8.raw | Bin 0 -> 1048576 bytes examples/textures_formats_loading.c | 244 +++++++++++++++++++++ examples/textures_formats_loading.png | Bin 0 -> 79031 bytes examples/textures_raw_data.c | 90 ++++++++ examples/textures_raw_data.png | Bin 0 -> 87424 bytes 34 files changed, 334 insertions(+) create mode 100644 examples/resources/texture_formats/sonic.png create mode 100644 examples/resources/texture_formats/sonic_A1R5G5B5.dds create mode 100644 examples/resources/texture_formats/sonic_A4R4G4B4.dds create mode 100644 examples/resources/texture_formats/sonic_A8R8G8B8.dds create mode 100644 examples/resources/texture_formats/sonic_ASTC_4x4_ldr.astc create mode 100644 examples/resources/texture_formats/sonic_ASTC_8x8_ldr.astc create mode 100644 examples/resources/texture_formats/sonic_DXT1_RGB.dds create mode 100644 examples/resources/texture_formats/sonic_DXT1_RGBA.dds create mode 100644 examples/resources/texture_formats/sonic_DXT3_RGBA.dds create mode 100644 examples/resources/texture_formats/sonic_DXT5_RGBA.dds create mode 100644 examples/resources/texture_formats/sonic_ETC1_RGB.ktx create mode 100644 examples/resources/texture_formats/sonic_ETC1_RGB.pkm create mode 100644 examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx create mode 100644 examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm create mode 100644 examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm create mode 100644 examples/resources/texture_formats/sonic_ETC2_RGB.ktx create mode 100644 examples/resources/texture_formats/sonic_ETC2_RGB.pkm create mode 100644 examples/resources/texture_formats/sonic_GRAYSCALE.pvr create mode 100644 examples/resources/texture_formats/sonic_L8A8.pvr create mode 100644 examples/resources/texture_formats/sonic_PVRT_RGB.pvr create mode 100644 examples/resources/texture_formats/sonic_PVRT_RGBA.pvr create mode 100644 examples/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr create mode 100644 examples/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr create mode 100644 examples/resources/texture_formats/sonic_R4G4B4A4.pvr create mode 100644 examples/resources/texture_formats/sonic_R5G5B5A1.pvr create mode 100644 examples/resources/texture_formats/sonic_R5G6B5.dds create mode 100644 examples/resources/texture_formats/sonic_R5G6B5.pvr create mode 100644 examples/resources/texture_formats/sonic_R8G8B8.pvr create mode 100644 examples/resources/texture_formats/sonic_R8G8B8A8.pvr create mode 100644 examples/resources/texture_formats/sonic_R8G8B8A8.raw create mode 100644 examples/textures_formats_loading.c create mode 100644 examples/textures_formats_loading.png create mode 100644 examples/textures_raw_data.c create mode 100644 examples/textures_raw_data.png (limited to 'examples') diff --git a/examples/resources/texture_formats/sonic.png b/examples/resources/texture_formats/sonic.png new file mode 100644 index 00000000..7a096847 Binary files /dev/null and b/examples/resources/texture_formats/sonic.png differ diff --git a/examples/resources/texture_formats/sonic_A1R5G5B5.dds b/examples/resources/texture_formats/sonic_A1R5G5B5.dds new file mode 100644 index 00000000..5e2347db Binary files /dev/null and b/examples/resources/texture_formats/sonic_A1R5G5B5.dds differ diff --git a/examples/resources/texture_formats/sonic_A4R4G4B4.dds b/examples/resources/texture_formats/sonic_A4R4G4B4.dds new file mode 100644 index 00000000..c5ccaf0c Binary files /dev/null and b/examples/resources/texture_formats/sonic_A4R4G4B4.dds differ diff --git a/examples/resources/texture_formats/sonic_A8R8G8B8.dds b/examples/resources/texture_formats/sonic_A8R8G8B8.dds new file mode 100644 index 00000000..fb71b7be Binary files /dev/null and b/examples/resources/texture_formats/sonic_A8R8G8B8.dds differ diff --git a/examples/resources/texture_formats/sonic_ASTC_4x4_ldr.astc b/examples/resources/texture_formats/sonic_ASTC_4x4_ldr.astc new file mode 100644 index 00000000..9a98d9a0 Binary files /dev/null and b/examples/resources/texture_formats/sonic_ASTC_4x4_ldr.astc differ diff --git a/examples/resources/texture_formats/sonic_ASTC_8x8_ldr.astc b/examples/resources/texture_formats/sonic_ASTC_8x8_ldr.astc new file mode 100644 index 00000000..360a264a Binary files /dev/null and b/examples/resources/texture_formats/sonic_ASTC_8x8_ldr.astc differ diff --git a/examples/resources/texture_formats/sonic_DXT1_RGB.dds b/examples/resources/texture_formats/sonic_DXT1_RGB.dds new file mode 100644 index 00000000..9d0b4598 Binary files /dev/null and b/examples/resources/texture_formats/sonic_DXT1_RGB.dds differ diff --git a/examples/resources/texture_formats/sonic_DXT1_RGBA.dds b/examples/resources/texture_formats/sonic_DXT1_RGBA.dds new file mode 100644 index 00000000..102bae7f Binary files /dev/null and b/examples/resources/texture_formats/sonic_DXT1_RGBA.dds differ diff --git a/examples/resources/texture_formats/sonic_DXT3_RGBA.dds b/examples/resources/texture_formats/sonic_DXT3_RGBA.dds new file mode 100644 index 00000000..46d965cb Binary files /dev/null and b/examples/resources/texture_formats/sonic_DXT3_RGBA.dds differ diff --git a/examples/resources/texture_formats/sonic_DXT5_RGBA.dds b/examples/resources/texture_formats/sonic_DXT5_RGBA.dds new file mode 100644 index 00000000..b3a59a79 Binary files /dev/null and b/examples/resources/texture_formats/sonic_DXT5_RGBA.dds differ diff --git a/examples/resources/texture_formats/sonic_ETC1_RGB.ktx b/examples/resources/texture_formats/sonic_ETC1_RGB.ktx new file mode 100644 index 00000000..66241b9d Binary files /dev/null and b/examples/resources/texture_formats/sonic_ETC1_RGB.ktx differ diff --git a/examples/resources/texture_formats/sonic_ETC1_RGB.pkm b/examples/resources/texture_formats/sonic_ETC1_RGB.pkm new file mode 100644 index 00000000..c6fc6df4 Binary files /dev/null and b/examples/resources/texture_formats/sonic_ETC1_RGB.pkm differ diff --git a/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx new file mode 100644 index 00000000..b01812cb Binary files /dev/null and b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx differ diff --git a/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm new file mode 100644 index 00000000..61ac48ce Binary files /dev/null and b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm differ diff --git a/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm new file mode 100644 index 00000000..61ac48ce Binary files /dev/null and b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm differ diff --git a/examples/resources/texture_formats/sonic_ETC2_RGB.ktx b/examples/resources/texture_formats/sonic_ETC2_RGB.ktx new file mode 100644 index 00000000..7f1207f7 Binary files /dev/null and b/examples/resources/texture_formats/sonic_ETC2_RGB.ktx differ diff --git a/examples/resources/texture_formats/sonic_ETC2_RGB.pkm b/examples/resources/texture_formats/sonic_ETC2_RGB.pkm new file mode 100644 index 00000000..f290f019 Binary files /dev/null and b/examples/resources/texture_formats/sonic_ETC2_RGB.pkm differ diff --git a/examples/resources/texture_formats/sonic_GRAYSCALE.pvr b/examples/resources/texture_formats/sonic_GRAYSCALE.pvr new file mode 100644 index 00000000..d31e2651 Binary files /dev/null and b/examples/resources/texture_formats/sonic_GRAYSCALE.pvr differ diff --git a/examples/resources/texture_formats/sonic_L8A8.pvr b/examples/resources/texture_formats/sonic_L8A8.pvr new file mode 100644 index 00000000..ccf5932e Binary files /dev/null and b/examples/resources/texture_formats/sonic_L8A8.pvr differ diff --git a/examples/resources/texture_formats/sonic_PVRT_RGB.pvr b/examples/resources/texture_formats/sonic_PVRT_RGB.pvr new file mode 100644 index 00000000..22f3f66a Binary files /dev/null and b/examples/resources/texture_formats/sonic_PVRT_RGB.pvr differ diff --git a/examples/resources/texture_formats/sonic_PVRT_RGBA.pvr b/examples/resources/texture_formats/sonic_PVRT_RGBA.pvr new file mode 100644 index 00000000..feb9aeaf Binary files /dev/null and b/examples/resources/texture_formats/sonic_PVRT_RGBA.pvr differ diff --git a/examples/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr b/examples/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr new file mode 100644 index 00000000..9147e1bb Binary files /dev/null and b/examples/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr differ diff --git a/examples/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr b/examples/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr new file mode 100644 index 00000000..2a8aea8c Binary files /dev/null and b/examples/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr differ diff --git a/examples/resources/texture_formats/sonic_R4G4B4A4.pvr b/examples/resources/texture_formats/sonic_R4G4B4A4.pvr new file mode 100644 index 00000000..3f7368a3 Binary files /dev/null and b/examples/resources/texture_formats/sonic_R4G4B4A4.pvr differ diff --git a/examples/resources/texture_formats/sonic_R5G5B5A1.pvr b/examples/resources/texture_formats/sonic_R5G5B5A1.pvr new file mode 100644 index 00000000..c7fa098d Binary files /dev/null and b/examples/resources/texture_formats/sonic_R5G5B5A1.pvr differ diff --git a/examples/resources/texture_formats/sonic_R5G6B5.dds b/examples/resources/texture_formats/sonic_R5G6B5.dds new file mode 100644 index 00000000..217da954 Binary files /dev/null and b/examples/resources/texture_formats/sonic_R5G6B5.dds differ diff --git a/examples/resources/texture_formats/sonic_R5G6B5.pvr b/examples/resources/texture_formats/sonic_R5G6B5.pvr new file mode 100644 index 00000000..9bb8320e Binary files /dev/null and b/examples/resources/texture_formats/sonic_R5G6B5.pvr differ diff --git a/examples/resources/texture_formats/sonic_R8G8B8.pvr b/examples/resources/texture_formats/sonic_R8G8B8.pvr new file mode 100644 index 00000000..072cf3ef Binary files /dev/null and b/examples/resources/texture_formats/sonic_R8G8B8.pvr differ diff --git a/examples/resources/texture_formats/sonic_R8G8B8A8.pvr b/examples/resources/texture_formats/sonic_R8G8B8A8.pvr new file mode 100644 index 00000000..f82534f9 Binary files /dev/null and b/examples/resources/texture_formats/sonic_R8G8B8A8.pvr differ diff --git a/examples/resources/texture_formats/sonic_R8G8B8A8.raw b/examples/resources/texture_formats/sonic_R8G8B8A8.raw new file mode 100644 index 00000000..fc5858e7 Binary files /dev/null and b/examples/resources/texture_formats/sonic_R8G8B8A8.raw differ diff --git a/examples/textures_formats_loading.c b/examples/textures_formats_loading.c new file mode 100644 index 00000000..a758fe27 --- /dev/null +++ b/examples/textures_formats_loading.c @@ -0,0 +1,244 @@ +/******************************************************************************************* +* +* raylib [textures] example - texture formats loading (compressed and uncompressed) +* +* NOTE: This example requires raylib OpenGL 3.3+ or ES2 versions for compressed textures, +* OpenGL 1.1 does not support compressed textures, only uncompressed ones. +* +* This example has been created using raylib 1.3 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2015 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +#define NUM_TEXTURES 24 + +typedef enum { + PNG_R8G8B8A8 = 0, + PVR_GRAYSCALE, + PVR_GRAY_ALPHA, + PVR_R5G6B5, + PVR_R5G5B5A1, + PVR_R4G4B4A4, + DDS_R5G6B5, + DDS_R5G5B5A1, + DDS_R4G4B4A4, + DDS_R8G8B8A8, + DDS_DXT1_RGB, + DDS_DXT1_RGBA, + DDS_DXT3_RGBA, + DDS_DXT5_RGBA, + PKM_ETC1_RGB, + PKM_ETC2_RGB, + PKM_ETC2_EAC_RGBA, + KTX_ETC1_RGB, + KTX_ETC2_RGB, + KTX_ETC2_EAC_RGBA, + ASTC_4x4_LDR, + ASTC_8x8_LDR, + PVR_PVRT_RGB, + PVR_PVRT_RGBA + +} TextureFormats; + +static const char *formatText[] = { + "PNG_R8G8B8A8", + "PVR_GRAYSCALE", + "PVR_GRAY_ALPHA", + "PVR_R5G6B5", + "PVR_R5G5B5A1", + "PVR_R4G4B4A4", + "DDS_R5G6B5", + "DDS_R5G5B5A1", + "DDS_R4G4B4A4", + "DDS_R8G8B8A8", + "DDS_DXT1_RGB", + "DDS_DXT1_RGBA", + "DDS_DXT3_RGBA", + "DDS_DXT5_RGBA", + "PKM_ETC1_RGB", + "PKM_ETC2_RGB", + "PKM_ETC2_EAC_RGBA", + "KTX_ETC1_RGB", + "KTX_ETC2_RGB", + "KTX_ETC2_EAC_RGBA", + "ASTC_4x4_LDR", + "ASTC_8x8_LDR", + "PVR_PVRT_RGB", + "PVR_PVRT_RGBA" +}; + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 480; + + InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture formats loading"); + + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) + + Texture2D sonic[NUM_TEXTURES]; + + sonic[PNG_R8G8B8A8] = LoadTexture("resources/texture_formats/sonic.png"); + + // Load UNCOMPRESSED PVR texture data + sonic[PVR_GRAYSCALE] = LoadTexture("resources/texture_formats/sonic_GRAYSCALE.pvr"); + sonic[PVR_GRAY_ALPHA] = LoadTexture("resources/texture_formats/sonic_L8A8.pvr"); + sonic[PVR_R5G6B5] = LoadTexture("resources/texture_formats/sonic_R5G6B5.pvr"); + sonic[PVR_R5G5B5A1] = LoadTexture("resources/texture_formats/sonic_R5G5B5A1.pvr"); + sonic[PVR_R4G4B4A4] = LoadTexture("resources/texture_formats/sonic_R4G4B4A4.pvr"); + + // Load UNCOMPRESSED DDS texture data + sonic[DDS_R5G6B5] = LoadTexture("resources/texture_formats/sonic_R5G6B5.dds"); + sonic[DDS_R5G5B5A1] = LoadTexture("resources/texture_formats/sonic_A1R5G5B5.dds"); + sonic[DDS_R4G4B4A4] = LoadTexture("resources/texture_formats/sonic_A4R4G4B4.dds"); + sonic[DDS_R8G8B8A8] = LoadTexture("resources/texture_formats/sonic_A8R8G8B8.dds"); + + // Load COMPRESSED DXT DDS texture data (if supported) + sonic[DDS_DXT1_RGB] = LoadTexture("resources/texture_formats/sonic_DXT1_RGB.dds"); + sonic[DDS_DXT1_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT1_RGBA.dds"); + sonic[DDS_DXT3_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT3_RGBA.dds"); + sonic[DDS_DXT5_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT5_RGBA.dds"); + + // Load COMPRESSED ETC texture data (if supported) + sonic[PKM_ETC1_RGB] = LoadTexture("resources/texture_formats/sonic_ETC1_RGB.pkm"); + sonic[PKM_ETC2_RGB] = LoadTexture("resources/texture_formats/sonic_ETC2_RGB.pkm"); + sonic[PKM_ETC2_EAC_RGBA] = LoadTexture("resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm"); + + sonic[KTX_ETC1_RGB] = LoadTexture("resources/texture_formats/sonic_ETC1_RGB.ktx"); + sonic[KTX_ETC2_RGB] = LoadTexture("resources/texture_formats/sonic_ETC2_RGB.ktx"); + sonic[KTX_ETC2_EAC_RGBA] = LoadTexture("resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx"); + + // Load COMPRESSED ASTC texture data (if supported) + sonic[ASTC_4x4_LDR] = LoadTexture("resources/texture_formats/sonic_ASTC_4x4_ldr.astc"); + sonic[ASTC_8x8_LDR] = LoadTexture("resources/texture_formats/sonic_ASTC_8x8_ldr.astc"); + + // Load COMPRESSED PVR texture data (if supported) + sonic[PVR_PVRT_RGB] = LoadTexture("resources/texture_formats/sonic_PVRT_RGB.pvr"); + sonic[PVR_PVRT_RGBA] = LoadTexture("resources/texture_formats/sonic_PVRT_RGBA.pvr"); + + int selectedFormat = PNG_R8G8B8A8; + + Rectangle selectRecs[NUM_TEXTURES]; + + for (int i = 0; i < NUM_TEXTURES; i++) + { + if (i < NUM_TEXTURES/2) selectRecs[i] = (Rectangle){ 40, 45 + 32*i, 150, 30 }; + else selectRecs[i] = (Rectangle){ 40 + 152, 45 + 32*(i - NUM_TEXTURES/2), 150, 30 }; + } + + // Texture sizes in KB + float textureSizes[NUM_TEXTURES] = { + 512*512*32/8/1024, //PNG_R8G8B8A8 (32 bpp) + 512*512*8/8/1024, //PVR_GRAYSCALE (8 bpp) + 512*512*16/8/1024, //PVR_GRAY_ALPHA (16 bpp) + 512*512*16/8/1024, //PVR_R5G6B5 (16 bpp) + 512*512*16/8/1024, //PVR_R5G5B5A1 (16 bpp) + 512*512*16/8/1024, //PVR_R4G4B4A4 (16 bpp) + 512*512*16/8/1024, //DDS_R5G6B5 (16 bpp) + 512*512*16/8/1024, //DDS_R5G5B5A1 (16 bpp) + 512*512*16/8/1024, //DDS_R4G4B4A4 (16 bpp) + 512*512*32/8/1024, //DDS_R8G8B8A8 (32 bpp) + 512*512*4/8/1024, //DDS_DXT1_RGB (4 bpp) -Compressed- + 512*512*4/8/1024, //DDS_DXT1_RGBA (4 bpp) -Compressed- + 512*512*8/8/1024, //DDS_DXT3_RGBA (8 bpp) -Compressed- + 512*512*8/8/1024, //DDS_DXT5_RGBA (8 bpp) -Compressed- + 512*512*4/8/1024, //PKM_ETC1_RGB (4 bpp) -Compressed- + 512*512*4/8/1024, //PKM_ETC2_RGB (4 bpp) -Compressed- + 512*512*8/8/1024, //PKM_ETC2_EAC_RGBA (8 bpp) -Compressed- + 512*512*4/8/1024, //KTX_ETC1_RGB (4 bpp) -Compressed- + 512*512*4/8/1024, //KTX_ETC2_RGB (4 bpp) -Compressed- + 512*512*8/8/1024, //KTX_ETC2_EAC_RGBA (8 bpp) -Compressed- + 512*512*8/8/1024, //ASTC_4x4_LDR (8 bpp) -Compressed- + 512*512*2/8/1024, //ASTC_8x8_LDR (2 bpp) -Compressed- + 512*512*4/8/1024, //PVR_PVRT_RGB (4 bpp) -Compressed- + 512*512*4/8/1024, //PVR_PVRT_RGBA (4 bpp) -Compressed- + }; + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //--------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + if (IsKeyPressed(KEY_DOWN)) + { + selectedFormat++; + if (selectedFormat >= NUM_TEXTURES) selectedFormat = 0; + } + else if (IsKeyPressed(KEY_UP)) + { + selectedFormat--; + if (selectedFormat < 0) selectedFormat = NUM_TEXTURES - 1; + } + else if (IsKeyPressed(KEY_RIGHT)) + { + if (selectedFormat < NUM_TEXTURES/2) selectedFormat += NUM_TEXTURES/2; + } + else if (IsKeyPressed(KEY_LEFT)) + { + if (selectedFormat >= NUM_TEXTURES/2) selectedFormat -= NUM_TEXTURES/2; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + + BeginDrawing(); + + ClearBackground(RAYWHITE); + + // Draw rectangles + for (int i = 0; i < NUM_TEXTURES; i++) + { + if (i == selectedFormat) + { + DrawRectangleRec(selectRecs[i], SKYBLUE); + DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE); + DrawText(formatText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(formatText[i], 10)/2, selectRecs[i].y + 11, 10, DARKBLUE); + } + else + { + DrawRectangleRec(selectRecs[i], LIGHTGRAY); + DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY); + DrawText(formatText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(formatText[i], 10)/2, selectRecs[i].y + 11, 10, DARKGRAY); + } + } + + // Draw selected texture + if (sonic[selectedFormat].id != 0) + { + DrawTexture(sonic[selectedFormat], 350, 0, WHITE); + } + else + { + DrawRectangleLines(488, 165, 200, 110, DARKGRAY); + DrawText("FORMAT", 550, 180, 20, MAROON); + DrawText("NOT SUPPORTED", 500, 210, 20, MAROON); + DrawText("ON YOUR GPU", 520, 240, 20, MAROON); + } + + DrawText("Select texture format (use cursor keys):", 40, 26, 10, DARKGRAY); + DrawText("Required GPU memory size (VRAM):", 40, 442, 10, DARKGRAY); + DrawText(FormatText("%4.0f KB", textureSizes[selectedFormat]), 240, 435, 20, DARKBLUE); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + for (int i = 0; i < NUM_TEXTURES; i++) UnloadTexture(sonic[i]); + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/textures_formats_loading.png b/examples/textures_formats_loading.png new file mode 100644 index 00000000..4cdb2f13 Binary files /dev/null and b/examples/textures_formats_loading.png differ diff --git a/examples/textures_raw_data.c b/examples/textures_raw_data.c new file mode 100644 index 00000000..a4ff71b3 --- /dev/null +++ b/examples/textures_raw_data.c @@ -0,0 +1,90 @@ +/******************************************************************************************* +* +* raylib [textures] example - Load textures from raw data +* +* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM) +* +* This example has been created using raylib 1.3 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2015 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +#include // Required for malloc() and free() + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture from raw data"); + + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) + + // Load RAW image data (512x512, 32bit RGBA, no file header) + Image sonicRaw = LoadImageRaw("resources/texture_formats/sonic_R8G8B8A8.raw", 512, 512, UNCOMPRESSED_R8G8B8A8, 0); + Texture2D sonic = LoadTextureFromImage(sonicRaw); // Upload CPU (RAM) image to GPU (VRAM) + UnloadImage(sonicRaw); // Unload CPU (RAM) image data + + // Generate a checked texture by code (1024x1024 pixels) + int width = 1024; + int height = 1024; + + Color *pixels = (Color *)malloc(width*height*sizeof(Color)); + + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + if (((x/32+y/32)/1)%2 == 0) pixels[y*height + x] = DARKBLUE; + else pixels[y*height + x] = SKYBLUE; + } + } + + // Load pixels data into an image structure and create texture + Image checkedIm = LoadImageEx(pixels, width, height); + Texture2D checked = LoadTextureFromImage(checkedIm); + UnloadImage(checkedIm); // Unload CPU (RAM) image data + free(pixels); // Unload CPU (RAM) pixels data + //--------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.3f)); + DrawTexture(sonic, 330, -20, WHITE); + + DrawText("CHECKED TEXTURE ", 84, 100, 30, DARKBLUE); + DrawText("GENERATED by CODE", 72, 164, 30, DARKBLUE); + DrawText("and RAW IMAGE LOADING", 46, 226, 30, DARKBLUE); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadTexture(sonic); // Texture unloading + UnloadTexture(checked); // Texture unloading + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/textures_raw_data.png b/examples/textures_raw_data.png new file mode 100644 index 00000000..374d2266 Binary files /dev/null and b/examples/textures_raw_data.png differ -- cgit v1.2.3 From 32330801c96ad017de1334922a8a88f08811e6f4 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 30 Aug 2015 17:46:37 +0200 Subject: Updates some examples --- examples/core_3d_camera_first_person.c | 91 +++++++++++++++++++++++++++++++ examples/core_3d_camera_first_person.png | Bin 0 -> 18402 bytes examples/core_3d_camera_free.c | 2 +- examples/core_3d_picking.c | 2 +- examples/models_billboard.c | 2 +- examples/models_cubicmap.c | 10 ++-- examples/models_heightmap.c | 12 ++-- examples/text_font_select.c | 10 ++-- examples/text_rbmf_fonts.c | 10 ++-- examples/text_sprite_fonts.c | 18 +++--- 10 files changed, 124 insertions(+), 33 deletions(-) create mode 100644 examples/core_3d_camera_first_person.c create mode 100644 examples/core_3d_camera_first_person.png (limited to 'examples') diff --git a/examples/core_3d_camera_first_person.c b/examples/core_3d_camera_first_person.c new file mode 100644 index 00000000..cd37f873 --- /dev/null +++ b/examples/core_3d_camera_first_person.c @@ -0,0 +1,91 @@ +/******************************************************************************************* +* +* raylib [core] example - 3d camera first person +* +* This example has been created using raylib 1.3 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2015 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +#define MAX_COLUMNS 20 + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); + + // Define the camera to look into our 3d world + Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }}; + + // Generates some random columns + float heights[MAX_COLUMNS]; + Vector3 positions[MAX_COLUMNS] = { 0.0, 2.5, 0.0 }; + Color colors[MAX_COLUMNS]; + + for (int i = 0; i < MAX_COLUMNS; i++) + { + heights[i] = (float)GetRandomValue(1, 12); + positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) }; + colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 }; + } + + Vector3 playerPosition = { 4, 2, 4 }; // Define player position + + SetCameraMode(CAMERA_FIRST_PERSON); // Set a first person camera mode + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + UpdateCameraPlayer(&camera, &playerPosition); // Update camera and player position + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + Begin3dMode(camera); + + DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 32, 32 }, LIGHTGRAY); // Draw ground + DrawCube((Vector3){ -16, 2.5, 0 }, 1, 5, 32, BLUE); // Draw a blue wall + DrawCube((Vector3){ 16, 2.5, 0 }, 1, 5, 32, LIME); // Draw a green wall + DrawCube((Vector3){ 0, 2.5, 16 }, 32, 5, 1, GOLD); // Draw a yellow wall + + // Draw some cubes around + for (int i = 0; i < MAX_COLUMNS; i++) + { + DrawCube(positions[i], 2, heights[i], 2, colors[i]); + DrawCubeWires(positions[i], 2, heights[i], 2, MAROON); + } + + End3dMode(); + + DrawText("First person camera default controls:", 20, 20, 10, GRAY); + DrawText("- Move with keys: W, A, S, D", 40, 50, 10, DARKGRAY); + DrawText("- Mouse move to lokk around", 40, 70, 10, DARKGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/core_3d_camera_first_person.png b/examples/core_3d_camera_first_person.png new file mode 100644 index 00000000..9373da2d Binary files /dev/null and b/examples/core_3d_camera_first_person.png differ diff --git a/examples/core_3d_camera_free.c b/examples/core_3d_camera_free.c index b54a99c1..cca9cfd5 100644 --- a/examples/core_3d_camera_free.c +++ b/examples/core_3d_camera_free.c @@ -37,7 +37,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - camera = UpdateCamera(0); // Update internal camera and our camera + UpdateCamera(&camera); // Update internal camera and our camera //---------------------------------------------------------------------------------- // Draw diff --git a/examples/core_3d_picking.c b/examples/core_3d_picking.c index 28503570..13839070 100644 --- a/examples/core_3d_picking.c +++ b/examples/core_3d_picking.c @@ -38,7 +38,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - camera = UpdateCamera(0); // Update internal camera and our camera + UpdateCamera(&camera); // Update internal camera and our camera if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) { diff --git a/examples/models_billboard.c b/examples/models_billboard.c index 511d61ce..05d836ca 100644 --- a/examples/models_billboard.c +++ b/examples/models_billboard.c @@ -38,7 +38,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - camera = UpdateCamera(0); // Update internal camera and our camera + UpdateCamera(&camera); // Update internal camera and our camera //---------------------------------------------------------------------------------- // Draw diff --git a/examples/models_cubicmap.c b/examples/models_cubicmap.c index 3b20907b..d7fe896c 100644 --- a/examples/models_cubicmap.c +++ b/examples/models_cubicmap.c @@ -35,18 +35,18 @@ int main() UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM - SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode - SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position + SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode + SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- - camera = UpdateCamera(0); // Update internal camera and our camera + UpdateCamera(&camera); // Update internal camera and our camera //---------------------------------------------------------------------------------- // Draw diff --git a/examples/models_heightmap.c b/examples/models_heightmap.c index 7de31a8e..fec3f5e6 100644 --- a/examples/models_heightmap.c +++ b/examples/models_heightmap.c @@ -29,20 +29,20 @@ int main() SetModelTexture(&map, texture); // Bind texture to model Vector3 mapPosition = { -16, 0.0, -16 }; // Set model position (depends on model scaling!) - UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM + UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM - SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode - SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position + SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode + SetCameraPosition(camera.position); // Set internal camera position to match our custom camera position - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- - camera = UpdateCamera(0); // Update internal camera and our camera + UpdateCamera(&camera); // Update internal camera and our camera //---------------------------------------------------------------------------------- // Draw diff --git a/examples/text_font_select.c b/examples/text_font_select.c index 25825aba..fe586db8 100644 --- a/examples/text_font_select.c +++ b/examples/text_font_select.c @@ -2,10 +2,10 @@ * * raylib [text] example - Font selector * -* This example has been created using raylib 1.0 (www.raylib.com) +* This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* Copyright (c) 2015 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -41,7 +41,7 @@ int main() const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text - Vector2 textSize = MeasureTextEx(fonts[currentFont], text, GetFontBaseSize(fonts[currentFont])*3, 1); + Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1); Vector2 mousePoint; @@ -118,7 +118,7 @@ int main() } // Text measurement for better positioning on screen - textSize = MeasureTextEx(fonts[currentFont], text, GetFontBaseSize(fonts[currentFont])*3, 1); + textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1); //---------------------------------------------------------------------------------- // Draw @@ -140,7 +140,7 @@ int main() DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor); DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2, - 260 + (70 - textSize.y)/2 }, GetFontBaseSize(fonts[currentFont])*3, + 260 + (70 - textSize.y)/2 }, fonts[currentFont].size*3, 1, colors[currentFont]); EndDrawing(); diff --git a/examples/text_rbmf_fonts.c b/examples/text_rbmf_fonts.c index 74e3da6b..b4bd851b 100644 --- a/examples/text_rbmf_fonts.c +++ b/examples/text_rbmf_fonts.c @@ -5,10 +5,10 @@ * 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) +* This example has been created using raylib 1.3 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* Copyright (c) 2015 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -50,8 +50,8 @@ int main() for (int i = 0; i < 8; i++) { - positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], GetFontBaseSize(fonts[i])*2, spacings[i]).x/2; - positions[i].y = 60 + GetFontBaseSize(fonts[i]) + 50*i; + positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].size*2, spacings[i]).x/2; + positions[i].y = 60 + fonts[i].size + 50*i; } Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD }; @@ -76,7 +76,7 @@ int main() for (int i = 0; i < 8; i++) { - DrawTextEx(fonts[i], messages[i], positions[i], GetFontBaseSize(fonts[i])*2, spacings[i], colors[i]); + DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].size*2, spacings[i], colors[i]); } EndDrawing(); diff --git a/examples/text_sprite_fonts.c b/examples/text_sprite_fonts.c index 423fa250..c73eda85 100644 --- a/examples/text_sprite_fonts.c +++ b/examples/text_sprite_fonts.c @@ -31,14 +31,14 @@ int main() Vector2 fontPosition1, fontPosition2, fontPosition3; - fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, GetFontBaseSize(font1), -3).x/2; - fontPosition1.y = screenHeight/2 - GetFontBaseSize(font1)/2 - 80; + fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.size, -3).x/2; + fontPosition1.y = screenHeight/2 - font1.size/2 - 80; - fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, GetFontBaseSize(font2), -2).x/2; - fontPosition2.y = screenHeight/2 - GetFontBaseSize(font2)/2 - 10; + fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.size, -2).x/2; + fontPosition2.y = screenHeight/2 - font2.size/2 - 10; - fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, GetFontBaseSize(font3), 2).x/2; - fontPosition3.y = screenHeight/2 - GetFontBaseSize(font3)/2 + 50; + fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.size, 2).x/2; + fontPosition3.y = screenHeight/2 - font3.size/2 + 50; //-------------------------------------------------------------------------------------- @@ -56,9 +56,9 @@ int main() ClearBackground(RAYWHITE); - DrawTextEx(font1, msg1, fontPosition1, GetFontBaseSize(font1), -3, WHITE); - DrawTextEx(font2, msg2, fontPosition2, GetFontBaseSize(font2), -2, WHITE); - DrawTextEx(font3, msg3, fontPosition3, GetFontBaseSize(font3), 2, WHITE); + DrawTextEx(font1, msg1, fontPosition1, font1.size, -3, WHITE); + DrawTextEx(font2, msg2, fontPosition2, font2.size, -2, WHITE); + DrawTextEx(font3, msg3, fontPosition3, font3.size, 2, WHITE); EndDrawing(); //---------------------------------------------------------------------------------- -- cgit v1.2.3