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/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 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/resources/cubicmap_atlas.png create mode 100644 examples/resources/guybrush.png (limited to 'examples/resources') 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 -- 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/resources') 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 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/resources') 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/resources') 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