summaryrefslogtreecommitdiffhomepage
path: root/examples/textures
diff options
context:
space:
mode:
authorRay <[email protected]>2017-04-04 01:54:49 +0200
committerRay <[email protected]>2017-04-04 01:54:49 +0200
commitdd4dd0e87d7d215a21b8fc129cbe1adc4b96afe8 (patch)
tree724f11991d301fc8bfd01ccd13321f66d8969329 /examples/textures
parent5a230659ef39c6eb3bdb5412ca6e1bfc9eeda98e (diff)
downloadraylib-dd4dd0e87d7d215a21b8fc129cbe1adc4b96afe8.tar.gz
raylib-dd4dd0e87d7d215a21b8fc129cbe1adc4b96afe8.zip
Reorganize examples folder
Diffstat (limited to 'examples/textures')
-rw-r--r--examples/textures/resources/cat.pngbin0 -> 388532 bytes
-rw-r--r--examples/textures/resources/guybrush.pngbin0 -> 85247 bytes
-rw-r--r--examples/textures/resources/heightmap.pngbin0 -> 10920 bytes
-rw-r--r--examples/textures/resources/parrots.pngbin0 -> 295054 bytes
-rw-r--r--examples/textures/resources/raylib_logo.pngbin0 -> 3760 bytes
-rw-r--r--examples/textures/resources/smoke.pngbin0 -> 15427 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic.pngbin0 -> 116512 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_A1R5G5B5.ddsbin0 -> 524416 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_A4R4G4B4.ddsbin0 -> 524416 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_A8R8G8B8.ddsbin0 -> 1048704 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ASTC_4x4_ldr.astcbin0 -> 262160 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ASTC_8x8_ldr.astcbin0 -> 65552 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_DXT1_RGB.ddsbin0 -> 131200 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_DXT1_RGBA.ddsbin0 -> 131200 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_DXT3_RGBA.ddsbin0 -> 262272 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_DXT5_RGBA.ddsbin0 -> 262272 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ETC1_RGB.ktxbin0 -> 131140 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ETC1_RGB.pkmbin0 -> 131088 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktxbin0 -> 262212 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkmbin0 -> 262160 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkmbin0 -> 262160 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ETC2_RGB.ktxbin0 -> 131140 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_ETC2_RGB.pkmbin0 -> 131088 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_GRAYSCALE.pvrbin0 -> 262211 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_L8A8.pvrbin0 -> 524355 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_PVRT_RGB.pvrbin0 -> 131139 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_PVRT_RGBA.pvrbin0 -> 131139 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvrbin0 -> 65603 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvrbin0 -> 65603 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_R4G4B4A4.pvrbin0 -> 524355 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_R5G5B5A1.pvrbin0 -> 524355 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_R5G6B5.ddsbin0 -> 524416 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_R5G6B5.pvrbin0 -> 524355 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_R8G8B8.pvrbin0 -> 786499 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_R8G8B8A8.pvrbin0 -> 1048643 bytes
-rw-r--r--examples/textures/resources/texture_formats/sonic_R8G8B8A8.rawbin0 -> 1048576 bytes
-rw-r--r--examples/textures/textures_formats_loading.c244
-rw-r--r--examples/textures/textures_formats_loading.pngbin0 -> 125797 bytes
-rw-r--r--examples/textures/textures_image_drawing.c78
-rw-r--r--examples/textures/textures_image_drawing.pngbin0 -> 420135 bytes
-rw-r--r--examples/textures/textures_image_loading.c63
-rw-r--r--examples/textures/textures_image_loading.pngbin0 -> 17200 bytes
-rw-r--r--examples/textures/textures_image_processing.c154
-rw-r--r--examples/textures/textures_image_processing.pngbin0 -> 259470 bytes
-rw-r--r--examples/textures/textures_logo_raylib.c57
-rw-r--r--examples/textures/textures_logo_raylib.pngbin0 -> 15442 bytes
-rw-r--r--examples/textures/textures_particles_trail_blending.c135
-rw-r--r--examples/textures/textures_particles_trail_blending.pngbin0 -> 358260 bytes
-rw-r--r--examples/textures/textures_raw_data.c93
-rw-r--r--examples/textures/textures_raw_data.pngbin0 -> 87424 bytes
-rw-r--r--examples/textures/textures_rectangle.c78
-rw-r--r--examples/textures/textures_rectangle.pngbin0 -> 109993 bytes
-rw-r--r--examples/textures/textures_srcrec_dstrec.c79
-rw-r--r--examples/textures/textures_srcrec_dstrec.pngbin0 -> 47563 bytes
-rw-r--r--examples/textures/textures_to_image.c68
-rw-r--r--examples/textures/textures_to_image.pngbin0 -> 17200 bytes
56 files changed, 1049 insertions, 0 deletions
diff --git a/examples/textures/resources/cat.png b/examples/textures/resources/cat.png
new file mode 100644
index 00000000..d023aa21
--- /dev/null
+++ b/examples/textures/resources/cat.png
Binary files differ
diff --git a/examples/textures/resources/guybrush.png b/examples/textures/resources/guybrush.png
new file mode 100644
index 00000000..32c9dced
--- /dev/null
+++ b/examples/textures/resources/guybrush.png
Binary files differ
diff --git a/examples/textures/resources/heightmap.png b/examples/textures/resources/heightmap.png
new file mode 100644
index 00000000..fe30f679
--- /dev/null
+++ b/examples/textures/resources/heightmap.png
Binary files differ
diff --git a/examples/textures/resources/parrots.png b/examples/textures/resources/parrots.png
new file mode 100644
index 00000000..d6ec60ba
--- /dev/null
+++ b/examples/textures/resources/parrots.png
Binary files differ
diff --git a/examples/textures/resources/raylib_logo.png b/examples/textures/resources/raylib_logo.png
new file mode 100644
index 00000000..66545627
--- /dev/null
+++ b/examples/textures/resources/raylib_logo.png
Binary files differ
diff --git a/examples/textures/resources/smoke.png b/examples/textures/resources/smoke.png
new file mode 100644
index 00000000..7bad8c68
--- /dev/null
+++ b/examples/textures/resources/smoke.png
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic.png b/examples/textures/resources/texture_formats/sonic.png
new file mode 100644
index 00000000..7a096847
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic.png
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_A1R5G5B5.dds b/examples/textures/resources/texture_formats/sonic_A1R5G5B5.dds
new file mode 100644
index 00000000..5e2347db
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_A1R5G5B5.dds
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_A4R4G4B4.dds b/examples/textures/resources/texture_formats/sonic_A4R4G4B4.dds
new file mode 100644
index 00000000..c5ccaf0c
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_A4R4G4B4.dds
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_A8R8G8B8.dds b/examples/textures/resources/texture_formats/sonic_A8R8G8B8.dds
new file mode 100644
index 00000000..fb71b7be
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_A8R8G8B8.dds
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ASTC_4x4_ldr.astc b/examples/textures/resources/texture_formats/sonic_ASTC_4x4_ldr.astc
new file mode 100644
index 00000000..9a98d9a0
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ASTC_4x4_ldr.astc
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ASTC_8x8_ldr.astc b/examples/textures/resources/texture_formats/sonic_ASTC_8x8_ldr.astc
new file mode 100644
index 00000000..360a264a
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ASTC_8x8_ldr.astc
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_DXT1_RGB.dds b/examples/textures/resources/texture_formats/sonic_DXT1_RGB.dds
new file mode 100644
index 00000000..9d0b4598
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_DXT1_RGB.dds
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_DXT1_RGBA.dds b/examples/textures/resources/texture_formats/sonic_DXT1_RGBA.dds
new file mode 100644
index 00000000..102bae7f
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_DXT1_RGBA.dds
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_DXT3_RGBA.dds b/examples/textures/resources/texture_formats/sonic_DXT3_RGBA.dds
new file mode 100644
index 00000000..46d965cb
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_DXT3_RGBA.dds
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_DXT5_RGBA.dds b/examples/textures/resources/texture_formats/sonic_DXT5_RGBA.dds
new file mode 100644
index 00000000..b3a59a79
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_DXT5_RGBA.dds
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ETC1_RGB.ktx b/examples/textures/resources/texture_formats/sonic_ETC1_RGB.ktx
new file mode 100644
index 00000000..66241b9d
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ETC1_RGB.ktx
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ETC1_RGB.pkm b/examples/textures/resources/texture_formats/sonic_ETC1_RGB.pkm
new file mode 100644
index 00000000..c6fc6df4
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ETC1_RGB.pkm
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx b/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx
new file mode 100644
index 00000000..b01812cb
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm b/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm
new file mode 100644
index 00000000..61ac48ce
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm b/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm
new file mode 100644
index 00000000..61ac48ce
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ETC2_RGB.ktx b/examples/textures/resources/texture_formats/sonic_ETC2_RGB.ktx
new file mode 100644
index 00000000..7f1207f7
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ETC2_RGB.ktx
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_ETC2_RGB.pkm b/examples/textures/resources/texture_formats/sonic_ETC2_RGB.pkm
new file mode 100644
index 00000000..f290f019
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_ETC2_RGB.pkm
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_GRAYSCALE.pvr b/examples/textures/resources/texture_formats/sonic_GRAYSCALE.pvr
new file mode 100644
index 00000000..d31e2651
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_GRAYSCALE.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_L8A8.pvr b/examples/textures/resources/texture_formats/sonic_L8A8.pvr
new file mode 100644
index 00000000..ccf5932e
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_L8A8.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_PVRT_RGB.pvr b/examples/textures/resources/texture_formats/sonic_PVRT_RGB.pvr
new file mode 100644
index 00000000..22f3f66a
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_PVRT_RGB.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_PVRT_RGBA.pvr b/examples/textures/resources/texture_formats/sonic_PVRT_RGBA.pvr
new file mode 100644
index 00000000..feb9aeaf
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_PVRT_RGBA.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr b/examples/textures/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr
new file mode 100644
index 00000000..9147e1bb
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr b/examples/textures/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr
new file mode 100644
index 00000000..2a8aea8c
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_R4G4B4A4.pvr b/examples/textures/resources/texture_formats/sonic_R4G4B4A4.pvr
new file mode 100644
index 00000000..3f7368a3
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_R4G4B4A4.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_R5G5B5A1.pvr b/examples/textures/resources/texture_formats/sonic_R5G5B5A1.pvr
new file mode 100644
index 00000000..c7fa098d
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_R5G5B5A1.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_R5G6B5.dds b/examples/textures/resources/texture_formats/sonic_R5G6B5.dds
new file mode 100644
index 00000000..217da954
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_R5G6B5.dds
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_R5G6B5.pvr b/examples/textures/resources/texture_formats/sonic_R5G6B5.pvr
new file mode 100644
index 00000000..9bb8320e
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_R5G6B5.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_R8G8B8.pvr b/examples/textures/resources/texture_formats/sonic_R8G8B8.pvr
new file mode 100644
index 00000000..072cf3ef
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_R8G8B8.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_R8G8B8A8.pvr b/examples/textures/resources/texture_formats/sonic_R8G8B8A8.pvr
new file mode 100644
index 00000000..f82534f9
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_R8G8B8A8.pvr
Binary files differ
diff --git a/examples/textures/resources/texture_formats/sonic_R8G8B8A8.raw b/examples/textures/resources/texture_formats/sonic_R8G8B8A8.raw
new file mode 100644
index 00000000..fc5858e7
--- /dev/null
+++ b/examples/textures/resources/texture_formats/sonic_R8G8B8A8.raw
Binary files differ
diff --git a/examples/textures/textures_formats_loading.c b/examples/textures/textures_formats_loading.c
new file mode 100644
index 00000000..f416ce38
--- /dev/null
+++ b/examples/textures/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 = 450;
+
+ 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, 30 + 32*i, 150, 30 };
+ else selectRecs[i] = (Rectangle){ 40 + 152, 30 + 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, -10, 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, 10, 10, DARKGRAY);
+ DrawText("Required GPU memory size (VRAM):", 40, 427, 10, DARKGRAY);
+ DrawText(FormatText("%4.0f KB", textureSizes[selectedFormat]), 240, 420, 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/textures_formats_loading.png b/examples/textures/textures_formats_loading.png
new file mode 100644
index 00000000..6778080f
--- /dev/null
+++ b/examples/textures/textures_formats_loading.png
Binary files differ
diff --git a/examples/textures/textures_image_drawing.c b/examples/textures/textures_image_drawing.c
new file mode 100644
index 00000000..1c6a1fb9
--- /dev/null
+++ b/examples/textures/textures_image_drawing.c
@@ -0,0 +1,78 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Image loading and drawing on it
+*
+* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
+*
+* This example has been created using raylib 1.4 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2016 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] example - image drawing");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+
+ Image cat = LoadImage("resources/cat.png"); // Load image in CPU memory (RAM)
+ ImageCrop(&cat, (Rectangle){ 100, 10, 280, 380 }); // Crop an image piece
+ ImageFlipHorizontal(&cat); // Flip cropped image horizontally
+ ImageResize(&cat, 150, 200); // Resize flipped-cropped image
+
+ Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
+
+ // Draw one image over the other with a scaling of 1.5f
+ ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f });
+ ImageCrop(&parrots, (Rectangle){ 0, 50, parrots.width, parrots.height - 100 }); // Crop resulting image
+
+ UnloadImage(cat); // Unload image from RAM
+
+ Texture2D texture = LoadTextureFromImage(parrots); // Image converted to texture, uploaded to GPU memory (VRAM)
+ UnloadImage(parrots); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
+
+ SetTargetFPS(60);
+ //---------------------------------------------------------------------------------------
+
+ // 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 - 40, WHITE);
+ DrawRectangleLines(screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 40, texture.width, texture.height, DARKGRAY);
+
+ DrawText("We are drawing only one texture from various images composed!", 240, 350, 10, DARKGRAY);
+ DrawText("Source images have been cropped, scaled, flipped and copied one over the other.", 190, 370, 10, DARKGRAY);
+
+ 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/textures_image_drawing.png b/examples/textures/textures_image_drawing.png
new file mode 100644
index 00000000..acfee069
--- /dev/null
+++ b/examples/textures/textures_image_drawing.png
Binary files differ
diff --git a/examples/textures/textures_image_loading.c b/examples/textures/textures_image_loading.c
new file mode 100644
index 00000000..54c73586
--- /dev/null
+++ b/examples/textures/textures_image_loading.c
@@ -0,0 +1,63 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Image loading and texture creation
+*
+* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
+*
+* This example has been created using raylib 1.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"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+
+ Image image = LoadImage("resources/raylib_logo.png"); // Loaded in CPU memory (RAM)
+ Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM)
+
+ UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
+ //---------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ // TODO: Update your variables here
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
+
+ DrawText("this IS a texture loaded from an image!", 300, 370, 10, GRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(texture); // Texture unloading
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/textures/textures_image_loading.png b/examples/textures/textures_image_loading.png
new file mode 100644
index 00000000..410103a5
--- /dev/null
+++ b/examples/textures/textures_image_loading.png
Binary files differ
diff --git a/examples/textures/textures_image_processing.c b/examples/textures/textures_image_processing.c
new file mode 100644
index 00000000..58b746e0
--- /dev/null
+++ b/examples/textures/textures_image_processing.c
@@ -0,0 +1,154 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Image processing
+*
+* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
+*
+* This example has been created using raylib 1.4 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2016 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#include <stdlib.h> // Required for: free()
+
+#define NUM_PROCESSES 8
+
+typedef enum {
+ NONE = 0,
+ COLOR_GRAYSCALE,
+ COLOR_TINT,
+ COLOR_INVERT,
+ COLOR_CONTRAST,
+ COLOR_BRIGHTNESS,
+ FLIP_VERTICAL,
+ FLIP_HORIZONTAL
+} ImageProcess;
+
+static const char *processText[] = {
+ "NO PROCESSING",
+ "COLOR GRAYSCALE",
+ "COLOR TINT",
+ "COLOR INVERT",
+ "COLOR CONTRAST",
+ "COLOR BRIGHTNESS",
+ "FLIP VERTICAL",
+ "FLIP HORIZONTAL"
+};
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+
+ Image image = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM)
+ ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update)
+ Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM)
+
+ int currentProcess = NONE;
+ bool textureReload = false;
+
+ Rectangle selectRecs[NUM_PROCESSES];
+
+ for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40, 50 + 32*i, 150, 30 };
+
+ SetTargetFPS(60);
+ //---------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsKeyPressed(KEY_DOWN))
+ {
+ currentProcess++;
+ if (currentProcess > 7) currentProcess = 0;
+ textureReload = true;
+ }
+ else if (IsKeyPressed(KEY_UP))
+ {
+ currentProcess--;
+ if (currentProcess < 0) currentProcess = 7;
+ textureReload = true;
+ }
+
+ if (textureReload)
+ {
+ UnloadImage(image); // Unload current image data
+ image = LoadImage("resources/parrots.png"); // Re-load image data
+
+ // NOTE: Image processing is a costly CPU process to be done every frame,
+ // If image processing is required in a frame-basis, it should be done
+ // with a texture and by shaders
+ switch (currentProcess)
+ {
+ case COLOR_GRAYSCALE: ImageColorGrayscale(&image); break;
+ case COLOR_TINT: ImageColorTint(&image, GREEN); break;
+ case COLOR_INVERT: ImageColorInvert(&image); break;
+ case COLOR_CONTRAST: ImageColorContrast(&image, -40); break;
+ case COLOR_BRIGHTNESS: ImageColorBrightness(&image, -80); break;
+ case FLIP_VERTICAL: ImageFlipVertical(&image); break;
+ case FLIP_HORIZONTAL: ImageFlipHorizontal(&image); break;
+ default: break;
+ }
+
+ Color *pixels = GetImageData(image); // Get pixel data from image (RGBA 32bit)
+ UpdateTexture(texture, pixels); // Update texture with new image data
+ free(pixels); // Unload pixels data from RAM
+
+ textureReload = false;
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("IMAGE PROCESSING:", 40, 30, 10, DARKGRAY);
+
+ // Draw rectangles
+ for (int i = 0; i < NUM_PROCESSES; i++)
+ {
+ if (i == currentProcess)
+ {
+ DrawRectangleRec(selectRecs[i], SKYBLUE);
+ DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE);
+ DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[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(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKGRAY);
+ }
+ }
+
+ DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE);
+ DrawRectangleLines(screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, texture.width, texture.height, BLACK);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(texture); // Unload texture from VRAM
+ UnloadImage(image); // Unload image from RAM
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/textures/textures_image_processing.png b/examples/textures/textures_image_processing.png
new file mode 100644
index 00000000..c15e19f9
--- /dev/null
+++ b/examples/textures/textures_image_processing.png
Binary files differ
diff --git a/examples/textures/textures_logo_raylib.c b/examples/textures/textures_logo_raylib.c
new file mode 100644
index 00000000..f2f93128
--- /dev/null
+++ b/examples/textures/textures_logo_raylib.c
@@ -0,0 +1,57 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Texture loading and drawing
+*
+* This example has been created using raylib 1.0 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2014 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+ Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
+ //---------------------------------------------------------------------------------------
+
+ // 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!", 360, 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/textures_logo_raylib.png b/examples/textures/textures_logo_raylib.png
new file mode 100644
index 00000000..c18bf880
--- /dev/null
+++ b/examples/textures/textures_logo_raylib.png
Binary files differ
diff --git a/examples/textures/textures_particles_trail_blending.c b/examples/textures/textures_particles_trail_blending.c
new file mode 100644
index 00000000..0b47c790
--- /dev/null
+++ b/examples/textures/textures_particles_trail_blending.c
@@ -0,0 +1,135 @@
+/*******************************************************************************************
+*
+* 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
+
+// Particle structure with basic data
+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.0f;
+ mouseTail[i].rotation = GetRandomValue(0, 360);
+ mouseTail[i].active = false;
+ }
+
+ float gravity = 3.0f;
+
+ 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.0f;
+ }
+ }
+
+ if (IsKeyPressed(KEY_SPACE))
+ {
+ if (blending == BLEND_ALPHA) blending = BLEND_ADDITIVE;
+ else blending = BLEND_ALPHA;
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(DARKGRAY);
+
+ BeginBlendMode(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));
+ }
+
+ EndBlendMode();
+
+ DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK);
+
+ if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK);
+ 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/textures_particles_trail_blending.png b/examples/textures/textures_particles_trail_blending.png
new file mode 100644
index 00000000..b0c40fd2
--- /dev/null
+++ b/examples/textures/textures_particles_trail_blending.png
Binary files differ
diff --git a/examples/textures/textures_raw_data.c b/examples/textures/textures_raw_data.c
new file mode 100644
index 00000000..d1922180
--- /dev/null
+++ b/examples/textures/textures_raw_data.c
@@ -0,0 +1,93 @@
+/*******************************************************************************************
+*
+* 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;
+
+ // Dynamic memory allocation to store pixels data (Color type)
+ 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
+
+ // Dynamic memory must be freed after using it
+ 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/textures_raw_data.png b/examples/textures/textures_raw_data.png
new file mode 100644
index 00000000..374d2266
--- /dev/null
+++ b/examples/textures/textures_raw_data.png
Binary files differ
diff --git a/examples/textures/textures_rectangle.c b/examples/textures/textures_rectangle.c
new file mode 100644
index 00000000..cca5b216
--- /dev/null
+++ b/examples/textures/textures_rectangle.c
@@ -0,0 +1,78 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Texture loading and drawing a part defined by a rectangle
+*
+* 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 [texture] example - texture rectangle");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+ Texture2D guybrush = LoadTexture("resources/guybrush.png"); // Texture loading
+
+ Vector2 position = { 350.0f, 240.0f };
+ Rectangle frameRec = { 0, 0, guybrush.width/7, guybrush.height };
+ int currentFrame = 0;
+ //--------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ if (IsKeyPressed(KEY_RIGHT))
+ {
+ currentFrame++;
+
+ if (currentFrame > 6) currentFrame = 0;
+
+ frameRec.x = currentFrame*guybrush.width/7;
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ 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();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(guybrush); // Texture unloading
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/textures/textures_rectangle.png b/examples/textures/textures_rectangle.png
new file mode 100644
index 00000000..d89404ab
--- /dev/null
+++ b/examples/textures/textures_rectangle.png
Binary files differ
diff --git a/examples/textures/textures_srcrec_dstrec.c b/examples/textures/textures_srcrec_dstrec.c
new file mode 100644
index 00000000..6d824ce6
--- /dev/null
+++ b/examples/textures/textures_srcrec_dstrec.c
@@ -0,0 +1,79 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Texture source and destination rectangles
+*
+* 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"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+ Texture2D 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 = { 0, 0, frameWidth, frameHeight };
+
+ // NOTE: Destination rectangle (screen rectangle where drawing part of texture)
+ 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
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+ rotation++;
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ // NOTE: Using DrawTexturePro() we can easily rotate and scale the part of the texture we draw
+ // sourceRec defines the part of the texture we use for drawing
+ // destRec defines the rectangle where our texture part will fit (scaling it to fit)
+ // origin defines the point of the texture used as reference for rotation and scaling
+ // rotation defines the texture rotation (using origin as rotation point)
+ DrawTexturePro(guybrush, sourceRec, destRec, origin, rotation, WHITE);
+
+ DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY);
+ DrawLine(0, destRec.y, screenWidth, destRec.y, GRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(guybrush); // Texture unloading
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+} \ No newline at end of file
diff --git a/examples/textures/textures_srcrec_dstrec.png b/examples/textures/textures_srcrec_dstrec.png
new file mode 100644
index 00000000..9ea00fe4
--- /dev/null
+++ b/examples/textures/textures_srcrec_dstrec.png
Binary files differ
diff --git a/examples/textures/textures_to_image.c b/examples/textures/textures_to_image.c
new file mode 100644
index 00000000..37c3b5a0
--- /dev/null
+++ b/examples/textures/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.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"
+
+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/textures_to_image.png b/examples/textures/textures_to_image.png
new file mode 100644
index 00000000..410103a5
--- /dev/null
+++ b/examples/textures/textures_to_image.png
Binary files differ