aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2015-08-29 17:01:56 +0200
committerraysan5 <raysan5@gmail.com>2015-08-29 17:01:56 +0200
commitecd6f77de7aeea28c512302fade8b4470a7bf2bf (patch)
tree3c2da3105981705b05f675eaae3e41def5d2825b
parent5cfd59258ae4c308aab1055430f10955e5188736 (diff)
downloadraylib-ecd6f77de7aeea28c512302fade8b4470a7bf2bf.tar.gz
raylib-ecd6f77de7aeea28c512302fade8b4470a7bf2bf.zip
New textures loading examples
-rw-r--r--examples/resources/texture_formats/sonic.pngbin0 -> 116512 bytes
-rw-r--r--examples/resources/texture_formats/sonic_A1R5G5B5.ddsbin0 -> 524416 bytes
-rw-r--r--examples/resources/texture_formats/sonic_A4R4G4B4.ddsbin0 -> 524416 bytes
-rw-r--r--examples/resources/texture_formats/sonic_A8R8G8B8.ddsbin0 -> 1048704 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ASTC_4x4_ldr.astcbin0 -> 262160 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ASTC_8x8_ldr.astcbin0 -> 65552 bytes
-rw-r--r--examples/resources/texture_formats/sonic_DXT1_RGB.ddsbin0 -> 131200 bytes
-rw-r--r--examples/resources/texture_formats/sonic_DXT1_RGBA.ddsbin0 -> 131200 bytes
-rw-r--r--examples/resources/texture_formats/sonic_DXT3_RGBA.ddsbin0 -> 262272 bytes
-rw-r--r--examples/resources/texture_formats/sonic_DXT5_RGBA.ddsbin0 -> 262272 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ETC1_RGB.ktxbin0 -> 131140 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ETC1_RGB.pkmbin0 -> 131088 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktxbin0 -> 262212 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkmbin0 -> 262160 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkmbin0 -> 262160 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ETC2_RGB.ktxbin0 -> 131140 bytes
-rw-r--r--examples/resources/texture_formats/sonic_ETC2_RGB.pkmbin0 -> 131088 bytes
-rw-r--r--examples/resources/texture_formats/sonic_GRAYSCALE.pvrbin0 -> 262211 bytes
-rw-r--r--examples/resources/texture_formats/sonic_L8A8.pvrbin0 -> 524355 bytes
-rw-r--r--examples/resources/texture_formats/sonic_PVRT_RGB.pvrbin0 -> 131139 bytes
-rw-r--r--examples/resources/texture_formats/sonic_PVRT_RGBA.pvrbin0 -> 131139 bytes
-rw-r--r--examples/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvrbin0 -> 65603 bytes
-rw-r--r--examples/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvrbin0 -> 65603 bytes
-rw-r--r--examples/resources/texture_formats/sonic_R4G4B4A4.pvrbin0 -> 524355 bytes
-rw-r--r--examples/resources/texture_formats/sonic_R5G5B5A1.pvrbin0 -> 524355 bytes
-rw-r--r--examples/resources/texture_formats/sonic_R5G6B5.ddsbin0 -> 524416 bytes
-rw-r--r--examples/resources/texture_formats/sonic_R5G6B5.pvrbin0 -> 524355 bytes
-rw-r--r--examples/resources/texture_formats/sonic_R8G8B8.pvrbin0 -> 786499 bytes
-rw-r--r--examples/resources/texture_formats/sonic_R8G8B8A8.pvrbin0 -> 1048643 bytes
-rw-r--r--examples/resources/texture_formats/sonic_R8G8B8A8.rawbin0 -> 1048576 bytes
-rw-r--r--examples/textures_formats_loading.c244
-rw-r--r--examples/textures_formats_loading.pngbin0 -> 79031 bytes
-rw-r--r--examples/textures_raw_data.c90
-rw-r--r--examples/textures_raw_data.pngbin0 -> 87424 bytes
34 files changed, 334 insertions, 0 deletions
diff --git a/examples/resources/texture_formats/sonic.png b/examples/resources/texture_formats/sonic.png
new file mode 100644
index 00000000..7a096847
--- /dev/null
+++ b/examples/resources/texture_formats/sonic.png
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_A1R5G5B5.dds
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_A4R4G4B4.dds
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_A8R8G8B8.dds
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ASTC_4x4_ldr.astc
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ASTC_8x8_ldr.astc
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_DXT1_RGB.dds
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_DXT1_RGBA.dds
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_DXT3_RGBA.dds
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_DXT5_RGBA.dds
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ETC1_RGB.ktx
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ETC1_RGB.pkm
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ETC2_RGB.ktx
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_ETC2_RGB.pkm
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_GRAYSCALE.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_L8A8.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_PVRT_RGB.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_PVRT_RGBA.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_R4G4B4A4.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_R5G5B5A1.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_R5G6B5.dds
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_R5G6B5.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_R8G8B8.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_R8G8B8A8.pvr
Binary files 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
--- /dev/null
+++ b/examples/resources/texture_formats/sonic_R8G8B8A8.raw
Binary files 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
--- /dev/null
+++ b/examples/textures_formats_loading.png
Binary files 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 <stdlib.h> // 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
--- /dev/null
+++ b/examples/textures_raw_data.png
Binary files differ