From 29067e19d9fd261c9e927eec07bfcb92bc8ab370 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 7 Apr 2017 00:51:08 +0200 Subject: Redesigned textures_rectangle example --- examples/textures/resources/guybrush.png | Bin 85247 -> 0 bytes examples/textures/resources/heightmap.png | Bin 10920 -> 0 bytes examples/textures/resources/scarfy.png | Bin 0 -> 21597 bytes examples/textures/textures_rectangle.c | 55 +++++++++++++++++++++--------- examples/textures/textures_rectangle.png | Bin 109993 -> 39809 bytes 5 files changed, 38 insertions(+), 17 deletions(-) delete mode 100644 examples/textures/resources/guybrush.png delete mode 100644 examples/textures/resources/heightmap.png create mode 100644 examples/textures/resources/scarfy.png (limited to 'examples/textures') diff --git a/examples/textures/resources/guybrush.png b/examples/textures/resources/guybrush.png deleted file mode 100644 index 32c9dced..00000000 Binary files a/examples/textures/resources/guybrush.png and /dev/null differ diff --git a/examples/textures/resources/heightmap.png b/examples/textures/resources/heightmap.png deleted file mode 100644 index fe30f679..00000000 Binary files a/examples/textures/resources/heightmap.png and /dev/null differ diff --git a/examples/textures/resources/scarfy.png b/examples/textures/resources/scarfy.png new file mode 100644 index 00000000..a377a712 Binary files /dev/null and b/examples/textures/resources/scarfy.png differ diff --git a/examples/textures/textures_rectangle.c b/examples/textures/textures_rectangle.c index cca5b216..c90db8ac 100644 --- a/examples/textures/textures_rectangle.c +++ b/examples/textures/textures_rectangle.c @@ -11,6 +11,9 @@ #include "raylib.h" +#define MAX_FRAME_SPEED 15 +#define MIN_FRAME_SPEED 1 + int main() { // Initialization @@ -21,11 +24,16 @@ int main() 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 + Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading - Vector2 position = { 350.0f, 240.0f }; - Rectangle frameRec = { 0, 0, guybrush.width/7, guybrush.height }; + Vector2 position = { 350.0f, 280.0f }; + Rectangle frameRec = { 0, 0, scarfy.width/6, scarfy.height }; int currentFrame = 0; + + int framesCounter = 0; + int framesSpeed = 8; // Number of spritesheet frames shown by second + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop @@ -33,14 +41,23 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_RIGHT)) + framesCounter++; + + if (framesCounter >= (60/framesSpeed)) { + framesCounter = 0; currentFrame++; - if (currentFrame > 6) currentFrame = 0; + if (currentFrame > 5) currentFrame = 0; - frameRec.x = currentFrame*guybrush.width/7; + frameRec.x = currentFrame*scarfy.width/6; } + + if (IsKeyPressed(KEY_RIGHT)) framesSpeed++; + else if (IsKeyPressed(KEY_LEFT)) framesSpeed--; + + if (framesSpeed > MAX_FRAME_SPEED) framesSpeed = MAX_FRAME_SPEED; + else if (framesSpeed < MIN_FRAME_SPEED) framesSpeed = MIN_FRAME_SPEED; //---------------------------------------------------------------------------------- // Draw @@ -49,19 +66,23 @@ int main() 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 + DrawTexture(scarfy, 15, 40, WHITE); + DrawRectangleLines(15, 40, scarfy.width, scarfy.height, LIME); + DrawRectangleLines(15 + frameRec.x, 40 + frameRec.y, frameRec.width, frameRec.height, RED); - DrawRectangleLines(35 + frameRec.x, 40 + frameRec.y, frameRec.width, frameRec.height, RED); + DrawText("FRAME SPEED: ", 165, 210, 10, DARKGRAY); + DrawText(FormatText("%02i FPS", framesSpeed), 575, 210, 10, DARKGRAY); + DrawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, DARKGRAY); - DrawText("PRESS RIGHT KEY to", 540, 310, 10, GRAY); - DrawText("CHANGE DRAWING RECTANGLE", 520, 330, 10, GRAY); + for (int i = 0; i < MAX_FRAME_SPEED; i++) + { + if (i < framesSpeed) DrawRectangle(250 + 21*i, 205, 20, 20, RED); + DrawRectangleLines(250 + 21*i, 205, 20, 20, MAROON); + } - 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); + DrawTextureRec(scarfy, frameRec, position, WHITE); // Draw part of the texture + + DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, GRAY); EndDrawing(); //---------------------------------------------------------------------------------- @@ -69,7 +90,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadTexture(guybrush); // Texture unloading + UnloadTexture(scarfy); // Texture unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/textures/textures_rectangle.png b/examples/textures/textures_rectangle.png index d89404ab..aa66464e 100644 Binary files a/examples/textures/textures_rectangle.png and b/examples/textures/textures_rectangle.png differ -- cgit v1.2.3 From 20d205cae5bf78d00fb03c266999c33488cbd2c8 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 8 Apr 2017 23:31:58 +0200 Subject: Working on examples... --- .gitignore | 1 + docs/examples/web/makefile | 3 - examples/Makefile | 24 - examples/audio/audio_module_playing.c | 2 +- examples/audio/audio_music_stream.c | 2 +- examples/audio/audio_sound_loading.c | 4 +- examples/audio/resources/audio/chiptun1.mod | Bin 2142 -> 0 bytes examples/audio/resources/audio/coin.wav | Bin 4776 -> 0 bytes examples/audio/resources/audio/guitar_noodling.ogg | Bin 506938 -> 0 bytes examples/audio/resources/audio/mini1111.xm | Bin 25676 -> 0 bytes examples/audio/resources/audio/sound.wav | Bin 97512 -> 0 bytes examples/audio/resources/audio/spring.wav | Bin 10850 -> 0 bytes examples/audio/resources/audio/tanatana.flac | Bin 100733 -> 0 bytes examples/audio/resources/audio/tanatana.ogg | Bin 57328 -> 0 bytes examples/audio/resources/audio/weird.wav | Bin 6246 -> 0 bytes examples/audio/resources/chiptun1.mod | Bin 0 -> 2142 bytes examples/audio/resources/coin.wav | Bin 0 -> 4776 bytes examples/audio/resources/guitar_noodling.ogg | Bin 0 -> 506938 bytes examples/audio/resources/mini1111.xm | Bin 0 -> 25676 bytes examples/audio/resources/sound.wav | Bin 0 -> 97512 bytes examples/audio/resources/spring.wav | Bin 0 -> 10850 bytes examples/audio/resources/tanatana.flac | Bin 0 -> 100733 bytes examples/audio/resources/tanatana.ogg | Bin 0 -> 57328 bytes examples/audio/resources/weird.wav | Bin 0 -> 6246 bytes examples/models/models_ray_picking.c | 19 +- examples/models/resources/model/lowpoly-tower.obj | 456 ----------------- examples/models/resources/model/lowpoly-tower.png | Bin 24939 -> 0 bytes examples/models/resources/tower.obj | 456 +++++++++++++++++ examples/models/resources/tower.png | Bin 0 -> 24939 bytes examples/others/font_selector.c | 158 ++++++ examples/others/image_formats_loading.c | 244 ++++++++++ examples/others/oculus_rift.c | 538 +++++++++++++++++++++ examples/others/particles_trail_blending.c | 135 ++++++ examples/others/resources/formats/sonic.png | Bin 0 -> 116512 bytes .../others/resources/formats/sonic_A1R5G5B5.dds | Bin 0 -> 524416 bytes .../others/resources/formats/sonic_A4R4G4B4.dds | Bin 0 -> 524416 bytes .../others/resources/formats/sonic_A8R8G8B8.dds | Bin 0 -> 1048704 bytes .../resources/formats/sonic_ASTC_4x4_ldr.astc | Bin 0 -> 262160 bytes .../resources/formats/sonic_ASTC_8x8_ldr.astc | Bin 0 -> 65552 bytes .../others/resources/formats/sonic_DXT1_RGB.dds | Bin 0 -> 131200 bytes .../others/resources/formats/sonic_DXT1_RGBA.dds | Bin 0 -> 131200 bytes .../others/resources/formats/sonic_DXT3_RGBA.dds | Bin 0 -> 262272 bytes .../others/resources/formats/sonic_DXT5_RGBA.dds | Bin 0 -> 262272 bytes .../others/resources/formats/sonic_ETC1_RGB.ktx | Bin 0 -> 131140 bytes .../others/resources/formats/sonic_ETC1_RGB.pkm | Bin 0 -> 131088 bytes .../resources/formats/sonic_ETC2_EAC_RGBA.ktx | Bin 0 -> 262212 bytes .../resources/formats/sonic_ETC2_EAC_RGBA.old.pkm | Bin 0 -> 262160 bytes .../resources/formats/sonic_ETC2_EAC_RGBA.pkm | Bin 0 -> 262160 bytes .../others/resources/formats/sonic_ETC2_RGB.ktx | Bin 0 -> 131140 bytes .../others/resources/formats/sonic_ETC2_RGB.pkm | Bin 0 -> 131088 bytes .../others/resources/formats/sonic_GRAYSCALE.pvr | Bin 0 -> 262211 bytes examples/others/resources/formats/sonic_L8A8.pvr | Bin 0 -> 524355 bytes .../others/resources/formats/sonic_PVRT_RGB.pvr | Bin 0 -> 131139 bytes .../others/resources/formats/sonic_PVRT_RGBA.pvr | Bin 0 -> 131139 bytes .../resources/formats/sonic_PVRT_RGBA_2bpp.pvr | Bin 0 -> 65603 bytes .../resources/formats/sonic_PVRT_RGB_2bpp.pvr | Bin 0 -> 65603 bytes .../others/resources/formats/sonic_R4G4B4A4.pvr | Bin 0 -> 524355 bytes .../others/resources/formats/sonic_R5G5B5A1.pvr | Bin 0 -> 524355 bytes examples/others/resources/formats/sonic_R5G6B5.dds | Bin 0 -> 524416 bytes examples/others/resources/formats/sonic_R5G6B5.pvr | Bin 0 -> 524355 bytes examples/others/resources/formats/sonic_R8G8B8.pvr | Bin 0 -> 786499 bytes .../others/resources/formats/sonic_R8G8B8A8.pvr | Bin 0 -> 1048643 bytes .../others/resources/formats/sonic_R8G8B8A8.raw | Bin 0 -> 1048576 bytes .../others/resources/shaders/glsl100/standard.fs | 152 ++++++ .../others/resources/shaders/glsl100/standard.vs | 23 + .../others/resources/shaders/glsl330/standard.fs | 150 ++++++ .../others/resources/shaders/glsl330/standard.vs | 23 + examples/others/rlgl_oculus_rift.c | 393 --------------- examples/others/standard_lighting.c | 483 ++++++++++++++++++ examples/shaders/resources/model/lowpoly-tower.obj | 456 ----------------- examples/shaders/resources/model/lowpoly-tower.png | Bin 24939 -> 0 bytes .../shaders/resources/shaders/glsl100/standard.fs | 152 ------ .../shaders/resources/shaders/glsl100/standard.vs | 23 - .../shaders/resources/shaders/glsl330/standard.fs | 150 ------ .../shaders/resources/shaders/glsl330/standard.vs | 23 - examples/shaders/shaders_standard_lighting.c | 482 ------------------ examples/shaders/shaders_standard_lighting.png | Bin 251479 -> 0 bytes examples/text/resources/KAISG.ttf | Bin 0 -> 79912 bytes examples/text/resources/bmfont.fnt | 99 ++++ examples/text/resources/bmfont.png | Bin 0 -> 14471 bytes examples/text/resources/custom_alagard.png | Bin 0 -> 37935 bytes examples/text/resources/custom_jupiter_crash.png | Bin 0 -> 23596 bytes examples/text/resources/custom_mecha.png | Bin 0 -> 26597 bytes examples/text/resources/fonts/KAISG.ttf | Bin 79912 -> 0 bytes examples/text/resources/fonts/bmfont.fnt | 99 ---- examples/text/resources/fonts/bmfont.png | Bin 14471 -> 0 bytes examples/text/resources/fonts/custom_alagard.png | Bin 37935 -> 0 bytes .../text/resources/fonts/custom_jupiter_crash.png | Bin 23596 -> 0 bytes examples/text/resources/fonts/custom_mecha.png | Bin 26597 -> 0 bytes examples/text/resources/fonts/pixantiqua.ttf | Bin 35408 -> 0 bytes examples/text/resources/fonts/pixantiqua_0.png | Bin 4531 -> 0 bytes examples/text/resources/pixantiqua.ttf | Bin 0 -> 35408 bytes examples/text/resources/pixantiqua_0.png | Bin 0 -> 4531 bytes examples/text/text_bmfont_ttf.c | 4 +- examples/text/text_bmfont_unordered.c | 2 +- examples/text/text_font_select.c | 158 ------ examples/text/text_font_select.png | Bin 16261 -> 0 bytes examples/text/text_rbmf_fonts.c | 7 +- examples/text/text_sprite_fonts.c | 6 +- examples/text/text_ttf_loading.c | 2 +- .../textures/resources/texture_formats/sonic.png | Bin 116512 -> 0 bytes .../resources/texture_formats/sonic_A1R5G5B5.dds | Bin 524416 -> 0 bytes .../resources/texture_formats/sonic_A4R4G4B4.dds | Bin 524416 -> 0 bytes .../resources/texture_formats/sonic_A8R8G8B8.dds | Bin 1048704 -> 0 bytes .../texture_formats/sonic_ASTC_4x4_ldr.astc | Bin 262160 -> 0 bytes .../texture_formats/sonic_ASTC_8x8_ldr.astc | Bin 65552 -> 0 bytes .../resources/texture_formats/sonic_DXT1_RGB.dds | Bin 131200 -> 0 bytes .../resources/texture_formats/sonic_DXT1_RGBA.dds | Bin 131200 -> 0 bytes .../resources/texture_formats/sonic_DXT3_RGBA.dds | Bin 262272 -> 0 bytes .../resources/texture_formats/sonic_DXT5_RGBA.dds | Bin 262272 -> 0 bytes .../resources/texture_formats/sonic_ETC1_RGB.ktx | Bin 131140 -> 0 bytes .../resources/texture_formats/sonic_ETC1_RGB.pkm | Bin 131088 -> 0 bytes .../texture_formats/sonic_ETC2_EAC_RGBA.ktx | Bin 262212 -> 0 bytes .../texture_formats/sonic_ETC2_EAC_RGBA.old.pkm | Bin 262160 -> 0 bytes .../texture_formats/sonic_ETC2_EAC_RGBA.pkm | Bin 262160 -> 0 bytes .../resources/texture_formats/sonic_ETC2_RGB.ktx | Bin 131140 -> 0 bytes .../resources/texture_formats/sonic_ETC2_RGB.pkm | Bin 131088 -> 0 bytes .../resources/texture_formats/sonic_GRAYSCALE.pvr | Bin 262211 -> 0 bytes .../resources/texture_formats/sonic_L8A8.pvr | Bin 524355 -> 0 bytes .../resources/texture_formats/sonic_PVRT_RGB.pvr | Bin 131139 -> 0 bytes .../resources/texture_formats/sonic_PVRT_RGBA.pvr | Bin 131139 -> 0 bytes .../texture_formats/sonic_PVRT_RGBA_2bpp.pvr | Bin 65603 -> 0 bytes .../texture_formats/sonic_PVRT_RGB_2bpp.pvr | Bin 65603 -> 0 bytes .../resources/texture_formats/sonic_R4G4B4A4.pvr | Bin 524355 -> 0 bytes .../resources/texture_formats/sonic_R5G5B5A1.pvr | Bin 524355 -> 0 bytes .../resources/texture_formats/sonic_R5G6B5.dds | Bin 524416 -> 0 bytes .../resources/texture_formats/sonic_R5G6B5.pvr | Bin 524355 -> 0 bytes .../resources/texture_formats/sonic_R8G8B8.pvr | Bin 786499 -> 0 bytes .../resources/texture_formats/sonic_R8G8B8A8.pvr | Bin 1048643 -> 0 bytes .../resources/texture_formats/sonic_R8G8B8A8.raw | Bin 1048576 -> 0 bytes examples/textures/textures_formats_loading.c | 244 ---------- examples/textures/textures_formats_loading.png | Bin 125797 -> 0 bytes .../textures/textures_particles_trail_blending.c | 135 ------ .../textures/textures_particles_trail_blending.png | Bin 358260 -> 0 bytes 134 files changed, 2487 insertions(+), 2821 deletions(-) delete mode 100644 examples/audio/resources/audio/chiptun1.mod delete mode 100644 examples/audio/resources/audio/coin.wav delete mode 100644 examples/audio/resources/audio/guitar_noodling.ogg delete mode 100644 examples/audio/resources/audio/mini1111.xm delete mode 100644 examples/audio/resources/audio/sound.wav delete mode 100644 examples/audio/resources/audio/spring.wav delete mode 100644 examples/audio/resources/audio/tanatana.flac delete mode 100644 examples/audio/resources/audio/tanatana.ogg delete mode 100644 examples/audio/resources/audio/weird.wav create mode 100644 examples/audio/resources/chiptun1.mod create mode 100644 examples/audio/resources/coin.wav create mode 100644 examples/audio/resources/guitar_noodling.ogg create mode 100644 examples/audio/resources/mini1111.xm create mode 100644 examples/audio/resources/sound.wav create mode 100644 examples/audio/resources/spring.wav create mode 100644 examples/audio/resources/tanatana.flac create mode 100644 examples/audio/resources/tanatana.ogg create mode 100644 examples/audio/resources/weird.wav delete mode 100644 examples/models/resources/model/lowpoly-tower.obj delete mode 100644 examples/models/resources/model/lowpoly-tower.png create mode 100644 examples/models/resources/tower.obj create mode 100644 examples/models/resources/tower.png create mode 100644 examples/others/font_selector.c create mode 100644 examples/others/image_formats_loading.c create mode 100644 examples/others/oculus_rift.c create mode 100644 examples/others/particles_trail_blending.c create mode 100644 examples/others/resources/formats/sonic.png create mode 100644 examples/others/resources/formats/sonic_A1R5G5B5.dds create mode 100644 examples/others/resources/formats/sonic_A4R4G4B4.dds create mode 100644 examples/others/resources/formats/sonic_A8R8G8B8.dds create mode 100644 examples/others/resources/formats/sonic_ASTC_4x4_ldr.astc create mode 100644 examples/others/resources/formats/sonic_ASTC_8x8_ldr.astc create mode 100644 examples/others/resources/formats/sonic_DXT1_RGB.dds create mode 100644 examples/others/resources/formats/sonic_DXT1_RGBA.dds create mode 100644 examples/others/resources/formats/sonic_DXT3_RGBA.dds create mode 100644 examples/others/resources/formats/sonic_DXT5_RGBA.dds create mode 100644 examples/others/resources/formats/sonic_ETC1_RGB.ktx create mode 100644 examples/others/resources/formats/sonic_ETC1_RGB.pkm create mode 100644 examples/others/resources/formats/sonic_ETC2_EAC_RGBA.ktx create mode 100644 examples/others/resources/formats/sonic_ETC2_EAC_RGBA.old.pkm create mode 100644 examples/others/resources/formats/sonic_ETC2_EAC_RGBA.pkm create mode 100644 examples/others/resources/formats/sonic_ETC2_RGB.ktx create mode 100644 examples/others/resources/formats/sonic_ETC2_RGB.pkm create mode 100644 examples/others/resources/formats/sonic_GRAYSCALE.pvr create mode 100644 examples/others/resources/formats/sonic_L8A8.pvr create mode 100644 examples/others/resources/formats/sonic_PVRT_RGB.pvr create mode 100644 examples/others/resources/formats/sonic_PVRT_RGBA.pvr create mode 100644 examples/others/resources/formats/sonic_PVRT_RGBA_2bpp.pvr create mode 100644 examples/others/resources/formats/sonic_PVRT_RGB_2bpp.pvr create mode 100644 examples/others/resources/formats/sonic_R4G4B4A4.pvr create mode 100644 examples/others/resources/formats/sonic_R5G5B5A1.pvr create mode 100644 examples/others/resources/formats/sonic_R5G6B5.dds create mode 100644 examples/others/resources/formats/sonic_R5G6B5.pvr create mode 100644 examples/others/resources/formats/sonic_R8G8B8.pvr create mode 100644 examples/others/resources/formats/sonic_R8G8B8A8.pvr create mode 100644 examples/others/resources/formats/sonic_R8G8B8A8.raw create mode 100644 examples/others/resources/shaders/glsl100/standard.fs create mode 100644 examples/others/resources/shaders/glsl100/standard.vs create mode 100644 examples/others/resources/shaders/glsl330/standard.fs create mode 100644 examples/others/resources/shaders/glsl330/standard.vs delete mode 100644 examples/others/rlgl_oculus_rift.c create mode 100644 examples/others/standard_lighting.c delete mode 100644 examples/shaders/resources/model/lowpoly-tower.obj delete mode 100644 examples/shaders/resources/model/lowpoly-tower.png delete mode 100644 examples/shaders/resources/shaders/glsl100/standard.fs delete mode 100644 examples/shaders/resources/shaders/glsl100/standard.vs delete mode 100644 examples/shaders/resources/shaders/glsl330/standard.fs delete mode 100644 examples/shaders/resources/shaders/glsl330/standard.vs delete mode 100644 examples/shaders/shaders_standard_lighting.c delete mode 100644 examples/shaders/shaders_standard_lighting.png create mode 100644 examples/text/resources/KAISG.ttf create mode 100644 examples/text/resources/bmfont.fnt create mode 100644 examples/text/resources/bmfont.png create mode 100644 examples/text/resources/custom_alagard.png create mode 100644 examples/text/resources/custom_jupiter_crash.png create mode 100644 examples/text/resources/custom_mecha.png delete mode 100644 examples/text/resources/fonts/KAISG.ttf delete mode 100644 examples/text/resources/fonts/bmfont.fnt delete mode 100644 examples/text/resources/fonts/bmfont.png delete mode 100644 examples/text/resources/fonts/custom_alagard.png delete mode 100644 examples/text/resources/fonts/custom_jupiter_crash.png delete mode 100644 examples/text/resources/fonts/custom_mecha.png delete mode 100644 examples/text/resources/fonts/pixantiqua.ttf delete mode 100644 examples/text/resources/fonts/pixantiqua_0.png create mode 100644 examples/text/resources/pixantiqua.ttf create mode 100644 examples/text/resources/pixantiqua_0.png delete mode 100644 examples/text/text_font_select.c delete mode 100644 examples/text/text_font_select.png delete mode 100644 examples/textures/resources/texture_formats/sonic.png delete mode 100644 examples/textures/resources/texture_formats/sonic_A1R5G5B5.dds delete mode 100644 examples/textures/resources/texture_formats/sonic_A4R4G4B4.dds delete mode 100644 examples/textures/resources/texture_formats/sonic_A8R8G8B8.dds delete mode 100644 examples/textures/resources/texture_formats/sonic_ASTC_4x4_ldr.astc delete mode 100644 examples/textures/resources/texture_formats/sonic_ASTC_8x8_ldr.astc delete mode 100644 examples/textures/resources/texture_formats/sonic_DXT1_RGB.dds delete mode 100644 examples/textures/resources/texture_formats/sonic_DXT1_RGBA.dds delete mode 100644 examples/textures/resources/texture_formats/sonic_DXT3_RGBA.dds delete mode 100644 examples/textures/resources/texture_formats/sonic_DXT5_RGBA.dds delete mode 100644 examples/textures/resources/texture_formats/sonic_ETC1_RGB.ktx delete mode 100644 examples/textures/resources/texture_formats/sonic_ETC1_RGB.pkm delete mode 100644 examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx delete mode 100644 examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm delete mode 100644 examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm delete mode 100644 examples/textures/resources/texture_formats/sonic_ETC2_RGB.ktx delete mode 100644 examples/textures/resources/texture_formats/sonic_ETC2_RGB.pkm delete mode 100644 examples/textures/resources/texture_formats/sonic_GRAYSCALE.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_L8A8.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_PVRT_RGB.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_PVRT_RGBA.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_R4G4B4A4.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_R5G5B5A1.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_R5G6B5.dds delete mode 100644 examples/textures/resources/texture_formats/sonic_R5G6B5.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_R8G8B8.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_R8G8B8A8.pvr delete mode 100644 examples/textures/resources/texture_formats/sonic_R8G8B8A8.raw delete mode 100644 examples/textures/textures_formats_loading.c delete mode 100644 examples/textures/textures_formats_loading.png delete mode 100644 examples/textures/textures_particles_trail_blending.c delete mode 100644 examples/textures/textures_particles_trail_blending.png (limited to 'examples/textures') diff --git a/.gitignore b/.gitignore index b1bcf1b6..664168ef 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ Thumbs.db *.sbr *.sdf obj/ +[Rr]elease/ [Rr]elease.win32/ _ReSharper*/ [Tt]est[Rr]esult* diff --git a/docs/examples/web/makefile b/docs/examples/web/makefile index 139b3e8a..05d65f58 100644 --- a/docs/examples/web/makefile +++ b/docs/examples/web/makefile @@ -238,15 +238,12 @@ EXAMPLES = \ textures_srcrec_dstrec \ textures_to_image \ textures_raw_data \ - textures_formats_loading \ - textures_particles_trail_blending \ textures_image_processing \ textures_image_drawing \ text_sprite_fonts \ text_bmfont_ttf \ text_rbmf_fonts \ text_format_text \ - text_font_select \ text_writing_anim \ text_ttf_loading \ text_bmfont_unordered \ diff --git a/examples/Makefile b/examples/Makefile index 58e8cb50..205c6924 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -238,15 +238,12 @@ EXAMPLES = \ textures/textures_srcrec_dstrec \ textures/textures_to_image \ textures/textures_raw_data \ - textures/textures_formats_loading \ - textures/textures_particles_trail_blending \ textures/textures_image_processing \ textures/textures_image_drawing \ text/text_sprite_fonts \ text/text_bmfont_ttf \ text/text_rbmf_fonts \ text/text_format_text \ - text/text_font_select \ text/text_writing_anim \ text/text_ttf_loading \ text/text_bmfont_unordered \ @@ -261,7 +258,6 @@ EXAMPLES = \ shaders/shaders_shapes_textures \ shaders/shaders_custom_uniform \ shaders/shaders_postprocessing \ - shaders/shaders_standard_lighting \ audio/audio_sound_loading \ audio/audio_music_stream \ audio/audio_module_playing \ @@ -303,11 +299,7 @@ core/core_mouse_wheel: core/core_mouse_wheel.c # compile [core] example - gamepad input core/core_input_gamepad: core/core_input_gamepad.c -ifeq ($(PLATFORM), $(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_RPI)) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) -else - @echo core_input_gamepad: Example not supported on PLATFORM_ANDROID or PLATFORM_WEB -endif # compile [core] example - generate random values core/core_random_values: core/core_random_values.c @@ -405,14 +397,6 @@ textures/textures_to_image: textures/textures_to_image.c textures/textures_raw_data: textures/textures_raw_data.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) -# compile [textures] example - texture formats loading -textures/textures_formats_loading: textures/textures_formats_loading.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) - -# compile [textures] example - texture particles trail blending -textures/textures_particles_trail_blending: textures/textures_particles_trail_blending.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) - # compile [textures] example - texture image processing textures/textures_image_processing: textures/textures_image_processing.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) @@ -437,10 +421,6 @@ text/text_rbmf_fonts: text/text_rbmf_fonts.c text/text_format_text: text/text_format_text.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) -# compile [text] example - font selection program -text/text_font_select: text/text_font_select.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) - # compile [text] example - text writing animation text/text_writing_anim: text/text_writing_anim.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) @@ -501,10 +481,6 @@ shaders/shaders_custom_uniform: shaders/shaders_custom_uniform.c shaders/shaders_postprocessing: shaders/shaders_postprocessing.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) -# compile [shaders] example - standard lighting -shaders/shaders_standard_lighting: shaders/shaders_standard_lighting.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) - # compile [audio] example - sound loading and playing (WAV and OGG) audio/audio_sound_loading: audio/audio_sound_loading.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) diff --git a/examples/audio/audio_module_playing.c b/examples/audio/audio_module_playing.c index 08ae2b05..671a119f 100644 --- a/examples/audio/audio_module_playing.c +++ b/examples/audio/audio_module_playing.c @@ -52,7 +52,7 @@ int main() circles[i].color = colors[GetRandomValue(0, 13)]; } - Music xm = LoadMusicStream("resources/audio/mini1111.xm"); + Music xm = LoadMusicStream("resources/mini1111.xm"); PlayMusicStream(xm); diff --git a/examples/audio/audio_music_stream.c b/examples/audio/audio_music_stream.c index 9c1ca4df..f9fe23d2 100644 --- a/examples/audio/audio_music_stream.c +++ b/examples/audio/audio_music_stream.c @@ -24,7 +24,7 @@ int main() InitAudioDevice(); // Initialize audio device - Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg"); + Music music = LoadMusicStream("resources/guitar_noodling.ogg"); PlayMusicStream(music); diff --git a/examples/audio/audio_sound_loading.c b/examples/audio/audio_sound_loading.c index feb30563..00e58326 100644 --- a/examples/audio/audio_sound_loading.c +++ b/examples/audio/audio_sound_loading.c @@ -24,8 +24,8 @@ int main() InitAudioDevice(); // Initialize audio device - Sound fxWav = LoadSound("resources/audio/sound.wav"); // Load WAV audio file - Sound fxOgg = LoadSound("resources/audio/tanatana.ogg"); // Load OGG audio file + Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file + Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file SetTargetFPS(60); //-------------------------------------------------------------------------------------- diff --git a/examples/audio/resources/audio/chiptun1.mod b/examples/audio/resources/audio/chiptun1.mod deleted file mode 100644 index 00d16885..00000000 Binary files a/examples/audio/resources/audio/chiptun1.mod and /dev/null differ diff --git a/examples/audio/resources/audio/coin.wav b/examples/audio/resources/audio/coin.wav deleted file mode 100644 index 6007509b..00000000 Binary files a/examples/audio/resources/audio/coin.wav and /dev/null differ diff --git a/examples/audio/resources/audio/guitar_noodling.ogg b/examples/audio/resources/audio/guitar_noodling.ogg deleted file mode 100644 index f5022040..00000000 Binary files a/examples/audio/resources/audio/guitar_noodling.ogg and /dev/null differ diff --git a/examples/audio/resources/audio/mini1111.xm b/examples/audio/resources/audio/mini1111.xm deleted file mode 100644 index a185c1a2..00000000 Binary files a/examples/audio/resources/audio/mini1111.xm and /dev/null differ diff --git a/examples/audio/resources/audio/sound.wav b/examples/audio/resources/audio/sound.wav deleted file mode 100644 index b5d01c9b..00000000 Binary files a/examples/audio/resources/audio/sound.wav and /dev/null differ diff --git a/examples/audio/resources/audio/spring.wav b/examples/audio/resources/audio/spring.wav deleted file mode 100644 index c7fbf1b9..00000000 Binary files a/examples/audio/resources/audio/spring.wav and /dev/null differ diff --git a/examples/audio/resources/audio/tanatana.flac b/examples/audio/resources/audio/tanatana.flac deleted file mode 100644 index dfe735cd..00000000 Binary files a/examples/audio/resources/audio/tanatana.flac and /dev/null differ diff --git a/examples/audio/resources/audio/tanatana.ogg b/examples/audio/resources/audio/tanatana.ogg deleted file mode 100644 index 90b1795a..00000000 Binary files a/examples/audio/resources/audio/tanatana.ogg and /dev/null differ diff --git a/examples/audio/resources/audio/weird.wav b/examples/audio/resources/audio/weird.wav deleted file mode 100644 index 101029c5..00000000 Binary files a/examples/audio/resources/audio/weird.wav and /dev/null differ diff --git a/examples/audio/resources/chiptun1.mod b/examples/audio/resources/chiptun1.mod new file mode 100644 index 00000000..00d16885 Binary files /dev/null and b/examples/audio/resources/chiptun1.mod differ diff --git a/examples/audio/resources/coin.wav b/examples/audio/resources/coin.wav new file mode 100644 index 00000000..6007509b Binary files /dev/null and b/examples/audio/resources/coin.wav differ diff --git a/examples/audio/resources/guitar_noodling.ogg b/examples/audio/resources/guitar_noodling.ogg new file mode 100644 index 00000000..f5022040 Binary files /dev/null and b/examples/audio/resources/guitar_noodling.ogg differ diff --git a/examples/audio/resources/mini1111.xm b/examples/audio/resources/mini1111.xm new file mode 100644 index 00000000..a185c1a2 Binary files /dev/null and b/examples/audio/resources/mini1111.xm differ diff --git a/examples/audio/resources/sound.wav b/examples/audio/resources/sound.wav new file mode 100644 index 00000000..b5d01c9b Binary files /dev/null and b/examples/audio/resources/sound.wav differ diff --git a/examples/audio/resources/spring.wav b/examples/audio/resources/spring.wav new file mode 100644 index 00000000..c7fbf1b9 Binary files /dev/null and b/examples/audio/resources/spring.wav differ diff --git a/examples/audio/resources/tanatana.flac b/examples/audio/resources/tanatana.flac new file mode 100644 index 00000000..dfe735cd Binary files /dev/null and b/examples/audio/resources/tanatana.flac differ diff --git a/examples/audio/resources/tanatana.ogg b/examples/audio/resources/tanatana.ogg new file mode 100644 index 00000000..90b1795a Binary files /dev/null and b/examples/audio/resources/tanatana.ogg differ diff --git a/examples/audio/resources/weird.wav b/examples/audio/resources/weird.wav new file mode 100644 index 00000000..101029c5 Binary files /dev/null and b/examples/audio/resources/weird.wav differ diff --git a/examples/models/models_ray_picking.c b/examples/models/models_ray_picking.c index 67b13155..55914fa2 100644 --- a/examples/models/models_ray_picking.c +++ b/examples/models/models_ray_picking.c @@ -11,7 +11,7 @@ ********************************************************************************************/ #include "raylib.h" -#include "../src/raymath.h" +#include "raymath.h" #include #include @@ -28,19 +28,19 @@ int main() // Define the camera to look into our 3d world Camera camera; - camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position + camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position camera.target = (Vector3){ 0.0f, 2.3f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 45.0f; // Camera field-of-view Y Ray ray; // Picking line ray - Model tower = LoadModel("resources/model/lowpoly-tower.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/model/lowpoly-tower.png"); // Load model texture - tower.material.texDiffuse = texture; // Set model diffuse texture + Model tower = LoadModel("resources/tower.obj"); // Load OBJ model + Texture2D texture = LoadTexture("resources/tower.png"); // Load model texture + tower.material.texDiffuse = texture; // Set model diffuse texture - Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position - BoundingBox towerBBox = CalculateBoundingBox( tower.mesh ); + Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position + BoundingBox towerBBox = CalculateBoundingBox(tower.mesh); bool hitMeshBBox = false; bool hitTriangle = false; @@ -187,7 +187,10 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context + UnloadModel(tower); // Unload model + UnloadTexture(texture); // Unload texture + + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; diff --git a/examples/models/resources/model/lowpoly-tower.obj b/examples/models/resources/model/lowpoly-tower.obj deleted file mode 100644 index ea03a9fc..00000000 --- a/examples/models/resources/model/lowpoly-tower.obj +++ /dev/null @@ -1,456 +0,0 @@ -# Blender v2.78 (sub 0) OBJ File: 'lowpoly-tower.blend' -# www.blender.org -o Grid -v -4.000000 0.000000 4.000000 -v -2.327363 0.000000 4.654725 -v 0.000000 0.000000 4.654725 -v 2.327363 0.000000 4.654725 -v 4.000000 0.000000 4.000000 -v -4.654725 0.955085 2.327363 -v -2.000000 0.815050 2.000000 -v 0.000000 0.476341 2.423448 -v 2.000000 0.476341 2.000000 -v 4.654725 0.000000 2.327363 -v -4.654725 1.649076 0.000000 -v -2.423448 1.092402 0.000000 -v 2.423448 0.198579 0.000000 -v 4.654725 0.000000 0.000000 -v -4.654725 1.649076 -2.327363 -v -2.000000 1.092402 -2.000000 -v 0.000000 0.476341 -2.423448 -v 2.000000 -0.012791 -2.000000 -v 4.654725 0.000000 -2.612731 -v -4.000000 0.955085 -4.000000 -v -2.327363 0.955085 -4.654725 -v 0.000000 0.955085 -4.654725 -v 2.327363 0.000000 -4.654725 -v 4.000000 0.000000 -4.000000 -v 2.423448 0.682825 0.000000 -v 2.000000 0.565423 -2.000000 -v -4.654725 -0.020560 2.327363 -v -4.654725 0.000000 0.000000 -v -4.654725 0.000000 -2.327363 -v -4.000000 0.000000 -4.000000 -v -2.327363 0.000000 -4.654725 -v 0.000000 -0.020560 -4.654725 -v 0.000000 0.709880 -1.230535 -v -0.000000 7.395413 0.000000 -v 0.962071 0.709880 -0.767226 -v -0.533909 0.709880 1.108674 -v -1.199683 0.709880 0.273820 -v -0.962071 0.709880 -0.767226 -v 1.506076 0.859071 1.325337 -v 1.199683 0.709880 0.273820 -v 0.533909 0.709880 1.108674 -v 0.000000 1.875340 -1.177842 -v -0.000000 2.293973 -0.649884 -v -0.000000 4.365648 -0.627970 -v 0.000000 6.167194 -0.942957 -v 0.000000 6.232434 -1.708677 -v 1.335898 6.232434 -1.065343 -v 0.737233 6.167195 -0.587924 -v 0.490966 4.365648 -0.391533 -v 0.508100 2.293973 -0.405196 -v 0.920874 1.875340 -0.734372 -v -0.741367 6.232434 1.539465 -v -0.409133 6.167195 0.849574 -v -0.272466 4.365648 0.565781 -v -0.281974 2.293973 0.585526 -v -0.511047 1.875340 1.061199 -v -1.665837 6.232434 0.380217 -v -0.919314 6.167195 0.209828 -v -0.612225 4.365648 0.139736 -v -0.633590 2.293973 0.144613 -v -1.148311 1.875340 0.262095 -v -1.335898 6.232434 -1.065343 -v -0.737233 6.167195 -0.587924 -v -0.490967 4.365648 -0.391533 -v -0.508100 2.293973 -0.405196 -v -0.920874 1.875340 -0.734372 -v 1.665837 6.232434 0.380216 -v 0.919315 6.167195 0.209828 -v 0.612225 4.365648 0.139736 -v 0.633590 2.293973 0.144613 -v 1.148311 1.875340 0.262095 -v 0.741367 6.232434 1.539465 -v 0.409133 6.167195 0.849575 -v 0.272466 4.365648 0.565781 -v 0.281974 2.293973 0.585526 -v 0.511046 1.875340 1.061199 -v 0.000000 5.012550 -0.969733 -v 0.758168 5.012550 -0.604618 -v -0.420751 5.012550 0.873699 -v -0.945419 5.012550 0.215786 -v -0.758168 5.012550 -0.604618 -v 0.945419 5.012550 0.215786 -v 0.420751 5.012550 0.873699 -vt 0.0523 0.5444 -vt 0.1817 0.4284 -vt 0.1641 0.5859 -vt 0.0177 0.4451 -vt 0.1526 0.3090 -vt 0.0189 0.1737 -vt 0.0188 0.3088 -vt 0.0561 0.0762 -vt 0.1757 0.1924 -vt 0.3024 0.4534 -vt 0.3071 0.5902 -vt 0.3413 0.2459 -vt 0.2906 0.1614 -vt 0.4116 0.1801 -vt 0.2834 0.3774 -vt 0.1526 0.0362 -vt 0.2917 0.1622 -vt 0.4446 0.5865 -vt 0.4443 0.2989 -vt 0.3711 0.3021 -vt 0.4396 0.0275 -vt 0.4094 0.1829 -vt 0.4219 0.4255 -vt 0.5474 0.5381 -vt 0.5811 0.4376 -vt 0.5715 0.1505 -vt 0.5811 0.2997 -vt 0.5272 0.0533 -vt 0.2208 0.2194 -vt 0.3456 0.3610 -vt 0.2878 0.0321 -vt 0.2321 0.3392 -vt 0.4432 0.0177 -vt 0.7347 0.7934 -vt 0.7382 0.7595 -vt 0.8982 0.7768 -vt 0.6169 0.7595 -vt 0.6139 0.7879 -vt 0.4951 0.7634 -vt 0.1551 0.6832 -vt 0.2925 0.6268 -vt 0.2925 0.6832 -vt 0.7795 0.6832 -vt 0.6421 0.6268 -vt 0.7795 0.6255 -vt 0.5046 0.7241 -vt 0.6421 0.7241 -vt 0.3986 0.6268 -vt 0.3986 0.6832 -vt 0.5046 0.6268 -vt 0.0177 0.6268 -vt 0.1551 0.6255 -vt 0.8856 0.6268 -vt 0.1899 0.9579 -vt 0.1194 0.8696 -vt 0.2324 0.8696 -vt 0.1899 0.7813 -vt 0.0943 0.7595 -vt 0.0177 0.8206 -vt 0.0177 0.9186 -vt 0.0943 0.9797 -vt 0.2793 0.2349 -vt 0.2304 0.2758 -vt 0.6597 0.0177 -vt 0.6954 0.0993 -vt 0.6367 0.0768 -vt 0.7558 0.0777 -vt 0.7238 0.0440 -vt 0.8840 0.1330 -vt 0.7385 0.1141 -vt 0.9157 0.0886 -vt 0.9781 0.1232 -vt 0.9224 0.1276 -vt 0.2677 0.8141 -vt 0.3463 0.8037 -vt 0.3086 0.8339 -vt 0.6387 0.3550 -vt 0.7130 0.3801 -vt 0.6596 0.4053 -vt 0.7245 0.3245 -vt 0.6919 0.3383 -vt 0.8655 0.3566 -vt 0.7351 0.3577 -vt 0.9770 0.3365 -vt 0.9078 0.3751 -vt 0.9174 0.3282 -vt 0.2677 0.9018 -vt 0.3086 0.8821 -vt 0.6803 0.2948 -vt 0.6251 0.3035 -vt 0.7194 0.2854 -vt 0.8764 0.2832 -vt 0.9221 0.2861 -vt 0.3363 0.9565 -vt 0.3464 0.9122 -vt 0.6751 0.2482 -vt 0.6178 0.2499 -vt 0.7179 0.2431 -vt 0.9823 0.2484 -vt 0.9247 0.2452 -vt 0.3935 0.9014 -vt 0.6755 0.1996 -vt 0.6164 0.1941 -vt 0.7201 0.1992 -vt 0.8793 0.2446 -vt 0.9823 0.2060 -vt 0.9257 0.2051 -vt 0.4598 0.8580 -vt 0.4144 0.8579 -vt 0.6819 0.1498 -vt 0.6222 0.1361 -vt 0.7266 0.1555 -vt 0.8831 0.1684 -vt 0.9252 0.1659 -vt 0.4218 0.7790 -vt 0.3934 0.8145 -vt 0.3363 0.7595 -vt 0.8815 0.2060 -vt 0.8720 0.3208 -vt 0.8825 0.1012 -vt 0.9735 0.0816 -vt 0.9718 0.3817 -vt 0.9807 0.2918 -vt 0.4218 0.9370 -vt 0.9810 0.1644 -vn 0.1035 0.8806 0.4623 -vn 0.0964 0.9481 0.3030 -vn 0.0000 0.9780 0.2088 -vn 0.0659 0.9835 0.1683 -vn 0.2325 0.9320 0.2779 -vn 0.0553 0.9960 -0.0702 -vn 0.2827 0.9564 0.0728 -vn 0.1873 0.9776 -0.0961 -vn 0.2421 0.9703 0.0000 -vn 0.0921 0.9772 -0.1913 -vn -0.0277 0.9947 -0.0993 -vn 0.2308 0.9274 -0.2944 -vn 0.2771 0.9572 -0.0837 -vn 0.3724 0.9074 0.1947 -vn 0.0777 0.9770 -0.1985 -vn -0.1094 0.9539 0.2794 -vn 0.0364 0.9844 0.1721 -vn 0.1683 0.9835 0.0659 -vn 0.0674 0.9901 0.1230 -vn 0.4338 0.8823 0.1829 -vn 0.2845 0.9565 0.0649 -vn 0.0886 0.9961 0.0000 -vn 0.2000 0.9789 0.0424 -vn 0.1417 0.9830 0.1171 -vn 0.3021 0.9524 0.0412 -vn -0.0193 0.9986 -0.0493 -vn 0.0000 0.9777 0.2098 -vn 0.0005 0.9781 -0.2083 -vn 0.1879 0.9782 -0.0887 -vn 0.2249 0.0000 0.9744 -vn 0.9783 0.0000 -0.2071 -vn 0.9783 0.0000 0.2071 -vn 0.0000 0.0000 -1.0000 -vn -1.0000 0.0000 0.0000 -vn -0.3645 0.0000 -0.9312 -vn -0.9312 0.0000 -0.3645 -vn -0.9312 0.0000 0.3645 -vn 0.2615 0.7979 -0.5431 -vn 0.5877 0.7979 -0.1341 -vn 0.4713 0.7979 0.3758 -vn -0.0000 0.7979 0.6028 -vn -0.4713 0.7979 0.3758 -vn -0.5877 0.7979 -0.1341 -vn -0.2615 0.7979 -0.5431 -vn -0.1285 0.9864 -0.1025 -vn 0.0929 0.8937 0.4389 -vn -0.4335 0.0407 -0.9002 -vn -0.2867 0.7507 -0.5952 -vn -0.4339 0.0095 -0.9009 -vn -0.4338 0.0209 -0.9008 -vn -0.0408 -0.9956 -0.0848 -vn -0.9741 0.0407 -0.2223 -vn -0.6441 0.7507 -0.1470 -vn -0.9749 0.0095 -0.2225 -vn -0.9747 0.0209 -0.2225 -vn -0.0918 -0.9956 -0.0209 -vn -0.7812 0.0407 0.6230 -vn -0.5165 0.7507 0.4119 -vn -0.7818 0.0095 0.6235 -vn -0.7817 0.0209 0.6234 -vn -0.0736 -0.9956 0.0587 -vn -0.0000 0.0407 0.9992 -vn 0.0000 0.7507 0.6607 -vn 0.0000 0.0095 1.0000 -vn -0.0000 0.0209 0.9998 -vn -0.0000 -0.9956 0.0941 -vn 0.7812 0.0407 0.6230 -vn 0.5165 0.7507 0.4119 -vn 0.7818 0.0095 0.6235 -vn 0.7817 0.0209 0.6234 -vn 0.0736 -0.9956 0.0587 -vn 0.9741 0.0407 -0.2223 -vn 0.6441 0.7507 -0.1470 -vn 0.9749 0.0095 -0.2225 -vn 0.9747 0.0209 -0.2225 -vn 0.0918 -0.9956 -0.0209 -vn 0.4335 0.0407 -0.9002 -vn 0.2867 0.7507 -0.5952 -vn 0.4339 0.0095 -0.9009 -vn 0.4338 0.0209 -0.9008 -vn 0.0408 -0.9956 -0.0848 -vn 0.3918 -0.4298 -0.8135 -vn 0.8803 -0.4298 -0.2009 -vn 0.7059 -0.4298 0.5630 -vn -0.0000 -0.4298 0.9029 -vn -0.7059 -0.4298 0.5630 -vn -0.8803 -0.4298 -0.2009 -vn -0.3918 -0.4298 -0.8135 -vn 0.0210 0.9998 -0.0048 -vn 0.0482 0.9981 -0.0385 -vn -0.0166 0.9914 -0.1301 -vn -0.0090 0.9904 -0.1379 -vn 0.2820 0.9576 0.0597 -vn -0.0000 0.9846 0.1749 -vn -0.0921 0.9772 -0.1913 -vn -0.1734 0.9794 0.1036 -s off -f 1/1/1 7/2/1 6/3/1 -f 2/4/2 8/5/2 7/2/2 -f 4/6/3 8/5/3 3/7/3 -f 5/8/4 9/9/4 4/6/4 -f 6/3/5 12/10/5 11/11/5 -f 35/12/6 25/13/6 26/14/6 -f 7/2/7 37/15/7 12/10/7 -f 10/16/8 13/17/8 9/9/8 -f 12/10/9 15/18/9 11/11/9 -f 35/12/10 17/19/10 33/20/10 -f 13/17/11 19/21/11 18/22/11 -f 16/23/12 20/24/12 15/18/12 -f 17/19/13 21/25/13 16/23/13 -f 17/19/14 23/26/14 22/27/14 -f 26/14/15 24/28/15 23/26/15 -f 1/1/16 2/4/16 7/2/16 -f 2/4/3 3/7/3 8/5/3 -f 4/6/17 9/9/17 8/5/17 -f 5/8/18 10/16/18 9/9/18 -f 6/3/19 7/2/19 12/10/19 -f 25/13/20 39/29/20 9/9/20 -f 38/30/21 12/10/21 37/15/21 -f 10/16/22 14/31/22 13/17/22 -f 12/10/23 16/23/23 15/18/23 -f 8/5/24 36/32/24 7/2/24 -f 38/30/25 17/19/25 16/23/25 -f 13/17/22 14/31/22 19/21/22 -f 16/23/26 21/25/26 20/24/26 -f 17/19/27 22/27/27 21/25/27 -f 17/19/28 26/14/28 23/26/28 -f 26/14/29 19/33/29 24/28/29 -f 26/34/30 18/35/30 19/36/30 -f 26/34/31 13/37/31 18/35/31 -f 25/38/32 9/39/32 13/37/32 -f 22/40/33 31/41/33 21/42/33 -f 6/43/34 28/44/34 27/45/34 -f 15/46/34 28/44/34 11/47/34 -f 21/42/35 30/48/35 20/49/35 -f 20/49/36 29/50/36 15/46/36 -f 22/40/33 23/51/33 32/52/33 -f 6/43/37 27/45/37 1/53/37 -f 46/54/38 34/55/38 47/56/38 -f 47/56/39 34/55/39 67/57/39 -f 67/57/40 34/55/40 72/58/40 -f 72/58/41 34/55/41 52/59/41 -f 52/59/42 34/55/42 57/60/42 -f 57/60/43 34/55/43 62/61/43 -f 62/61/44 34/55/44 46/54/44 -f 40/62/45 41/63/45 39/29/45 -f 39/29/46 8/5/46 9/9/46 -f 38/64/47 42/65/47 33/66/47 -f 65/67/48 42/65/48 66/68/48 -f 65/67/49 44/69/49 43/70/49 -f 81/71/50 45/72/50 77/73/50 -f 62/74/51 45/75/51 63/76/51 -f 37/77/52 66/78/52 38/79/52 -f 60/80/53 66/78/53 61/81/53 -f 60/80/54 64/82/54 65/83/54 -f 58/84/55 81/85/55 80/86/55 -f 57/87/56 63/76/56 58/88/56 -f 56/89/57 37/77/57 36/90/57 -f 55/91/58 61/81/58 56/89/58 -f 54/92/59 60/80/59 55/91/59 -f 79/93/60 58/84/60 80/86/60 -f 52/94/61 58/88/61 53/95/61 -f 76/96/62 36/90/62 41/97/62 -f 75/98/63 56/89/63 76/96/63 -f 75/98/64 54/92/64 55/91/64 -f 73/99/65 79/93/65 83/100/65 -f 73/101/66 52/94/66 53/95/66 -f 71/102/67 41/97/67 40/103/67 -f 70/104/68 76/96/68 71/102/68 -f 70/104/69 74/105/69 75/98/69 -f 68/106/70 83/100/70 82/107/70 -f 67/108/71 73/101/71 68/109/71 -f 51/110/72 40/103/72 35/111/72 -f 50/112/73 71/102/73 51/110/73 -f 49/113/74 70/104/74 50/112/74 -f 78/114/75 68/106/75 82/107/75 -f 47/115/76 68/109/76 48/116/76 -f 42/65/77 35/111/77 33/66/77 -f 43/70/78 51/110/78 42/65/78 -f 44/69/79 50/112/79 43/70/79 -f 45/72/80 78/114/80 77/73/80 -f 46/117/81 48/116/81 45/75/81 -f 44/69/82 78/114/82 49/113/82 -f 49/113/83 82/107/83 69/118/83 -f 82/107/84 74/105/84 69/118/84 -f 83/100/85 54/92/85 74/105/85 -f 79/93/86 59/119/86 54/92/86 -f 80/86/87 64/82/87 59/119/87 -f 64/120/88 77/73/88 44/69/88 -f 35/12/89 40/62/89 25/13/89 -f 7/2/90 36/32/90 37/15/90 -f 35/12/91 26/14/91 17/19/91 -f 25/13/92 40/62/92 39/29/92 -f 38/30/93 16/23/93 12/10/93 -f 8/5/94 41/63/94 36/32/94 -f 38/30/95 33/20/95 17/19/95 -f 26/34/31 25/38/31 13/37/31 -f 22/40/33 32/52/33 31/41/33 -f 6/43/34 11/47/34 28/44/34 -f 15/46/34 29/50/34 28/44/34 -f 21/42/35 31/41/35 30/48/35 -f 20/49/36 30/48/36 29/50/36 -f 39/29/96 41/63/96 8/5/96 -f 38/64/47 66/68/47 42/65/47 -f 65/67/48 43/70/48 42/65/48 -f 65/67/49 64/120/49 44/69/49 -f 81/71/50 63/121/50 45/72/50 -f 62/74/51 46/117/51 45/75/51 -f 37/77/52 61/81/52 66/78/52 -f 60/80/53 65/83/53 66/78/53 -f 60/80/54 59/119/54 64/82/54 -f 58/84/55 63/122/55 81/85/55 -f 57/87/56 62/74/56 63/76/56 -f 56/89/57 61/81/57 37/77/57 -f 55/91/58 60/80/58 61/81/58 -f 54/92/59 59/119/59 60/80/59 -f 79/93/60 53/123/60 58/84/60 -f 52/94/61 57/87/61 58/88/61 -f 76/96/62 56/89/62 36/90/62 -f 75/98/63 55/91/63 56/89/63 -f 75/98/64 74/105/64 54/92/64 -f 73/99/65 53/123/65 79/93/65 -f 73/101/66 72/124/66 52/94/66 -f 71/102/67 76/96/67 41/97/67 -f 70/104/68 75/98/68 76/96/68 -f 70/104/69 69/118/69 74/105/69 -f 68/106/70 73/99/70 83/100/70 -f 67/108/71 72/124/71 73/101/71 -f 51/110/72 71/102/72 40/103/72 -f 50/112/73 70/104/73 71/102/73 -f 49/113/74 69/118/74 70/104/74 -f 78/114/75 48/125/75 68/106/75 -f 47/115/76 67/108/76 68/109/76 -f 42/65/77 51/110/77 35/111/77 -f 43/70/78 50/112/78 51/110/78 -f 44/69/79 49/113/79 50/112/79 -f 45/72/80 48/125/80 78/114/80 -f 46/117/81 47/115/81 48/116/81 -f 44/69/82 77/73/82 78/114/82 -f 49/113/83 78/114/83 82/107/83 -f 82/107/84 83/100/84 74/105/84 -f 83/100/85 79/93/85 54/92/85 -f 79/93/86 80/86/86 59/119/86 -f 80/86/87 81/85/87 64/82/87 -f 64/120/88 81/71/88 77/73/88 diff --git a/examples/models/resources/model/lowpoly-tower.png b/examples/models/resources/model/lowpoly-tower.png deleted file mode 100644 index 7c9239e2..00000000 Binary files a/examples/models/resources/model/lowpoly-tower.png and /dev/null differ diff --git a/examples/models/resources/tower.obj b/examples/models/resources/tower.obj new file mode 100644 index 00000000..ea03a9fc --- /dev/null +++ b/examples/models/resources/tower.obj @@ -0,0 +1,456 @@ +# Blender v2.78 (sub 0) OBJ File: 'lowpoly-tower.blend' +# www.blender.org +o Grid +v -4.000000 0.000000 4.000000 +v -2.327363 0.000000 4.654725 +v 0.000000 0.000000 4.654725 +v 2.327363 0.000000 4.654725 +v 4.000000 0.000000 4.000000 +v -4.654725 0.955085 2.327363 +v -2.000000 0.815050 2.000000 +v 0.000000 0.476341 2.423448 +v 2.000000 0.476341 2.000000 +v 4.654725 0.000000 2.327363 +v -4.654725 1.649076 0.000000 +v -2.423448 1.092402 0.000000 +v 2.423448 0.198579 0.000000 +v 4.654725 0.000000 0.000000 +v -4.654725 1.649076 -2.327363 +v -2.000000 1.092402 -2.000000 +v 0.000000 0.476341 -2.423448 +v 2.000000 -0.012791 -2.000000 +v 4.654725 0.000000 -2.612731 +v -4.000000 0.955085 -4.000000 +v -2.327363 0.955085 -4.654725 +v 0.000000 0.955085 -4.654725 +v 2.327363 0.000000 -4.654725 +v 4.000000 0.000000 -4.000000 +v 2.423448 0.682825 0.000000 +v 2.000000 0.565423 -2.000000 +v -4.654725 -0.020560 2.327363 +v -4.654725 0.000000 0.000000 +v -4.654725 0.000000 -2.327363 +v -4.000000 0.000000 -4.000000 +v -2.327363 0.000000 -4.654725 +v 0.000000 -0.020560 -4.654725 +v 0.000000 0.709880 -1.230535 +v -0.000000 7.395413 0.000000 +v 0.962071 0.709880 -0.767226 +v -0.533909 0.709880 1.108674 +v -1.199683 0.709880 0.273820 +v -0.962071 0.709880 -0.767226 +v 1.506076 0.859071 1.325337 +v 1.199683 0.709880 0.273820 +v 0.533909 0.709880 1.108674 +v 0.000000 1.875340 -1.177842 +v -0.000000 2.293973 -0.649884 +v -0.000000 4.365648 -0.627970 +v 0.000000 6.167194 -0.942957 +v 0.000000 6.232434 -1.708677 +v 1.335898 6.232434 -1.065343 +v 0.737233 6.167195 -0.587924 +v 0.490966 4.365648 -0.391533 +v 0.508100 2.293973 -0.405196 +v 0.920874 1.875340 -0.734372 +v -0.741367 6.232434 1.539465 +v -0.409133 6.167195 0.849574 +v -0.272466 4.365648 0.565781 +v -0.281974 2.293973 0.585526 +v -0.511047 1.875340 1.061199 +v -1.665837 6.232434 0.380217 +v -0.919314 6.167195 0.209828 +v -0.612225 4.365648 0.139736 +v -0.633590 2.293973 0.144613 +v -1.148311 1.875340 0.262095 +v -1.335898 6.232434 -1.065343 +v -0.737233 6.167195 -0.587924 +v -0.490967 4.365648 -0.391533 +v -0.508100 2.293973 -0.405196 +v -0.920874 1.875340 -0.734372 +v 1.665837 6.232434 0.380216 +v 0.919315 6.167195 0.209828 +v 0.612225 4.365648 0.139736 +v 0.633590 2.293973 0.144613 +v 1.148311 1.875340 0.262095 +v 0.741367 6.232434 1.539465 +v 0.409133 6.167195 0.849575 +v 0.272466 4.365648 0.565781 +v 0.281974 2.293973 0.585526 +v 0.511046 1.875340 1.061199 +v 0.000000 5.012550 -0.969733 +v 0.758168 5.012550 -0.604618 +v -0.420751 5.012550 0.873699 +v -0.945419 5.012550 0.215786 +v -0.758168 5.012550 -0.604618 +v 0.945419 5.012550 0.215786 +v 0.420751 5.012550 0.873699 +vt 0.0523 0.5444 +vt 0.1817 0.4284 +vt 0.1641 0.5859 +vt 0.0177 0.4451 +vt 0.1526 0.3090 +vt 0.0189 0.1737 +vt 0.0188 0.3088 +vt 0.0561 0.0762 +vt 0.1757 0.1924 +vt 0.3024 0.4534 +vt 0.3071 0.5902 +vt 0.3413 0.2459 +vt 0.2906 0.1614 +vt 0.4116 0.1801 +vt 0.2834 0.3774 +vt 0.1526 0.0362 +vt 0.2917 0.1622 +vt 0.4446 0.5865 +vt 0.4443 0.2989 +vt 0.3711 0.3021 +vt 0.4396 0.0275 +vt 0.4094 0.1829 +vt 0.4219 0.4255 +vt 0.5474 0.5381 +vt 0.5811 0.4376 +vt 0.5715 0.1505 +vt 0.5811 0.2997 +vt 0.5272 0.0533 +vt 0.2208 0.2194 +vt 0.3456 0.3610 +vt 0.2878 0.0321 +vt 0.2321 0.3392 +vt 0.4432 0.0177 +vt 0.7347 0.7934 +vt 0.7382 0.7595 +vt 0.8982 0.7768 +vt 0.6169 0.7595 +vt 0.6139 0.7879 +vt 0.4951 0.7634 +vt 0.1551 0.6832 +vt 0.2925 0.6268 +vt 0.2925 0.6832 +vt 0.7795 0.6832 +vt 0.6421 0.6268 +vt 0.7795 0.6255 +vt 0.5046 0.7241 +vt 0.6421 0.7241 +vt 0.3986 0.6268 +vt 0.3986 0.6832 +vt 0.5046 0.6268 +vt 0.0177 0.6268 +vt 0.1551 0.6255 +vt 0.8856 0.6268 +vt 0.1899 0.9579 +vt 0.1194 0.8696 +vt 0.2324 0.8696 +vt 0.1899 0.7813 +vt 0.0943 0.7595 +vt 0.0177 0.8206 +vt 0.0177 0.9186 +vt 0.0943 0.9797 +vt 0.2793 0.2349 +vt 0.2304 0.2758 +vt 0.6597 0.0177 +vt 0.6954 0.0993 +vt 0.6367 0.0768 +vt 0.7558 0.0777 +vt 0.7238 0.0440 +vt 0.8840 0.1330 +vt 0.7385 0.1141 +vt 0.9157 0.0886 +vt 0.9781 0.1232 +vt 0.9224 0.1276 +vt 0.2677 0.8141 +vt 0.3463 0.8037 +vt 0.3086 0.8339 +vt 0.6387 0.3550 +vt 0.7130 0.3801 +vt 0.6596 0.4053 +vt 0.7245 0.3245 +vt 0.6919 0.3383 +vt 0.8655 0.3566 +vt 0.7351 0.3577 +vt 0.9770 0.3365 +vt 0.9078 0.3751 +vt 0.9174 0.3282 +vt 0.2677 0.9018 +vt 0.3086 0.8821 +vt 0.6803 0.2948 +vt 0.6251 0.3035 +vt 0.7194 0.2854 +vt 0.8764 0.2832 +vt 0.9221 0.2861 +vt 0.3363 0.9565 +vt 0.3464 0.9122 +vt 0.6751 0.2482 +vt 0.6178 0.2499 +vt 0.7179 0.2431 +vt 0.9823 0.2484 +vt 0.9247 0.2452 +vt 0.3935 0.9014 +vt 0.6755 0.1996 +vt 0.6164 0.1941 +vt 0.7201 0.1992 +vt 0.8793 0.2446 +vt 0.9823 0.2060 +vt 0.9257 0.2051 +vt 0.4598 0.8580 +vt 0.4144 0.8579 +vt 0.6819 0.1498 +vt 0.6222 0.1361 +vt 0.7266 0.1555 +vt 0.8831 0.1684 +vt 0.9252 0.1659 +vt 0.4218 0.7790 +vt 0.3934 0.8145 +vt 0.3363 0.7595 +vt 0.8815 0.2060 +vt 0.8720 0.3208 +vt 0.8825 0.1012 +vt 0.9735 0.0816 +vt 0.9718 0.3817 +vt 0.9807 0.2918 +vt 0.4218 0.9370 +vt 0.9810 0.1644 +vn 0.1035 0.8806 0.4623 +vn 0.0964 0.9481 0.3030 +vn 0.0000 0.9780 0.2088 +vn 0.0659 0.9835 0.1683 +vn 0.2325 0.9320 0.2779 +vn 0.0553 0.9960 -0.0702 +vn 0.2827 0.9564 0.0728 +vn 0.1873 0.9776 -0.0961 +vn 0.2421 0.9703 0.0000 +vn 0.0921 0.9772 -0.1913 +vn -0.0277 0.9947 -0.0993 +vn 0.2308 0.9274 -0.2944 +vn 0.2771 0.9572 -0.0837 +vn 0.3724 0.9074 0.1947 +vn 0.0777 0.9770 -0.1985 +vn -0.1094 0.9539 0.2794 +vn 0.0364 0.9844 0.1721 +vn 0.1683 0.9835 0.0659 +vn 0.0674 0.9901 0.1230 +vn 0.4338 0.8823 0.1829 +vn 0.2845 0.9565 0.0649 +vn 0.0886 0.9961 0.0000 +vn 0.2000 0.9789 0.0424 +vn 0.1417 0.9830 0.1171 +vn 0.3021 0.9524 0.0412 +vn -0.0193 0.9986 -0.0493 +vn 0.0000 0.9777 0.2098 +vn 0.0005 0.9781 -0.2083 +vn 0.1879 0.9782 -0.0887 +vn 0.2249 0.0000 0.9744 +vn 0.9783 0.0000 -0.2071 +vn 0.9783 0.0000 0.2071 +vn 0.0000 0.0000 -1.0000 +vn -1.0000 0.0000 0.0000 +vn -0.3645 0.0000 -0.9312 +vn -0.9312 0.0000 -0.3645 +vn -0.9312 0.0000 0.3645 +vn 0.2615 0.7979 -0.5431 +vn 0.5877 0.7979 -0.1341 +vn 0.4713 0.7979 0.3758 +vn -0.0000 0.7979 0.6028 +vn -0.4713 0.7979 0.3758 +vn -0.5877 0.7979 -0.1341 +vn -0.2615 0.7979 -0.5431 +vn -0.1285 0.9864 -0.1025 +vn 0.0929 0.8937 0.4389 +vn -0.4335 0.0407 -0.9002 +vn -0.2867 0.7507 -0.5952 +vn -0.4339 0.0095 -0.9009 +vn -0.4338 0.0209 -0.9008 +vn -0.0408 -0.9956 -0.0848 +vn -0.9741 0.0407 -0.2223 +vn -0.6441 0.7507 -0.1470 +vn -0.9749 0.0095 -0.2225 +vn -0.9747 0.0209 -0.2225 +vn -0.0918 -0.9956 -0.0209 +vn -0.7812 0.0407 0.6230 +vn -0.5165 0.7507 0.4119 +vn -0.7818 0.0095 0.6235 +vn -0.7817 0.0209 0.6234 +vn -0.0736 -0.9956 0.0587 +vn -0.0000 0.0407 0.9992 +vn 0.0000 0.7507 0.6607 +vn 0.0000 0.0095 1.0000 +vn -0.0000 0.0209 0.9998 +vn -0.0000 -0.9956 0.0941 +vn 0.7812 0.0407 0.6230 +vn 0.5165 0.7507 0.4119 +vn 0.7818 0.0095 0.6235 +vn 0.7817 0.0209 0.6234 +vn 0.0736 -0.9956 0.0587 +vn 0.9741 0.0407 -0.2223 +vn 0.6441 0.7507 -0.1470 +vn 0.9749 0.0095 -0.2225 +vn 0.9747 0.0209 -0.2225 +vn 0.0918 -0.9956 -0.0209 +vn 0.4335 0.0407 -0.9002 +vn 0.2867 0.7507 -0.5952 +vn 0.4339 0.0095 -0.9009 +vn 0.4338 0.0209 -0.9008 +vn 0.0408 -0.9956 -0.0848 +vn 0.3918 -0.4298 -0.8135 +vn 0.8803 -0.4298 -0.2009 +vn 0.7059 -0.4298 0.5630 +vn -0.0000 -0.4298 0.9029 +vn -0.7059 -0.4298 0.5630 +vn -0.8803 -0.4298 -0.2009 +vn -0.3918 -0.4298 -0.8135 +vn 0.0210 0.9998 -0.0048 +vn 0.0482 0.9981 -0.0385 +vn -0.0166 0.9914 -0.1301 +vn -0.0090 0.9904 -0.1379 +vn 0.2820 0.9576 0.0597 +vn -0.0000 0.9846 0.1749 +vn -0.0921 0.9772 -0.1913 +vn -0.1734 0.9794 0.1036 +s off +f 1/1/1 7/2/1 6/3/1 +f 2/4/2 8/5/2 7/2/2 +f 4/6/3 8/5/3 3/7/3 +f 5/8/4 9/9/4 4/6/4 +f 6/3/5 12/10/5 11/11/5 +f 35/12/6 25/13/6 26/14/6 +f 7/2/7 37/15/7 12/10/7 +f 10/16/8 13/17/8 9/9/8 +f 12/10/9 15/18/9 11/11/9 +f 35/12/10 17/19/10 33/20/10 +f 13/17/11 19/21/11 18/22/11 +f 16/23/12 20/24/12 15/18/12 +f 17/19/13 21/25/13 16/23/13 +f 17/19/14 23/26/14 22/27/14 +f 26/14/15 24/28/15 23/26/15 +f 1/1/16 2/4/16 7/2/16 +f 2/4/3 3/7/3 8/5/3 +f 4/6/17 9/9/17 8/5/17 +f 5/8/18 10/16/18 9/9/18 +f 6/3/19 7/2/19 12/10/19 +f 25/13/20 39/29/20 9/9/20 +f 38/30/21 12/10/21 37/15/21 +f 10/16/22 14/31/22 13/17/22 +f 12/10/23 16/23/23 15/18/23 +f 8/5/24 36/32/24 7/2/24 +f 38/30/25 17/19/25 16/23/25 +f 13/17/22 14/31/22 19/21/22 +f 16/23/26 21/25/26 20/24/26 +f 17/19/27 22/27/27 21/25/27 +f 17/19/28 26/14/28 23/26/28 +f 26/14/29 19/33/29 24/28/29 +f 26/34/30 18/35/30 19/36/30 +f 26/34/31 13/37/31 18/35/31 +f 25/38/32 9/39/32 13/37/32 +f 22/40/33 31/41/33 21/42/33 +f 6/43/34 28/44/34 27/45/34 +f 15/46/34 28/44/34 11/47/34 +f 21/42/35 30/48/35 20/49/35 +f 20/49/36 29/50/36 15/46/36 +f 22/40/33 23/51/33 32/52/33 +f 6/43/37 27/45/37 1/53/37 +f 46/54/38 34/55/38 47/56/38 +f 47/56/39 34/55/39 67/57/39 +f 67/57/40 34/55/40 72/58/40 +f 72/58/41 34/55/41 52/59/41 +f 52/59/42 34/55/42 57/60/42 +f 57/60/43 34/55/43 62/61/43 +f 62/61/44 34/55/44 46/54/44 +f 40/62/45 41/63/45 39/29/45 +f 39/29/46 8/5/46 9/9/46 +f 38/64/47 42/65/47 33/66/47 +f 65/67/48 42/65/48 66/68/48 +f 65/67/49 44/69/49 43/70/49 +f 81/71/50 45/72/50 77/73/50 +f 62/74/51 45/75/51 63/76/51 +f 37/77/52 66/78/52 38/79/52 +f 60/80/53 66/78/53 61/81/53 +f 60/80/54 64/82/54 65/83/54 +f 58/84/55 81/85/55 80/86/55 +f 57/87/56 63/76/56 58/88/56 +f 56/89/57 37/77/57 36/90/57 +f 55/91/58 61/81/58 56/89/58 +f 54/92/59 60/80/59 55/91/59 +f 79/93/60 58/84/60 80/86/60 +f 52/94/61 58/88/61 53/95/61 +f 76/96/62 36/90/62 41/97/62 +f 75/98/63 56/89/63 76/96/63 +f 75/98/64 54/92/64 55/91/64 +f 73/99/65 79/93/65 83/100/65 +f 73/101/66 52/94/66 53/95/66 +f 71/102/67 41/97/67 40/103/67 +f 70/104/68 76/96/68 71/102/68 +f 70/104/69 74/105/69 75/98/69 +f 68/106/70 83/100/70 82/107/70 +f 67/108/71 73/101/71 68/109/71 +f 51/110/72 40/103/72 35/111/72 +f 50/112/73 71/102/73 51/110/73 +f 49/113/74 70/104/74 50/112/74 +f 78/114/75 68/106/75 82/107/75 +f 47/115/76 68/109/76 48/116/76 +f 42/65/77 35/111/77 33/66/77 +f 43/70/78 51/110/78 42/65/78 +f 44/69/79 50/112/79 43/70/79 +f 45/72/80 78/114/80 77/73/80 +f 46/117/81 48/116/81 45/75/81 +f 44/69/82 78/114/82 49/113/82 +f 49/113/83 82/107/83 69/118/83 +f 82/107/84 74/105/84 69/118/84 +f 83/100/85 54/92/85 74/105/85 +f 79/93/86 59/119/86 54/92/86 +f 80/86/87 64/82/87 59/119/87 +f 64/120/88 77/73/88 44/69/88 +f 35/12/89 40/62/89 25/13/89 +f 7/2/90 36/32/90 37/15/90 +f 35/12/91 26/14/91 17/19/91 +f 25/13/92 40/62/92 39/29/92 +f 38/30/93 16/23/93 12/10/93 +f 8/5/94 41/63/94 36/32/94 +f 38/30/95 33/20/95 17/19/95 +f 26/34/31 25/38/31 13/37/31 +f 22/40/33 32/52/33 31/41/33 +f 6/43/34 11/47/34 28/44/34 +f 15/46/34 29/50/34 28/44/34 +f 21/42/35 31/41/35 30/48/35 +f 20/49/36 30/48/36 29/50/36 +f 39/29/96 41/63/96 8/5/96 +f 38/64/47 66/68/47 42/65/47 +f 65/67/48 43/70/48 42/65/48 +f 65/67/49 64/120/49 44/69/49 +f 81/71/50 63/121/50 45/72/50 +f 62/74/51 46/117/51 45/75/51 +f 37/77/52 61/81/52 66/78/52 +f 60/80/53 65/83/53 66/78/53 +f 60/80/54 59/119/54 64/82/54 +f 58/84/55 63/122/55 81/85/55 +f 57/87/56 62/74/56 63/76/56 +f 56/89/57 61/81/57 37/77/57 +f 55/91/58 60/80/58 61/81/58 +f 54/92/59 59/119/59 60/80/59 +f 79/93/60 53/123/60 58/84/60 +f 52/94/61 57/87/61 58/88/61 +f 76/96/62 56/89/62 36/90/62 +f 75/98/63 55/91/63 56/89/63 +f 75/98/64 74/105/64 54/92/64 +f 73/99/65 53/123/65 79/93/65 +f 73/101/66 72/124/66 52/94/66 +f 71/102/67 76/96/67 41/97/67 +f 70/104/68 75/98/68 76/96/68 +f 70/104/69 69/118/69 74/105/69 +f 68/106/70 73/99/70 83/100/70 +f 67/108/71 72/124/71 73/101/71 +f 51/110/72 71/102/72 40/103/72 +f 50/112/73 70/104/73 71/102/73 +f 49/113/74 69/118/74 70/104/74 +f 78/114/75 48/125/75 68/106/75 +f 47/115/76 67/108/76 68/109/76 +f 42/65/77 51/110/77 35/111/77 +f 43/70/78 50/112/78 51/110/78 +f 44/69/79 49/113/79 50/112/79 +f 45/72/80 48/125/80 78/114/80 +f 46/117/81 47/115/81 48/116/81 +f 44/69/82 77/73/82 78/114/82 +f 49/113/83 78/114/83 82/107/83 +f 82/107/84 83/100/84 74/105/84 +f 83/100/85 79/93/85 54/92/85 +f 79/93/86 80/86/86 59/119/86 +f 80/86/87 81/85/87 64/82/87 +f 64/120/88 81/71/88 77/73/88 diff --git a/examples/models/resources/tower.png b/examples/models/resources/tower.png new file mode 100644 index 00000000..7c9239e2 Binary files /dev/null and b/examples/models/resources/tower.png differ diff --git a/examples/others/font_selector.c b/examples/others/font_selector.c new file mode 100644 index 00000000..5891bef7 --- /dev/null +++ b/examples/others/font_selector.c @@ -0,0 +1,158 @@ +/******************************************************************************************* +* +* raylib [text] example - Font selector +* +* 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 [text] example - font selector"); + + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) + SpriteFont fonts[8]; // SpriteFont array + + fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading + fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading + fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading + fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // SpriteFont loading + fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // SpriteFont loading + fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading + fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading + fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading + + int currentFont = 0; // Selected font + + Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; + + const char fontNames[8][20] = { "[0] Alagard", "[1] PixelPlay", "[2] MECHA", "[3] Setback", + "[4] Romulus", "[5] PixAntiqua", "[6] Alpha Beta", "[7] Jupiter Crash" }; + + const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text + + Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].baseSize*3, 1); + + Vector2 mousePoint; + + Color btnNextOutColor = DARKBLUE; // Button color (outside line) + Color btnNextInColor = SKYBLUE; // Button color (inside) + + int framesCounter = 0; // Useful to count frames button is 'active' = clicked + + int positionY = 180; // Text selector and button Y position + + Rectangle btnNextRec = { 673, positionY, 109, 44 }; // Button rectangle (useful for collision) + + 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 + //---------------------------------------------------------------------------------- + + // Keyboard-based font selection (easy) + if (IsKeyPressed(KEY_RIGHT)) + { + if (currentFont < 7) currentFont++; + } + + if (IsKeyPressed(KEY_LEFT)) + { + if (currentFont > 0) currentFont--; + } + + if (IsKeyPressed('0')) currentFont = 0; + else if (IsKeyPressed('1')) currentFont = 1; + else if (IsKeyPressed('2')) currentFont = 2; + else if (IsKeyPressed('3')) currentFont = 3; + else if (IsKeyPressed('4')) currentFont = 4; + else if (IsKeyPressed('5')) currentFont = 5; + else if (IsKeyPressed('6')) currentFont = 6; + else if (IsKeyPressed('7')) currentFont = 7; + + // Mouse-based font selection (NEXT button logic) + mousePoint = GetMousePosition(); + + if (CheckCollisionPointRec(mousePoint, btnNextRec)) + { + // Mouse hover button logic + if (framesCounter == 0) + { + btnNextOutColor = DARKPURPLE; + btnNextInColor = PURPLE; + } + + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) + { + framesCounter = 20; // Frames button is 'active' + btnNextOutColor = MAROON; + btnNextInColor = RED; + } + } + else + { + // Mouse not hover button + btnNextOutColor = DARKBLUE; + btnNextInColor = SKYBLUE; + } + + if (framesCounter > 0) framesCounter--; + + if (framesCounter == 1) // We change font on frame 1 + { + currentFont++; + if (currentFont > 7) currentFont = 0; + } + + // Text measurement for better positioning on screen + textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].baseSize*3, 1); + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("font selector - use arroys, button or numbers", 160, 80, 20, DARKGRAY); + DrawLine(120, 120, 680, 120, DARKGRAY); + + DrawRectangle(18, positionY, 644, 44, DARKGRAY); + DrawRectangle(20, positionY + 2, 640, 40, LIGHTGRAY); + DrawText(fontNames[currentFont], 30, positionY + 13, 20, BLACK); + DrawText("< >", 610, positionY + 8, 30, BLACK); + + DrawRectangleRec(btnNextRec, btnNextOutColor); + DrawRectangle(675, positionY + 2, 105, 40, btnNextInColor); + DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor); + + DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2, + 260 + (70 - textSize.y)/2 }, fonts[currentFont].baseSize*3, + 1, colors[currentFont]); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); // SpriteFont(s) unloading + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/others/image_formats_loading.c b/examples/others/image_formats_loading.c new file mode 100644 index 00000000..446f3f3e --- /dev/null +++ b/examples/others/image_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/formats/sonic.png"); + + // Load UNCOMPRESSED PVR texture data + sonic[PVR_GRAYSCALE] = LoadTexture("resources/formats/sonic_GRAYSCALE.pvr"); + sonic[PVR_GRAY_ALPHA] = LoadTexture("resources/formats/sonic_L8A8.pvr"); + sonic[PVR_R5G6B5] = LoadTexture("resources/formats/sonic_R5G6B5.pvr"); + sonic[PVR_R5G5B5A1] = LoadTexture("resources/formats/sonic_R5G5B5A1.pvr"); + sonic[PVR_R4G4B4A4] = LoadTexture("resources/formats/sonic_R4G4B4A4.pvr"); + + // Load UNCOMPRESSED DDS texture data + sonic[DDS_R5G6B5] = LoadTexture("resources/formats/sonic_R5G6B5.dds"); + sonic[DDS_R5G5B5A1] = LoadTexture("resources/formats/sonic_A1R5G5B5.dds"); + sonic[DDS_R4G4B4A4] = LoadTexture("resources/formats/sonic_A4R4G4B4.dds"); + sonic[DDS_R8G8B8A8] = LoadTexture("resources/formats/sonic_A8R8G8B8.dds"); + + // Load COMPRESSED DXT DDS texture data (if supported) + sonic[DDS_DXT1_RGB] = LoadTexture("resources/formats/sonic_DXT1_RGB.dds"); + sonic[DDS_DXT1_RGBA] = LoadTexture("resources/formats/sonic_DXT1_RGBA.dds"); + sonic[DDS_DXT3_RGBA] = LoadTexture("resources/formats/sonic_DXT3_RGBA.dds"); + sonic[DDS_DXT5_RGBA] = LoadTexture("resources/formats/sonic_DXT5_RGBA.dds"); + + // Load COMPRESSED ETC texture data (if supported) + sonic[PKM_ETC1_RGB] = LoadTexture("resources/formats/sonic_ETC1_RGB.pkm"); + sonic[PKM_ETC2_RGB] = LoadTexture("resources/formats/sonic_ETC2_RGB.pkm"); + sonic[PKM_ETC2_EAC_RGBA] = LoadTexture("resources/formats/sonic_ETC2_EAC_RGBA.pkm"); + + sonic[KTX_ETC1_RGB] = LoadTexture("resources/formats/sonic_ETC1_RGB.ktx"); + sonic[KTX_ETC2_RGB] = LoadTexture("resources/formats/sonic_ETC2_RGB.ktx"); + sonic[KTX_ETC2_EAC_RGBA] = LoadTexture("resources/formats/sonic_ETC2_EAC_RGBA.ktx"); + + // Load COMPRESSED ASTC texture data (if supported) + sonic[ASTC_4x4_LDR] = LoadTexture("resources/formats/sonic_ASTC_4x4_ldr.astc"); + sonic[ASTC_8x8_LDR] = LoadTexture("resources/formats/sonic_ASTC_8x8_ldr.astc"); + + // Load COMPRESSED PVR texture data (if supported) + sonic[PVR_PVRT_RGB] = LoadTexture("resources/formats/sonic_PVRT_RGB.pvr"); + sonic[PVR_PVRT_RGBA] = LoadTexture("resources/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/others/oculus_rift.c b/examples/others/oculus_rift.c new file mode 100644 index 00000000..f1b0bd3b --- /dev/null +++ b/examples/others/oculus_rift.c @@ -0,0 +1,538 @@ +/******************************************************************************************* +* +* raylib [core] example - Oculus Rift CV1 +* +* Compile example using: +* gcc -o $(NAME_PART).exe $(FILE_NAME) -I..\src\external -I..\src\external\OculusSDK\LibOVR\Include / +* -L. -L..\src\external\OculusSDK\LibOVR -lLibOVRRT32_1 -lraylib -lglfw3 -lopengl32 -lgdi32 -std=c99 / +* -Wl,-allow-multiple-definition +* +* #define SUPPORT_OCULUS_RIFT_CV1 / RLGL_OCULUS_SUPPORT +* Enable Oculus Rift CV1 functionality +* +* This example has been created using raylib 1.5 (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 "glad.h" // Required for: OpenGL types and functions declarations +#include "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality + +#include // Required for: memset() +#include // Required for: exit() +#include // required for: vfprintf() +#include // Required for: va_list, va_start(), vfprintf(), va_end() + +#define RLGL_OCULUS_SUPPORT // Enable Oculus Rift code +#if defined(RLGL_OCULUS_SUPPORT) + #include "OVR_CAPI_GL.h" // Oculus SDK for OpenGL +#endif + +//---------------------------------------------------------------------------------- +// Defines and Macros +//---------------------------------------------------------------------------------- +// ... + +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- + +// TraceLog message types +typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType; + +#if defined(RLGL_OCULUS_SUPPORT) +// Oculus buffer type +typedef struct OculusBuffer { + ovrTextureSwapChain textureChain; + GLuint depthId; + GLuint fboId; + int width; + int height; +} OculusBuffer; + +// Oculus mirror texture type +typedef struct OculusMirror { + ovrMirrorTexture texture; + GLuint fboId; + int width; + int height; +} OculusMirror; + +// Oculus layer type +typedef struct OculusLayer { + ovrViewScaleDesc viewScaleDesc; + ovrLayerEyeFov eyeLayer; // layer 0 + //ovrLayerQuad quadLayer; // TODO: layer 1: '2D' quad for GUI + Matrix eyeProjections[2]; + int width; + int height; +} OculusLayer; +#endif + +//---------------------------------------------------------------------------------- +// Global Variables Definition +//---------------------------------------------------------------------------------- +#if defined(RLGL_OCULUS_SUPPORT) +// OVR device variables +static ovrSession session; // Oculus session (pointer to ovrHmdStruct) +static ovrHmdDesc hmdDesc; // Oculus device descriptor parameters +static ovrGraphicsLuid luid; // Oculus locally unique identifier for the program (64 bit) +static OculusLayer layer; // Oculus drawing layer (similar to photoshop) +static OculusBuffer buffer; // Oculus internal buffers (texture chain and fbo) +static OculusMirror mirror; // Oculus mirror texture and fbo +static unsigned int frameIndex = 0; // Oculus frames counter, used to discard frames from chain +#endif + +//---------------------------------------------------------------------------------- +// Module specific Functions Declaration +//---------------------------------------------------------------------------------- +#if defined(RLGL_OCULUS_SUPPORT) +static bool InitOculusDevice(void); // Initialize Oculus device (returns true if success) +static void CloseOculusDevice(void); // Close Oculus device +static void UpdateOculusTracking(Camera *camera); // Update Oculus head position-orientation tracking +static void BeginOculusDrawing(void); // Setup Oculus buffers for drawing +static void EndOculusDrawing(void); // Finish Oculus drawing and blit framebuffer to mirror + +static OculusBuffer LoadOculusBuffer(ovrSession session, int width, int height); // Load Oculus required buffers +static void UnloadOculusBuffer(ovrSession session, OculusBuffer buffer); // Unload texture required buffers +static OculusMirror LoadOculusMirror(ovrSession session, int width, int height); // Load Oculus mirror buffers +static void UnloadOculusMirror(ovrSession session, OculusMirror mirror); // Unload Oculus mirror buffers +static void BlitOculusMirror(ovrSession session, OculusMirror mirror); // Copy Oculus screen buffer to mirror texture +static OculusLayer InitOculusLayer(ovrSession session); // Init Oculus layer (similar to photoshop) +static Matrix FromOvrMatrix(ovrMatrix4f ovrM); // Convert from Oculus ovrMatrix4f struct to raymath Matrix struct +#endif + +static void TraceLog(int msgType, const char *text, ...); + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 1080; + int screenHeight = 600; + + // NOTE: screenWidth/screenHeight should match VR device aspect ratio + + InitWindow(screenWidth, screenHeight, "raylib [core] example - oculus rift"); + + bool vrDeviceReady = InitOculusDevice(); // Init VR device Oculus Rift CV1 + + if (!vrDeviceReady) InitVrSimulator(HMD_OCULUS_RIFT_CV1); // Init VR simulator if device fails + + // Define the camera to look into our 3d world + Camera camera; + camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position + camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) + camera.fovy = 60.0f; // Camera field-of-view Y + + Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; + + SetCameraMode(camera, CAMERA_FIRST_PERSON); // Set first person camera mode + + SetTargetFPS(90); // Set our game to run at 90 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + if (!vrDeviceReady) UpdateCamera(&camera); // Update camera (simulator mode) + else UpdateOculusTracking(&camera); // Update camera with device tracking data + + if (IsKeyPressed(KEY_SPACE)) ToggleVrMode(); // Toggle VR mode + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + if (vrDeviceReady) BeginOculusDrawing(); + else BeginVrDrawing(); + + Begin3dMode(camera); + + DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); + DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); + + DrawGrid(40, 1.0f); + + End3dMode(); + + if (vrDeviceReady) EndOculusDrawing(); + else EndVrDrawing(); + + DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + if (vrDeviceReady) CloseOculusDevice(); + else CloseVrSimulator(); + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} + +//---------------------------------------------------------------------------------- +// Module specific Functions Definition +//---------------------------------------------------------------------------------- + +#if defined(RLGL_OCULUS_SUPPORT) +// Set internal projection and modelview matrix depending on eyes tracking data +static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView) +{ + Matrix eyeProjection = matProjection; + Matrix eyeModelView = matModelView; + + glViewport(layer.eyeLayer.Viewport[eye].Pos.x, layer.eyeLayer.Viewport[eye].Pos.y, + layer.eyeLayer.Viewport[eye].Size.w, layer.eyeLayer.Viewport[eye].Size.h); + + Quaternion eyeRenderPose = (Quaternion){ layer.eyeLayer.RenderPose[eye].Orientation.x, + layer.eyeLayer.RenderPose[eye].Orientation.y, + layer.eyeLayer.RenderPose[eye].Orientation.z, + layer.eyeLayer.RenderPose[eye].Orientation.w }; + QuaternionInvert(&eyeRenderPose); + Matrix eyeOrientation = QuaternionToMatrix(eyeRenderPose); + Matrix eyeTranslation = MatrixTranslate(-layer.eyeLayer.RenderPose[eye].Position.x, + -layer.eyeLayer.RenderPose[eye].Position.y, + -layer.eyeLayer.RenderPose[eye].Position.z); + + Matrix eyeView = MatrixMultiply(eyeTranslation, eyeOrientation); // Matrix containing eye-head movement + eyeModelView = MatrixMultiply(matModelView, eyeView); // Combine internal camera matrix (modelview) wih eye-head movement + + eyeProjection = layer.eyeProjections[eye]; +} + +// Initialize Oculus device (returns true if success) +static bool InitOculusDevice(void) +{ + bool oculusReady = false; + + ovrResult result = ovr_Initialize(NULL); + + if (OVR_FAILURE(result)) TraceLog(WARNING, "OVR: Could not initialize Oculus device"); + else + { + result = ovr_Create(&session, &luid); + if (OVR_FAILURE(result)) + { + TraceLog(WARNING, "OVR: Could not create Oculus session"); + ovr_Shutdown(); + } + else + { + hmdDesc = ovr_GetHmdDesc(session); + + TraceLog(INFO, "OVR: Product Name: %s", hmdDesc.ProductName); + TraceLog(INFO, "OVR: Manufacturer: %s", hmdDesc.Manufacturer); + TraceLog(INFO, "OVR: Product ID: %i", hmdDesc.ProductId); + TraceLog(INFO, "OVR: Product Type: %i", hmdDesc.Type); + //TraceLog(INFO, "OVR: Serial Number: %s", hmdDesc.SerialNumber); + TraceLog(INFO, "OVR: Resolution: %ix%i", hmdDesc.Resolution.w, hmdDesc.Resolution.h); + + // NOTE: Oculus mirror is set to defined screenWidth and screenHeight... + // ...ideally, it should be (hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2) + + // Initialize Oculus Buffers + layer = InitOculusLayer(session); + buffer = LoadOculusBuffer(session, layer.width, layer.height); + mirror = LoadOculusMirror(session, hmdDesc.Resolution.w/2, hmdDesc.Resolution.h/2); // NOTE: hardcoded... + layer.eyeLayer.ColorTexture[0] = buffer.textureChain; //SetOculusLayerTexture(eyeLayer, buffer.textureChain); + + // Recenter OVR tracking origin + ovr_RecenterTrackingOrigin(session); + + oculusReady = true; + } + } + + return oculusReady; +} + +// Close Oculus device (and unload buffers) +static void CloseOculusDevice(void) +{ + UnloadOculusMirror(session, mirror); // Unload Oculus mirror buffer + UnloadOculusBuffer(session, buffer); // Unload Oculus texture buffers + + ovr_Destroy(session); // Free Oculus session data + ovr_Shutdown(); // Close Oculus device connection +} + +// Update Oculus head position-orientation tracking +static void UpdateOculusTracking(Camera *camera) +{ + frameIndex++; + + ovrPosef eyePoses[2]; + ovr_GetEyePoses(session, frameIndex, ovrTrue, layer.viewScaleDesc.HmdToEyeOffset, eyePoses, &layer.eyeLayer.SensorSampleTime); + + layer.eyeLayer.RenderPose[0] = eyePoses[0]; + layer.eyeLayer.RenderPose[1] = eyePoses[1]; + + // TODO: Update external camera with eyePoses data (position, orientation) + // NOTE: We can simplify to simple camera if we consider IPD and HMD device configuration again later + // it will be useful for the user to draw, lets say, billboards oriented to camera + + // Get session status information + ovrSessionStatus sessionStatus; + ovr_GetSessionStatus(session, &sessionStatus); + + if (sessionStatus.ShouldQuit) TraceLog(WARNING, "OVR: Session should quit..."); + if (sessionStatus.ShouldRecenter) ovr_RecenterTrackingOrigin(session); + //if (sessionStatus.HmdPresent) // HMD is present. + //if (sessionStatus.DisplayLost) // HMD was unplugged or the display driver was manually disabled or encountered a TDR. + //if (sessionStatus.HmdMounted) // HMD is on the user's head. + //if (sessionStatus.IsVisible) // the game or experience has VR focus and is visible in the HMD. +} + +// Setup Oculus buffers for drawing +static void BeginOculusDrawing(void) +{ + GLuint currentTexId; + int currentIndex; + + ovr_GetTextureSwapChainCurrentIndex(session, buffer.textureChain, ¤tIndex); + ovr_GetTextureSwapChainBufferGL(session, buffer.textureChain, currentIndex, ¤tTexId); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer.fboId); + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, currentTexId, 0); + //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, buffer.depthId, 0); // Already binded +} + +// Finish Oculus drawing and blit framebuffer to mirror +static void EndOculusDrawing(void) +{ + // Unbind current framebuffer (Oculus buffer) + glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + + ovr_CommitTextureSwapChain(session, buffer.textureChain); + + ovrLayerHeader *layers = &layer.eyeLayer.Header; + ovr_SubmitFrame(session, frameIndex, &layer.viewScaleDesc, &layers, 1); + + // Blit mirror texture to back buffer + BlitOculusMirror(session, mirror); +} + +// Load Oculus required buffers: texture-swap-chain, fbo, texture-depth +static OculusBuffer LoadOculusBuffer(ovrSession session, int width, int height) +{ + OculusBuffer buffer; + buffer.width = width; + buffer.height = height; + + // Create OVR texture chain + ovrTextureSwapChainDesc desc = {}; + desc.Type = ovrTexture_2D; + desc.ArraySize = 1; + desc.Width = width; + desc.Height = height; + desc.MipLevels = 1; + desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB; // Requires glEnable(GL_FRAMEBUFFER_SRGB); + desc.SampleCount = 1; + desc.StaticImage = ovrFalse; + + ovrResult result = ovr_CreateTextureSwapChainGL(session, &desc, &buffer.textureChain); + + if (!OVR_SUCCESS(result)) TraceLog(WARNING, "OVR: Failed to create swap textures buffer"); + + int textureCount = 0; + ovr_GetTextureSwapChainLength(session, buffer.textureChain, &textureCount); + + if (!OVR_SUCCESS(result) || !textureCount) TraceLog(WARNING, "OVR: Unable to count swap chain textures"); + + for (int i = 0; i < textureCount; ++i) + { + GLuint chainTexId; + ovr_GetTextureSwapChainBufferGL(session, buffer.textureChain, i, &chainTexId); + glBindTexture(GL_TEXTURE_2D, chainTexId); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + + glBindTexture(GL_TEXTURE_2D, 0); + + /* + // Setup framebuffer object (using depth texture) + glGenFramebuffers(1, &buffer.fboId); + glGenTextures(1, &buffer.depthId); + glBindTexture(GL_TEXTURE_2D, buffer.depthId); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, buffer.width, buffer.height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); + */ + + // Setup framebuffer object (using depth renderbuffer) + glGenFramebuffers(1, &buffer.fboId); + glGenRenderbuffers(1, &buffer.depthId); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer.fboId); + glBindRenderbuffer(GL_RENDERBUFFER, buffer.depthId); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, buffer.width, buffer.height); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, buffer.depthId); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + + return buffer; +} + +// Unload texture required buffers +static void UnloadOculusBuffer(ovrSession session, OculusBuffer buffer) +{ + if (buffer.textureChain) + { + ovr_DestroyTextureSwapChain(session, buffer.textureChain); + buffer.textureChain = NULL; + } + + if (buffer.depthId != 0) glDeleteTextures(1, &buffer.depthId); + if (buffer.fboId != 0) glDeleteFramebuffers(1, &buffer.fboId); +} + +// Load Oculus mirror buffers +static OculusMirror LoadOculusMirror(ovrSession session, int width, int height) +{ + OculusMirror mirror; + mirror.width = width; + mirror.height = height; + + ovrMirrorTextureDesc mirrorDesc; + memset(&mirrorDesc, 0, sizeof(mirrorDesc)); + mirrorDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB; + mirrorDesc.Width = mirror.width; + mirrorDesc.Height = mirror.height; + + if (!OVR_SUCCESS(ovr_CreateMirrorTextureGL(session, &mirrorDesc, &mirror.texture))) TraceLog(WARNING, "Could not create mirror texture"); + + glGenFramebuffers(1, &mirror.fboId); + + return mirror; +} + +// Unload Oculus mirror buffers +static void UnloadOculusMirror(ovrSession session, OculusMirror mirror) +{ + if (mirror.fboId != 0) glDeleteFramebuffers(1, &mirror.fboId); + if (mirror.texture) ovr_DestroyMirrorTexture(session, mirror.texture); +} + +// Copy Oculus screen buffer to mirror texture +static void BlitOculusMirror(ovrSession session, OculusMirror mirror) +{ + GLuint mirrorTextureId; + + ovr_GetMirrorTextureBufferGL(session, mirror.texture, &mirrorTextureId); + + glBindFramebuffer(GL_READ_FRAMEBUFFER, mirror.fboId); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mirrorTextureId, 0); +#if defined(GRAPHICS_API_OPENGL_33) + // NOTE: glBlitFramebuffer() requires extension: GL_EXT_framebuffer_blit (not available in OpenGL ES 2.0) + glBlitFramebuffer(0, 0, mirror.width, mirror.height, 0, mirror.height, mirror.width, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST); +#endif + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); +} + +// Init Oculus layer (similar to photoshop) +static OculusLayer InitOculusLayer(ovrSession session) +{ + OculusLayer layer = { 0 }; + + layer.viewScaleDesc.HmdSpaceToWorldScaleInMeters = 1.0f; + + memset(&layer.eyeLayer, 0, sizeof(ovrLayerEyeFov)); + layer.eyeLayer.Header.Type = ovrLayerType_EyeFov; + layer.eyeLayer.Header.Flags = ovrLayerFlag_TextureOriginAtBottomLeft; + + ovrEyeRenderDesc eyeRenderDescs[2]; + + for (int eye = 0; eye < 2; eye++) + { + eyeRenderDescs[eye] = ovr_GetRenderDesc(session, eye, hmdDesc.DefaultEyeFov[eye]); + ovrMatrix4f ovrPerspectiveProjection = ovrMatrix4f_Projection(eyeRenderDescs[eye].Fov, 0.01f, 10000.0f, ovrProjection_None); //ovrProjection_ClipRangeOpenGL); + layer.eyeProjections[eye] = FromOvrMatrix(ovrPerspectiveProjection); // NOTE: struct ovrMatrix4f { float M[4][4] } --> struct Matrix + + layer.viewScaleDesc.HmdToEyeOffset[eye] = eyeRenderDescs[eye].HmdToEyeOffset; + layer.eyeLayer.Fov[eye] = eyeRenderDescs[eye].Fov; + + ovrSizei eyeSize = ovr_GetFovTextureSize(session, eye, layer.eyeLayer.Fov[eye], 1.0f); + layer.eyeLayer.Viewport[eye].Size = eyeSize; + layer.eyeLayer.Viewport[eye].Pos.x = layer.width; + layer.eyeLayer.Viewport[eye].Pos.y = 0; + + layer.height = eyeSize.h; //std::max(renderTargetSize.y, (uint32_t)eyeSize.h); + layer.width += eyeSize.w; + } + + return layer; +} + +// Convert from Oculus ovrMatrix4f struct to raymath Matrix struct +static Matrix FromOvrMatrix(ovrMatrix4f ovrmat) +{ + Matrix rmat; + + rmat.m0 = ovrmat.M[0][0]; + rmat.m1 = ovrmat.M[1][0]; + rmat.m2 = ovrmat.M[2][0]; + rmat.m3 = ovrmat.M[3][0]; + rmat.m4 = ovrmat.M[0][1]; + rmat.m5 = ovrmat.M[1][1]; + rmat.m6 = ovrmat.M[2][1]; + rmat.m7 = ovrmat.M[3][1]; + rmat.m8 = ovrmat.M[0][2]; + rmat.m9 = ovrmat.M[1][2]; + rmat.m10 = ovrmat.M[2][2]; + rmat.m11 = ovrmat.M[3][2]; + rmat.m12 = ovrmat.M[0][3]; + rmat.m13 = ovrmat.M[1][3]; + rmat.m14 = ovrmat.M[2][3]; + rmat.m15 = ovrmat.M[3][3]; + + MatrixTranspose(&rmat); + + return rmat; +} +#endif + +// Output a trace log message +// NOTE: Expected msgType: (0)Info, (1)Error, (2)Warning +static void TraceLog(int msgType, const char *text, ...) +{ + va_list args; + va_start(args, text); + + switch (msgType) + { + case INFO: fprintf(stdout, "INFO: "); break; + case ERROR: fprintf(stdout, "ERROR: "); break; + case WARNING: fprintf(stdout, "WARNING: "); break; + case DEBUG: fprintf(stdout, "DEBUG: "); break; + default: break; + } + + vfprintf(stdout, text, args); + fprintf(stdout, "\n"); + + va_end(args); + + if (msgType == ERROR) exit(1); +} + diff --git a/examples/others/particles_trail_blending.c b/examples/others/particles_trail_blending.c new file mode 100644 index 00000000..0b47c790 --- /dev/null +++ b/examples/others/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/others/resources/formats/sonic.png b/examples/others/resources/formats/sonic.png new file mode 100644 index 00000000..7a096847 Binary files /dev/null and b/examples/others/resources/formats/sonic.png differ diff --git a/examples/others/resources/formats/sonic_A1R5G5B5.dds b/examples/others/resources/formats/sonic_A1R5G5B5.dds new file mode 100644 index 00000000..5e2347db Binary files /dev/null and b/examples/others/resources/formats/sonic_A1R5G5B5.dds differ diff --git a/examples/others/resources/formats/sonic_A4R4G4B4.dds b/examples/others/resources/formats/sonic_A4R4G4B4.dds new file mode 100644 index 00000000..c5ccaf0c Binary files /dev/null and b/examples/others/resources/formats/sonic_A4R4G4B4.dds differ diff --git a/examples/others/resources/formats/sonic_A8R8G8B8.dds b/examples/others/resources/formats/sonic_A8R8G8B8.dds new file mode 100644 index 00000000..fb71b7be Binary files /dev/null and b/examples/others/resources/formats/sonic_A8R8G8B8.dds differ diff --git a/examples/others/resources/formats/sonic_ASTC_4x4_ldr.astc b/examples/others/resources/formats/sonic_ASTC_4x4_ldr.astc new file mode 100644 index 00000000..9a98d9a0 Binary files /dev/null and b/examples/others/resources/formats/sonic_ASTC_4x4_ldr.astc differ diff --git a/examples/others/resources/formats/sonic_ASTC_8x8_ldr.astc b/examples/others/resources/formats/sonic_ASTC_8x8_ldr.astc new file mode 100644 index 00000000..360a264a Binary files /dev/null and b/examples/others/resources/formats/sonic_ASTC_8x8_ldr.astc differ diff --git a/examples/others/resources/formats/sonic_DXT1_RGB.dds b/examples/others/resources/formats/sonic_DXT1_RGB.dds new file mode 100644 index 00000000..9d0b4598 Binary files /dev/null and b/examples/others/resources/formats/sonic_DXT1_RGB.dds differ diff --git a/examples/others/resources/formats/sonic_DXT1_RGBA.dds b/examples/others/resources/formats/sonic_DXT1_RGBA.dds new file mode 100644 index 00000000..102bae7f Binary files /dev/null and b/examples/others/resources/formats/sonic_DXT1_RGBA.dds differ diff --git a/examples/others/resources/formats/sonic_DXT3_RGBA.dds b/examples/others/resources/formats/sonic_DXT3_RGBA.dds new file mode 100644 index 00000000..46d965cb Binary files /dev/null and b/examples/others/resources/formats/sonic_DXT3_RGBA.dds differ diff --git a/examples/others/resources/formats/sonic_DXT5_RGBA.dds b/examples/others/resources/formats/sonic_DXT5_RGBA.dds new file mode 100644 index 00000000..b3a59a79 Binary files /dev/null and b/examples/others/resources/formats/sonic_DXT5_RGBA.dds differ diff --git a/examples/others/resources/formats/sonic_ETC1_RGB.ktx b/examples/others/resources/formats/sonic_ETC1_RGB.ktx new file mode 100644 index 00000000..66241b9d Binary files /dev/null and b/examples/others/resources/formats/sonic_ETC1_RGB.ktx differ diff --git a/examples/others/resources/formats/sonic_ETC1_RGB.pkm b/examples/others/resources/formats/sonic_ETC1_RGB.pkm new file mode 100644 index 00000000..c6fc6df4 Binary files /dev/null and b/examples/others/resources/formats/sonic_ETC1_RGB.pkm differ diff --git a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.ktx b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.ktx new file mode 100644 index 00000000..b01812cb Binary files /dev/null and b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.ktx differ diff --git a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.old.pkm b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.old.pkm new file mode 100644 index 00000000..61ac48ce Binary files /dev/null and b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.old.pkm differ diff --git a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.pkm b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.pkm new file mode 100644 index 00000000..61ac48ce Binary files /dev/null and b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.pkm differ diff --git a/examples/others/resources/formats/sonic_ETC2_RGB.ktx b/examples/others/resources/formats/sonic_ETC2_RGB.ktx new file mode 100644 index 00000000..7f1207f7 Binary files /dev/null and b/examples/others/resources/formats/sonic_ETC2_RGB.ktx differ diff --git a/examples/others/resources/formats/sonic_ETC2_RGB.pkm b/examples/others/resources/formats/sonic_ETC2_RGB.pkm new file mode 100644 index 00000000..f290f019 Binary files /dev/null and b/examples/others/resources/formats/sonic_ETC2_RGB.pkm differ diff --git a/examples/others/resources/formats/sonic_GRAYSCALE.pvr b/examples/others/resources/formats/sonic_GRAYSCALE.pvr new file mode 100644 index 00000000..d31e2651 Binary files /dev/null and b/examples/others/resources/formats/sonic_GRAYSCALE.pvr differ diff --git a/examples/others/resources/formats/sonic_L8A8.pvr b/examples/others/resources/formats/sonic_L8A8.pvr new file mode 100644 index 00000000..ccf5932e Binary files /dev/null and b/examples/others/resources/formats/sonic_L8A8.pvr differ diff --git a/examples/others/resources/formats/sonic_PVRT_RGB.pvr b/examples/others/resources/formats/sonic_PVRT_RGB.pvr new file mode 100644 index 00000000..22f3f66a Binary files /dev/null and b/examples/others/resources/formats/sonic_PVRT_RGB.pvr differ diff --git a/examples/others/resources/formats/sonic_PVRT_RGBA.pvr b/examples/others/resources/formats/sonic_PVRT_RGBA.pvr new file mode 100644 index 00000000..feb9aeaf Binary files /dev/null and b/examples/others/resources/formats/sonic_PVRT_RGBA.pvr differ diff --git a/examples/others/resources/formats/sonic_PVRT_RGBA_2bpp.pvr b/examples/others/resources/formats/sonic_PVRT_RGBA_2bpp.pvr new file mode 100644 index 00000000..9147e1bb Binary files /dev/null and b/examples/others/resources/formats/sonic_PVRT_RGBA_2bpp.pvr differ diff --git a/examples/others/resources/formats/sonic_PVRT_RGB_2bpp.pvr b/examples/others/resources/formats/sonic_PVRT_RGB_2bpp.pvr new file mode 100644 index 00000000..2a8aea8c Binary files /dev/null and b/examples/others/resources/formats/sonic_PVRT_RGB_2bpp.pvr differ diff --git a/examples/others/resources/formats/sonic_R4G4B4A4.pvr b/examples/others/resources/formats/sonic_R4G4B4A4.pvr new file mode 100644 index 00000000..3f7368a3 Binary files /dev/null and b/examples/others/resources/formats/sonic_R4G4B4A4.pvr differ diff --git a/examples/others/resources/formats/sonic_R5G5B5A1.pvr b/examples/others/resources/formats/sonic_R5G5B5A1.pvr new file mode 100644 index 00000000..c7fa098d Binary files /dev/null and b/examples/others/resources/formats/sonic_R5G5B5A1.pvr differ diff --git a/examples/others/resources/formats/sonic_R5G6B5.dds b/examples/others/resources/formats/sonic_R5G6B5.dds new file mode 100644 index 00000000..217da954 Binary files /dev/null and b/examples/others/resources/formats/sonic_R5G6B5.dds differ diff --git a/examples/others/resources/formats/sonic_R5G6B5.pvr b/examples/others/resources/formats/sonic_R5G6B5.pvr new file mode 100644 index 00000000..9bb8320e Binary files /dev/null and b/examples/others/resources/formats/sonic_R5G6B5.pvr differ diff --git a/examples/others/resources/formats/sonic_R8G8B8.pvr b/examples/others/resources/formats/sonic_R8G8B8.pvr new file mode 100644 index 00000000..072cf3ef Binary files /dev/null and b/examples/others/resources/formats/sonic_R8G8B8.pvr differ diff --git a/examples/others/resources/formats/sonic_R8G8B8A8.pvr b/examples/others/resources/formats/sonic_R8G8B8A8.pvr new file mode 100644 index 00000000..f82534f9 Binary files /dev/null and b/examples/others/resources/formats/sonic_R8G8B8A8.pvr differ diff --git a/examples/others/resources/formats/sonic_R8G8B8A8.raw b/examples/others/resources/formats/sonic_R8G8B8A8.raw new file mode 100644 index 00000000..fc5858e7 Binary files /dev/null and b/examples/others/resources/formats/sonic_R8G8B8A8.raw differ diff --git a/examples/others/resources/shaders/glsl100/standard.fs b/examples/others/resources/shaders/glsl100/standard.fs new file mode 100644 index 00000000..fe604e2a --- /dev/null +++ b/examples/others/resources/shaders/glsl100/standard.fs @@ -0,0 +1,152 @@ +#version 100 + +precision mediump float; + +varying vec3 fragPosition; +varying vec2 fragTexCoord; +varying vec4 fragColor; +varying vec3 fragNormal; + +uniform sampler2D texture0; +uniform sampler2D texture1; +uniform sampler2D texture2; + +uniform vec4 colAmbient; +uniform vec4 colDiffuse; +uniform vec4 colSpecular; +uniform float glossiness; + +uniform int useNormal; +uniform int useSpecular; + +uniform mat4 modelMatrix; +uniform vec3 viewDir; + +struct Light { + int enabled; + int type; + vec3 position; + vec3 direction; + vec4 diffuse; + float intensity; + float radius; + float coneAngle; +}; + +const int maxLights = 8; +uniform Light lights[maxLights]; + +vec3 ComputeLightPoint(Light l, vec3 n, vec3 v, float s) +{ + vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1.0)); + vec3 surfaceToLight = l.position - surfacePos; + + // Diffuse shading + float brightness = clamp(float(dot(n, surfaceToLight)/(length(surfaceToLight)*length(n))), 0.0, 1.0); + float diff = 1.0/dot(surfaceToLight/l.radius, surfaceToLight/l.radius)*brightness*l.intensity; + + // Specular shading + float spec = 0.0; + if (diff > 0.0) + { + vec3 h = normalize(-l.direction + v); + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; + } + + return (diff*l.diffuse.rgb + spec*colSpecular.rgb); +} + +vec3 ComputeLightDirectional(Light l, vec3 n, vec3 v, float s) +{ + vec3 lightDir = normalize(-l.direction); + + // Diffuse shading + float diff = clamp(float(dot(n, lightDir)), 0.0, 1.0)*l.intensity; + + // Specular shading + float spec = 0.0; + if (diff > 0.0) + { + vec3 h = normalize(lightDir + v); + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; + } + + // Combine results + return (diff*l.intensity*l.diffuse.rgb + spec*colSpecular.rgb); +} + +vec3 ComputeLightSpot(Light l, vec3 n, vec3 v, float s) +{ + vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); + vec3 lightToSurface = normalize(surfacePos - l.position); + vec3 lightDir = normalize(-l.direction); + + // Diffuse shading + float diff = clamp(float(dot(n, lightDir)), 0.0, 1.0)*l.intensity; + + // Spot attenuation + float attenuation = clamp(float(dot(n, lightToSurface)), 0.0, 1.0); + attenuation = dot(lightToSurface, -lightDir); + + float lightToSurfaceAngle = degrees(acos(attenuation)); + if (lightToSurfaceAngle > l.coneAngle) attenuation = 0.0; + + float falloff = (l.coneAngle - lightToSurfaceAngle)/l.coneAngle; + + // Combine diffuse and attenuation + float diffAttenuation = diff*attenuation; + + // Specular shading + float spec = 0.0; + if (diffAttenuation > 0.0) + { + vec3 h = normalize(lightDir + v); + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; + } + + return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); +} + +void main() +{ + // Calculate fragment normal in screen space + // NOTE: important to multiply model matrix by fragment normal to apply model transformation (rotation and scale) + mat3 normalMatrix = mat3(modelMatrix); + vec3 normal = normalize(normalMatrix*fragNormal); + + // Normalize normal and view direction vectors + vec3 n = normalize(normal); + vec3 v = normalize(viewDir); + + // Calculate diffuse texture color fetching + vec4 texelColor = texture2D(texture0, fragTexCoord); + vec3 lighting = colAmbient.rgb; + + // Calculate normal texture color fetching or set to maximum normal value by default + if (useNormal == 1) + { + n *= texture2D(texture1, fragTexCoord).rgb; + n = normalize(n); + } + + // Calculate specular texture color fetching or set to maximum specular value by default + float spec = 1.0; + if (useSpecular == 1) spec = texture2D(texture2, fragTexCoord).r; + + for (int i = 0; i < maxLights; i++) + { + // Check if light is enabled + if (lights[i].enabled == 1) + { + // Calculate lighting based on light type + if(lights[i].type == 0) lighting += ComputeLightPoint(lights[i], n, v, spec); + else if(lights[i].type == 1) lighting += ComputeLightDirectional(lights[i], n, v, spec); + else if(lights[i].type == 2) lighting += ComputeLightSpot(lights[i], n, v, spec); + + // NOTE: It seems that too many ComputeLight*() operations inside for loop breaks the shader on RPI + } + } + + // Calculate final fragment color + gl_FragColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); +} diff --git a/examples/others/resources/shaders/glsl100/standard.vs b/examples/others/resources/shaders/glsl100/standard.vs new file mode 100644 index 00000000..49c5a3eb --- /dev/null +++ b/examples/others/resources/shaders/glsl100/standard.vs @@ -0,0 +1,23 @@ +#version 100 + +attribute vec3 vertexPosition; +attribute vec3 vertexNormal; +attribute vec2 vertexTexCoord; +attribute vec4 vertexColor; + +varying vec3 fragPosition; +varying vec2 fragTexCoord; +varying vec4 fragColor; +varying vec3 fragNormal; + +uniform mat4 mvpMatrix; + +void main() +{ + fragPosition = vertexPosition; + fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + fragNormal = vertexNormal; + + gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); +} \ No newline at end of file diff --git a/examples/others/resources/shaders/glsl330/standard.fs b/examples/others/resources/shaders/glsl330/standard.fs new file mode 100644 index 00000000..0d461484 --- /dev/null +++ b/examples/others/resources/shaders/glsl330/standard.fs @@ -0,0 +1,150 @@ +#version 330 + +in vec3 fragPosition; +in vec2 fragTexCoord; +in vec4 fragColor; +in vec3 fragNormal; + +out vec4 finalColor; + +uniform sampler2D texture0; +uniform sampler2D texture1; +uniform sampler2D texture2; + +uniform vec4 colAmbient; +uniform vec4 colDiffuse; +uniform vec4 colSpecular; +uniform float glossiness; + +uniform int useNormal; +uniform int useSpecular; + +uniform mat4 modelMatrix; +uniform vec3 viewDir; + +struct Light { + int enabled; + int type; + vec3 position; + vec3 direction; + vec4 diffuse; + float intensity; + float radius; + float coneAngle; +}; + +const int maxLights = 8; +uniform Light lights[maxLights]; + +vec3 ComputeLightPoint(Light l, vec3 n, vec3 v, float s) +{ + vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); + vec3 surfaceToLight = l.position - surfacePos; + + // Diffuse shading + float brightness = clamp(float(dot(n, surfaceToLight)/(length(surfaceToLight)*length(n))), 0.0, 1.0); + float diff = 1.0/dot(surfaceToLight/l.radius, surfaceToLight/l.radius)*brightness*l.intensity; + + // Specular shading + float spec = 0.0; + if (diff > 0.0) + { + vec3 h = normalize(-l.direction + v); + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; + } + + return (diff*l.diffuse.rgb + spec*colSpecular.rgb); +} + +vec3 ComputeLightDirectional(Light l, vec3 n, vec3 v, float s) +{ + vec3 lightDir = normalize(-l.direction); + + // Diffuse shading + float diff = clamp(float(dot(n, lightDir)), 0.0, 1.0)*l.intensity; + + // Specular shading + float spec = 0.0; + if (diff > 0.0) + { + vec3 h = normalize(lightDir + v); + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; + } + + // Combine results + return (diff*l.intensity*l.diffuse.rgb + spec*colSpecular.rgb); +} + +vec3 ComputeLightSpot(Light l, vec3 n, vec3 v, float s) +{ + vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); + vec3 lightToSurface = normalize(surfacePos - l.position); + vec3 lightDir = normalize(-l.direction); + + // Diffuse shading + float diff = clamp(float(dot(n, lightDir)), 0.0, 1.0)*l.intensity; + + // Spot attenuation + float attenuation = clamp(float(dot(n, lightToSurface)), 0.0, 1.0); + attenuation = dot(lightToSurface, -lightDir); + + float lightToSurfaceAngle = degrees(acos(attenuation)); + if (lightToSurfaceAngle > l.coneAngle) attenuation = 0.0; + + float falloff = (l.coneAngle - lightToSurfaceAngle)/l.coneAngle; + + // Combine diffuse and attenuation + float diffAttenuation = diff*attenuation; + + // Specular shading + float spec = 0.0; + if (diffAttenuation > 0.0) + { + vec3 h = normalize(lightDir + v); + spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; + } + + return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); +} + +void main() +{ + // Calculate fragment normal in screen space + // NOTE: important to multiply model matrix by fragment normal to apply model transformation (rotation and scale) + mat3 normalMatrix = mat3(modelMatrix); + vec3 normal = normalize(normalMatrix*fragNormal); + + // Normalize normal and view direction vectors + vec3 n = normalize(normal); + vec3 v = normalize(viewDir); + + // Calculate diffuse texture color fetching + vec4 texelColor = texture(texture0, fragTexCoord); + vec3 lighting = colAmbient.rgb; + + // Calculate normal texture color fetching or set to maximum normal value by default + if (useNormal == 1) + { + n *= texture(texture1, fragTexCoord).rgb; + n = normalize(n); + } + + // Calculate specular texture color fetching or set to maximum specular value by default + float spec = 1.0; + if (useSpecular == 1) spec = texture(texture2, fragTexCoord).r; + + for (int i = 0; i < maxLights; i++) + { + // Check if light is enabled + if (lights[i].enabled == 1) + { + // Calculate lighting based on light type + if (lights[i].type == 0) lighting += ComputeLightPoint(lights[i], n, v, spec); + else if (lights[i].type == 1) lighting += ComputeLightDirectional(lights[i], n, v, spec); + else if (lights[i].type == 2) lighting += ComputeLightSpot(lights[i], n, v, spec); + } + } + + // Calculate final fragment color + finalColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); +} diff --git a/examples/others/resources/shaders/glsl330/standard.vs b/examples/others/resources/shaders/glsl330/standard.vs new file mode 100644 index 00000000..fc0a5ff4 --- /dev/null +++ b/examples/others/resources/shaders/glsl330/standard.vs @@ -0,0 +1,23 @@ +#version 330 + +in vec3 vertexPosition; +in vec3 vertexNormal; +in vec2 vertexTexCoord; +in vec4 vertexColor; + +out vec3 fragPosition; +out vec2 fragTexCoord; +out vec4 fragColor; +out vec3 fragNormal; + +uniform mat4 mvpMatrix; + +void main() +{ + fragPosition = vertexPosition; + fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + fragNormal = vertexNormal; + + gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); +} \ No newline at end of file diff --git a/examples/others/rlgl_oculus_rift.c b/examples/others/rlgl_oculus_rift.c deleted file mode 100644 index 30ef6f3b..00000000 --- a/examples/others/rlgl_oculus_rift.c +++ /dev/null @@ -1,393 +0,0 @@ -/******************************************************************************************* -* -* raylib [rlgl] example - Oculus minimum sample -* -* NOTE: This example requires OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders but it can also be used. -* -* Compile rlgl module using: -* gcc -c rlgl.c -Wall -std=c99 -DRLGL_STANDALONE -DRAYMATH_IMPLEMENTATION -DGRAPHICS_API_OPENGL_33 -DRLGL_OCULUS_SUPPORT -* -* NOTE 1: rlgl module requires the following header-only files: -* external/glad.h - OpenGL extensions loader (stripped to only required extensions) -* shader_standard.h - Standard shader for materials and lighting -* shader_distortion.h - Distortion shader for VR -* raymath.h - Vector and matrix math functions -* -* NOTE 2: rlgl requires LibOVR (Oculus PC SDK) to support Oculus Rift CV1 -* -* Compile example using: -* gcc -o rlgl_oculus_rift.exe rlgl_oculus_rift.c rlgl.o -L. -lLibOVRRT32_1 -lglfw3 -lopengl32 -lgdi32 -std=c99 -* -* NOTE: Example must be linked against LibOVRRT32_1.dll that comes with Oculus Rift runtime. -* -* This example has been created using raylib 1.5 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include -#include -#include -#include -#include - -#include // Windows/Context and inputs management - -#define RLGL_STANDALONE -#include "rlgl.h" // rlgl library: OpenGL 1.1 immediate-mode style coding - -#define RED (Color){ 230, 41, 55, 255 } // Red -#define RAYWHITE (Color){ 245, 245, 245, 255 } // My own White (raylib logo) -#define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray - -//---------------------------------------------------------------------------------- -// Module specific Functions Declaration -//---------------------------------------------------------------------------------- -static void ErrorCallback(int error, const char* description); -static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); - -// Drawing functions (uses rlgl functionality) -static void DrawGrid(int slices, float spacing); -static void DrawCube(Vector3 position, float width, float height, float length, Color color); -static void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); -static void DrawRectangleV(Vector2 position, Vector2 size, Color color); - -//---------------------------------------------------------------------------------- -// Main Entry point -//---------------------------------------------------------------------------------- -int main(void) -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 1080; // Mirror screen width (set to hmdDesc.Resolution.w/2) - int screenHeight = 600; // Mirror screen height (set to hmdDesc.Resolution.h/2) - - // NOTE: Mirror screen size can be set to any desired resolution! - - // GLFW3 Initialization + OpenGL 3.3 Context + Extensions - //-------------------------------------------------------- - glfwSetErrorCallback(ErrorCallback); - - if (!glfwInit()) - { - TraceLog(WARNING, "GLFW3: Can not initialize GLFW"); - return 1; - } - else TraceLog(INFO, "GLFW3: GLFW initialized successfully"); - - glfwWindowHint(GLFW_SAMPLES, 4); - glfwWindowHint(GLFW_DEPTH_BITS, 16); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); - - GLFWwindow *window = glfwCreateWindow(screenWidth, screenHeight, "rlgl oculus rift", NULL, NULL); - - if (!window) - { - glfwTerminate(); - return 2; - } - else TraceLog(INFO, "GLFW3: Window created successfully"); - - glfwSetKeyCallback(window, KeyCallback); - - glfwMakeContextCurrent(window); - glfwSwapInterval(0); - - // Load OpenGL 3.3 supported extensions - rlglLoadExtensions(glfwGetProcAddress); - //-------------------------------------------------------- - - // Initialize OpenGL context (states and resources) - rlglInit(screenWidth, screenHeight); - - rlClearColor(245, 245, 245, 255); // Define clear color - rlEnableDepthTest(); // Enable DEPTH_TEST for 3D - - // Define custom camera to initialize projection and view matrices - Camera camera; - camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - - // Initialize viewport and internal projection/modelview matrices - rlViewport(0, 0, screenWidth, screenHeight); - rlMatrixMode(RL_PROJECTION); // Switch to PROJECTION matrix - rlLoadIdentity(); // Reset current matrix (PROJECTION) - - // Setup perspective projection - float aspect = (float)screenWidth/(float)screenHeight; - double top = 0.01*tan(camera.fovy*PI/360.0); - double right = top*aspect; - rlFrustum(-right, right, -top, top, 0.01, 1000.0); - - rlMatrixMode(RL_MODELVIEW); // Switch back to MODELVIEW matrix - rlLoadIdentity(); // Reset current matrix (MODELVIEW) - - // Setup Camera view - Matrix cameraView = MatrixLookAt(camera.position, camera.target, camera.up); - rlMultMatrixf(MatrixToFloat(cameraView)); // Multiply MODELVIEW matrix by view matrix (camera) - - InitOculusDevice(); // Initialize Oculus Rift CV1 - - Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!glfwWindowShouldClose(window)) - { - // Update - //---------------------------------------------------------------------------------- - UpdateOculusTracking(&camera); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginOculusDrawing(); - - rlClearScreenBuffers(); // Clear current framebuffer(s) - - DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); - DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, RAYWHITE); - DrawGrid(10, 1.0f); - - // NOTE: Internal buffers drawing (3D data) - rlglDraw(); - - EndOculusDrawing(); - - glfwSwapBuffers(window); - glfwPollEvents(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - CloseOculusDevice(); // Close Oculus device and clear resources - - rlglClose(); // Unload rlgl internal buffers and default shader/texture - - glfwDestroyWindow(window); // Close window - glfwTerminate(); // Free GLFW3 resources - //-------------------------------------------------------------------------------------- - - return 0; -} - -//---------------------------------------------------------------------------------- -// Module specific Functions Definitions -//---------------------------------------------------------------------------------- - -// GLFW3: Error callback -static void ErrorCallback(int error, const char* description) -{ - TraceLog(ERROR, description); -} - -// GLFW3: Keyboard callback -static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) - { - glfwSetWindowShouldClose(window, GL_TRUE); - } -} - -// Draw rectangle using rlgl OpenGL 1.1 style coding (translated to OpenGL 3.3 internally) -static void DrawRectangleV(Vector2 position, Vector2 size, Color color) -{ - rlBegin(RL_TRIANGLES); - rlColor4ub(color.r, color.g, color.b, color.a); - - rlVertex2i(position.x, position.y); - rlVertex2i(position.x, position.y + size.y); - rlVertex2i(position.x + size.x, position.y + size.y); - - rlVertex2i(position.x, position.y); - rlVertex2i(position.x + size.x, position.y + size.y); - rlVertex2i(position.x + size.x, position.y); - rlEnd(); -} - -// Draw a grid centered at (0, 0, 0) -static void DrawGrid(int slices, float spacing) -{ - int halfSlices = slices / 2; - - rlBegin(RL_LINES); - for(int i = -halfSlices; i <= halfSlices; i++) - { - if (i == 0) - { - rlColor3f(0.5f, 0.5f, 0.5f); - rlColor3f(0.5f, 0.5f, 0.5f); - rlColor3f(0.5f, 0.5f, 0.5f); - rlColor3f(0.5f, 0.5f, 0.5f); - } - else - { - rlColor3f(0.75f, 0.75f, 0.75f); - rlColor3f(0.75f, 0.75f, 0.75f); - rlColor3f(0.75f, 0.75f, 0.75f); - rlColor3f(0.75f, 0.75f, 0.75f); - } - - rlVertex3f((float)i*spacing, 0.0f, (float)-halfSlices*spacing); - rlVertex3f((float)i*spacing, 0.0f, (float)halfSlices*spacing); - - rlVertex3f((float)-halfSlices*spacing, 0.0f, (float)i*spacing); - rlVertex3f((float)halfSlices*spacing, 0.0f, (float)i*spacing); - } - rlEnd(); -} - -// Draw cube -// NOTE: Cube position is the center position -void DrawCube(Vector3 position, float width, float height, float length, Color color) -{ - float x = 0.0f; - float y = 0.0f; - float z = 0.0f; - - rlPushMatrix(); - - // NOTE: Be careful! Function order matters (rotate -> scale -> translate) - rlTranslatef(position.x, position.y, position.z); - //rlScalef(2.0f, 2.0f, 2.0f); - //rlRotatef(45, 0, 1, 0); - - rlBegin(RL_TRIANGLES); - rlColor4ub(color.r, color.g, color.b, color.a); - - // Front Face ----------------------------------------------------- - rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left - rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right - rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left - - rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right - rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left - rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right - - // Back Face ------------------------------------------------------ - rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left - rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left - rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right - - rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right - rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right - rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left - - // Top Face ------------------------------------------------------- - rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left - rlVertex3f(x-width/2, y+height/2, z+length/2); // Bottom Left - rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right - - rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right - rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left - rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right - - // Bottom Face ---------------------------------------------------- - rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left - rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right - rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left - - rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right - rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right - rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left - - // Right face ----------------------------------------------------- - rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right - rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right - rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left - - rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Left - rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right - rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left - - // Left Face ------------------------------------------------------ - rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right - rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left - rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Right - - rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left - rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left - rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right - rlEnd(); - rlPopMatrix(); -} - -// Draw cube wires -void DrawCubeWires(Vector3 position, float width, float height, float length, Color color) -{ - float x = 0.0f; - float y = 0.0f; - float z = 0.0f; - - rlPushMatrix(); - - rlTranslatef(position.x, position.y, position.z); - //rlRotatef(45, 0, 1, 0); - - rlBegin(RL_LINES); - rlColor4ub(color.r, color.g, color.b, color.a); - - // Front Face ----------------------------------------------------- - // Bottom Line - rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left - rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right - - // Left Line - rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right - rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right - - // Top Line - rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right - rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left - - // Right Line - rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left - rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left - - // Back Face ------------------------------------------------------ - // Bottom Line - rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left - rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right - - // Left Line - rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right - rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right - - // Top Line - rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right - rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left - - // Right Line - rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left - rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left - - // Top Face ------------------------------------------------------- - // Left Line - rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left Front - rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Back - - // Right Line - rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right Front - rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Back - - // Bottom Face --------------------------------------------------- - // Left Line - rlVertex3f(x-width/2, y-height/2, z+length/2); // Top Left Front - rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left Back - - // Right Line - rlVertex3f(x+width/2, y-height/2, z+length/2); // Top Right Front - rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right Back - rlEnd(); - rlPopMatrix(); -} \ No newline at end of file diff --git a/examples/others/standard_lighting.c b/examples/others/standard_lighting.c new file mode 100644 index 00000000..14fda32e --- /dev/null +++ b/examples/others/standard_lighting.c @@ -0,0 +1,483 @@ +/******************************************************************************************* +* +* raylib [shaders] example - Standard lighting (materials and lights) +* +* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, +* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. +* +* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example +* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders +* raylib comes with shaders ready for both versions, check raylib/shaders install folder +* +* This example has been created using raylib 1.7 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2016-2017 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +#include // Required for: NULL +#include // Required for: strcpy() +#include // Required for: vector math + +//---------------------------------------------------------------------------------- +// Defines and Macros +//---------------------------------------------------------------------------------- +#define MAX_LIGHTS 8 // Max lights supported by standard shader + +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- + +// Light type +typedef struct LightData { + unsigned int id; // Light unique id + bool enabled; // Light enabled + int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT + + Vector3 position; // Light position + Vector3 target; // Light direction: LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target) + float radius; // Light attenuation radius light intensity reduced with distance (world distance) + + Color diffuse; // Light diffuse color + float intensity; // Light intensity level + + float coneAngle; // Light cone max angle: LIGHT_SPOT +} LightData, *Light; + +// Light types +typedef enum { LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT } LightType; + +//---------------------------------------------------------------------------------- +// Global Variables Definition +//---------------------------------------------------------------------------------- +static Light lights[MAX_LIGHTS]; // Lights pool +static int lightsCount = 0; // Enabled lights counter +static int lightsLocs[MAX_LIGHTS][8]; // Lights location points in shader: 8 possible points per light: + // enabled, type, position, target, radius, diffuse, intensity, coneAngle + +//---------------------------------------------------------------------------------- +// Module Functions Declaration +//---------------------------------------------------------------------------------- +static Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool +static void DestroyLight(Light light); // Destroy a light and take it out of the list +static void DrawLight(Light light); // Draw light in 3D world + +static void GetShaderLightsLocations(Shader shader); // Get shader locations for lights (up to MAX_LIGHTS) +static void SetShaderLightsValues(Shader shader); // Set shader uniform values for lights + +// Vector3 math functions +static float VectorLength(const Vector3 v); // Calculate vector lenght +static void VectorNormalize(Vector3 *v); // Normalize provided vector +static Vector3 VectorSubtract(Vector3 v1, Vector3 v2); // Substract two vectors + + +//https://www.gamedev.net/topic/655969-speed-gluniform-vs-uniform-buffer-objects/ +//https://www.reddit.com/r/opengl/comments/4ri20g/is_gluniform_more_expensive_than_glprogramuniform/ +//http://cg.alexandra.dk/?p=3778 - AZDO +//https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) + + InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader"); + + // Define the camera to look into our 3d world + Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; + Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position + + Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model + + Material material;// = LoadStandardMaterial(); + + material.shader = LoadShader("resources/shaders/glsl330/standard.vs", + "resources/shaders/glsl330/standard.fs"); + + // Try to get lights location points (if available) + GetShaderLightsLocations(material.shader); + + material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture + material.texNormal = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture + material.texSpecular = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture + material.colDiffuse = WHITE; + material.colAmbient = (Color){0, 0, 10, 255}; + material.colSpecular = WHITE; + material.glossiness = 50.0f; + + dwarf.material = material; // Apply material to model + + Light spotLight = CreateLight(LIGHT_SPOT, (Vector3){3.0f, 5.0f, 2.0f}, (Color){255, 255, 255, 255}); + spotLight->target = (Vector3){0.0f, 0.0f, 0.0f}; + spotLight->intensity = 2.0f; + spotLight->diffuse = (Color){255, 100, 100, 255}; + spotLight->coneAngle = 60.0f; + + Light dirLight = CreateLight(LIGHT_DIRECTIONAL, (Vector3){0.0f, -3.0f, -3.0f}, (Color){255, 255, 255, 255}); + dirLight->target = (Vector3){1.0f, -2.0f, -2.0f}; + dirLight->intensity = 2.0f; + dirLight->diffuse = (Color){100, 255, 100, 255}; + + Light pointLight = CreateLight(LIGHT_POINT, (Vector3){0.0f, 4.0f, 5.0f}, (Color){255, 255, 255, 255}); + pointLight->intensity = 2.0f; + pointLight->diffuse = (Color){100, 100, 255, 255}; + pointLight->radius = 3.0f; + + // Set shader lights values for enabled lights + // NOTE: If values are not changed in real time, they can be set at initialization!!! + SetShaderLightsValues(material.shader); + + //SetShaderActive(0); + + // Setup orbital camera + SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + UpdateCamera(&camera); // Update camera + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + Begin3dMode(camera); + + DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture + + DrawLight(spotLight); // Draw spot light + DrawLight(dirLight); // Draw directional light + DrawLight(pointLight); // Draw point light + + DrawGrid(10, 1.0f); // Draw a grid + + End3dMode(); + + DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); + + DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadMaterial(material); // Unload material and assigned textures + UnloadModel(dwarf); // Unload model + + // Destroy all created lights + DestroyLight(pointLight); + DestroyLight(dirLight); + DestroyLight(spotLight); + + // Unload lights + if (lightsCount > 0) + { + for (int i = 0; i < lightsCount; i++) free(lights[i]); + lightsCount = 0; + } + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} + +//-------------------------------------------------------------------------------------------- +// Module Functions Definitions +//-------------------------------------------------------------------------------------------- + +// Create a new light, initialize it and add to pool +Light CreateLight(int type, Vector3 position, Color diffuse) +{ + Light light = NULL; + + if (lightsCount < MAX_LIGHTS) + { + // Allocate dynamic memory + light = (Light)malloc(sizeof(LightData)); + + // Initialize light values with generic values + light->id = lightsCount; + light->type = type; + light->enabled = true; + + light->position = position; + light->target = (Vector3){ 0.0f, 0.0f, 0.0f }; + light->intensity = 1.0f; + light->diffuse = diffuse; + + // Add new light to the array + lights[lightsCount] = light; + + // Increase enabled lights count + lightsCount++; + } + else + { + // NOTE: Returning latest created light to avoid crashes + light = lights[lightsCount]; + } + + return light; +} + +// Destroy a light and take it out of the list +void DestroyLight(Light light) +{ + if (light != NULL) + { + int lightId = light->id; + + // Free dynamic memory allocation + free(lights[lightId]); + + // Remove *obj from the pointers array + for (int i = lightId; i < lightsCount; i++) + { + // Resort all the following pointers of the array + if ((i + 1) < lightsCount) + { + lights[i] = lights[i + 1]; + lights[i]->id = lights[i + 1]->id; + } + } + + // Decrease enabled physic objects count + lightsCount--; + } +} + +// Draw light in 3D world +void DrawLight(Light light) +{ + switch (light->type) + { + case LIGHT_POINT: + { + DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY)); + + DrawCircle3D(light->position, light->radius, (Vector3){ 0, 0, 0 }, 0.0f, (light->enabled ? light->diffuse : GRAY)); + DrawCircle3D(light->position, light->radius, (Vector3){ 1, 0, 0 }, 90.0f, (light->enabled ? light->diffuse : GRAY)); + DrawCircle3D(light->position, light->radius, (Vector3){ 0, 1, 0 },90.0f, (light->enabled ? light->diffuse : GRAY)); + } break; + case LIGHT_DIRECTIONAL: + { + DrawLine3D(light->position, light->target, (light->enabled ? light->diffuse : GRAY)); + + DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY)); + DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY)); + } break; + case LIGHT_SPOT: + { + DrawLine3D(light->position, light->target, (light->enabled ? light->diffuse : GRAY)); + + Vector3 dir = VectorSubtract(light->target, light->position); + VectorNormalize(&dir); + + DrawCircle3D(light->position, 0.5f, dir, 0.0f, (light->enabled ? light->diffuse : GRAY)); + + //DrawCylinderWires(light->position, 0.0f, 0.3f*light->coneAngle/50, 0.6f, 5, (light->enabled ? light->diffuse : GRAY)); + DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY)); + } break; + default: break; + } +} + +// Get shader locations for lights (up to MAX_LIGHTS) +static void GetShaderLightsLocations(Shader shader) +{ + char locName[32] = "lights[x].\0"; + char locNameUpdated[64]; + + for (int i = 0; i < MAX_LIGHTS; i++) + { + locName[7] = '0' + i; + + strcpy(locNameUpdated, locName); + strcat(locNameUpdated, "enabled\0"); + lightsLocs[i][0] = GetShaderLocation(shader, locNameUpdated); + + locNameUpdated[0] = '\0'; + strcpy(locNameUpdated, locName); + strcat(locNameUpdated, "type\0"); + lightsLocs[i][1] = GetShaderLocation(shader, locNameUpdated); + + locNameUpdated[0] = '\0'; + strcpy(locNameUpdated, locName); + strcat(locNameUpdated, "position\0"); + lightsLocs[i][2] = GetShaderLocation(shader, locNameUpdated); + + locNameUpdated[0] = '\0'; + strcpy(locNameUpdated, locName); + strcat(locNameUpdated, "direction\0"); + lightsLocs[i][3] = GetShaderLocation(shader, locNameUpdated); + + locNameUpdated[0] = '\0'; + strcpy(locNameUpdated, locName); + strcat(locNameUpdated, "radius\0"); + lightsLocs[i][4] = GetShaderLocation(shader, locNameUpdated); + + locNameUpdated[0] = '\0'; + strcpy(locNameUpdated, locName); + strcat(locNameUpdated, "diffuse\0"); + lightsLocs[i][5] = GetShaderLocation(shader, locNameUpdated); + + locNameUpdated[0] = '\0'; + strcpy(locNameUpdated, locName); + strcat(locNameUpdated, "intensity\0"); + lightsLocs[i][6] = GetShaderLocation(shader, locNameUpdated); + + locNameUpdated[0] = '\0'; + strcpy(locNameUpdated, locName); + strcat(locNameUpdated, "coneAngle\0"); + lightsLocs[i][7] = GetShaderLocation(shader, locNameUpdated); + } +} + +// Set shader uniform values for lights +// NOTE: It would be far easier with shader UBOs but are not supported on OpenGL ES 2.0 +// TODO: Replace glUniform1i(), glUniform1f(), glUniform3f(), glUniform4f(): +//SetShaderValue(Shader shader, int uniformLoc, float *value, int size) +//SetShaderValuei(Shader shader, int uniformLoc, int *value, int size) +static void SetShaderLightsValues(Shader shader) +{ + int tempInt[8] = { 0 }; + float tempFloat[8] = { 0.0f }; + + for (int i = 0; i < MAX_LIGHTS; i++) + { + if (i < lightsCount) + { + tempInt[0] = lights[i]->enabled; + SetShaderValuei(shader, lightsLocs[i][0], tempInt, 1); //glUniform1i(lightsLocs[i][0], lights[i]->enabled); + + tempInt[0] = lights[i]->type; + SetShaderValuei(shader, lightsLocs[i][1], tempInt, 1); //glUniform1i(lightsLocs[i][1], lights[i]->type); + + tempFloat[0] = (float)lights[i]->diffuse.r/255.0f; + tempFloat[1] = (float)lights[i]->diffuse.g/255.0f; + tempFloat[2] = (float)lights[i]->diffuse.b/255.0f; + tempFloat[3] = (float)lights[i]->diffuse.a/255.0f; + SetShaderValue(shader, lightsLocs[i][5], tempFloat, 4); + //glUniform4f(lightsLocs[i][5], (float)lights[i]->diffuse.r/255, (float)lights[i]->diffuse.g/255, (float)lights[i]->diffuse.b/255, (float)lights[i]->diffuse.a/255); + + tempFloat[0] = lights[i]->intensity; + SetShaderValue(shader, lightsLocs[i][6], tempFloat, 1); + + switch (lights[i]->type) + { + case LIGHT_POINT: + { + tempFloat[0] = lights[i]->position.x; + tempFloat[1] = lights[i]->position.y; + tempFloat[2] = lights[i]->position.z; + SetShaderValue(shader, lightsLocs[i][2], tempFloat, 3); + + tempFloat[0] = lights[i]->radius; + SetShaderValue(shader, lightsLocs[i][4], tempFloat, 1); + + //glUniform3f(lightsLocs[i][2], lights[i]->position.x, lights[i]->position.y, lights[i]->position.z); + //glUniform1f(lightsLocs[i][4], lights[i]->radius); + } break; + case LIGHT_DIRECTIONAL: + { + Vector3 direction = VectorSubtract(lights[i]->target, lights[i]->position); + VectorNormalize(&direction); + + tempFloat[0] = direction.x; + tempFloat[1] = direction.y; + tempFloat[2] = direction.z; + SetShaderValue(shader, lightsLocs[i][3], tempFloat, 3); + + //glUniform3f(lightsLocs[i][3], direction.x, direction.y, direction.z); + } break; + case LIGHT_SPOT: + { + tempFloat[0] = lights[i]->position.x; + tempFloat[1] = lights[i]->position.y; + tempFloat[2] = lights[i]->position.z; + SetShaderValue(shader, lightsLocs[i][2], tempFloat, 3); + + //glUniform3f(lightsLocs[i][2], lights[i]->position.x, lights[i]->position.y, lights[i]->position.z); + + Vector3 direction = VectorSubtract(lights[i]->target, lights[i]->position); + VectorNormalize(&direction); + + tempFloat[0] = direction.x; + tempFloat[1] = direction.y; + tempFloat[2] = direction.z; + SetShaderValue(shader, lightsLocs[i][3], tempFloat, 3); + //glUniform3f(lightsLocs[i][3], direction.x, direction.y, direction.z); + + tempFloat[0] = lights[i]->coneAngle; + SetShaderValue(shader, lightsLocs[i][7], tempFloat, 1); + //glUniform1f(lightsLocs[i][7], lights[i]->coneAngle); + } break; + default: break; + } + } + else + { + tempInt[0] = 0; + SetShaderValuei(shader, lightsLocs[i][0], tempInt, 1); //glUniform1i(lightsLocs[i][0], 0); // Light disabled + } + } +} + +// Calculate vector lenght +float VectorLength(const Vector3 v) +{ + float length; + + length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); + + return length; +} + +// Normalize provided vector +void VectorNormalize(Vector3 *v) +{ + float length, ilength; + + length = VectorLength(*v); + + if (length == 0.0f) length = 1.0f; + + ilength = 1.0f/length; + + v->x *= ilength; + v->y *= ilength; + v->z *= ilength; +} + +// Substract two vectors +Vector3 VectorSubtract(Vector3 v1, Vector3 v2) +{ + Vector3 result; + + result.x = v1.x - v2.x; + result.y = v1.y - v2.y; + result.z = v1.z - v2.z; + + return result; +} diff --git a/examples/shaders/resources/model/lowpoly-tower.obj b/examples/shaders/resources/model/lowpoly-tower.obj deleted file mode 100644 index ea03a9fc..00000000 --- a/examples/shaders/resources/model/lowpoly-tower.obj +++ /dev/null @@ -1,456 +0,0 @@ -# Blender v2.78 (sub 0) OBJ File: 'lowpoly-tower.blend' -# www.blender.org -o Grid -v -4.000000 0.000000 4.000000 -v -2.327363 0.000000 4.654725 -v 0.000000 0.000000 4.654725 -v 2.327363 0.000000 4.654725 -v 4.000000 0.000000 4.000000 -v -4.654725 0.955085 2.327363 -v -2.000000 0.815050 2.000000 -v 0.000000 0.476341 2.423448 -v 2.000000 0.476341 2.000000 -v 4.654725 0.000000 2.327363 -v -4.654725 1.649076 0.000000 -v -2.423448 1.092402 0.000000 -v 2.423448 0.198579 0.000000 -v 4.654725 0.000000 0.000000 -v -4.654725 1.649076 -2.327363 -v -2.000000 1.092402 -2.000000 -v 0.000000 0.476341 -2.423448 -v 2.000000 -0.012791 -2.000000 -v 4.654725 0.000000 -2.612731 -v -4.000000 0.955085 -4.000000 -v -2.327363 0.955085 -4.654725 -v 0.000000 0.955085 -4.654725 -v 2.327363 0.000000 -4.654725 -v 4.000000 0.000000 -4.000000 -v 2.423448 0.682825 0.000000 -v 2.000000 0.565423 -2.000000 -v -4.654725 -0.020560 2.327363 -v -4.654725 0.000000 0.000000 -v -4.654725 0.000000 -2.327363 -v -4.000000 0.000000 -4.000000 -v -2.327363 0.000000 -4.654725 -v 0.000000 -0.020560 -4.654725 -v 0.000000 0.709880 -1.230535 -v -0.000000 7.395413 0.000000 -v 0.962071 0.709880 -0.767226 -v -0.533909 0.709880 1.108674 -v -1.199683 0.709880 0.273820 -v -0.962071 0.709880 -0.767226 -v 1.506076 0.859071 1.325337 -v 1.199683 0.709880 0.273820 -v 0.533909 0.709880 1.108674 -v 0.000000 1.875340 -1.177842 -v -0.000000 2.293973 -0.649884 -v -0.000000 4.365648 -0.627970 -v 0.000000 6.167194 -0.942957 -v 0.000000 6.232434 -1.708677 -v 1.335898 6.232434 -1.065343 -v 0.737233 6.167195 -0.587924 -v 0.490966 4.365648 -0.391533 -v 0.508100 2.293973 -0.405196 -v 0.920874 1.875340 -0.734372 -v -0.741367 6.232434 1.539465 -v -0.409133 6.167195 0.849574 -v -0.272466 4.365648 0.565781 -v -0.281974 2.293973 0.585526 -v -0.511047 1.875340 1.061199 -v -1.665837 6.232434 0.380217 -v -0.919314 6.167195 0.209828 -v -0.612225 4.365648 0.139736 -v -0.633590 2.293973 0.144613 -v -1.148311 1.875340 0.262095 -v -1.335898 6.232434 -1.065343 -v -0.737233 6.167195 -0.587924 -v -0.490967 4.365648 -0.391533 -v -0.508100 2.293973 -0.405196 -v -0.920874 1.875340 -0.734372 -v 1.665837 6.232434 0.380216 -v 0.919315 6.167195 0.209828 -v 0.612225 4.365648 0.139736 -v 0.633590 2.293973 0.144613 -v 1.148311 1.875340 0.262095 -v 0.741367 6.232434 1.539465 -v 0.409133 6.167195 0.849575 -v 0.272466 4.365648 0.565781 -v 0.281974 2.293973 0.585526 -v 0.511046 1.875340 1.061199 -v 0.000000 5.012550 -0.969733 -v 0.758168 5.012550 -0.604618 -v -0.420751 5.012550 0.873699 -v -0.945419 5.012550 0.215786 -v -0.758168 5.012550 -0.604618 -v 0.945419 5.012550 0.215786 -v 0.420751 5.012550 0.873699 -vt 0.0523 0.5444 -vt 0.1817 0.4284 -vt 0.1641 0.5859 -vt 0.0177 0.4451 -vt 0.1526 0.3090 -vt 0.0189 0.1737 -vt 0.0188 0.3088 -vt 0.0561 0.0762 -vt 0.1757 0.1924 -vt 0.3024 0.4534 -vt 0.3071 0.5902 -vt 0.3413 0.2459 -vt 0.2906 0.1614 -vt 0.4116 0.1801 -vt 0.2834 0.3774 -vt 0.1526 0.0362 -vt 0.2917 0.1622 -vt 0.4446 0.5865 -vt 0.4443 0.2989 -vt 0.3711 0.3021 -vt 0.4396 0.0275 -vt 0.4094 0.1829 -vt 0.4219 0.4255 -vt 0.5474 0.5381 -vt 0.5811 0.4376 -vt 0.5715 0.1505 -vt 0.5811 0.2997 -vt 0.5272 0.0533 -vt 0.2208 0.2194 -vt 0.3456 0.3610 -vt 0.2878 0.0321 -vt 0.2321 0.3392 -vt 0.4432 0.0177 -vt 0.7347 0.7934 -vt 0.7382 0.7595 -vt 0.8982 0.7768 -vt 0.6169 0.7595 -vt 0.6139 0.7879 -vt 0.4951 0.7634 -vt 0.1551 0.6832 -vt 0.2925 0.6268 -vt 0.2925 0.6832 -vt 0.7795 0.6832 -vt 0.6421 0.6268 -vt 0.7795 0.6255 -vt 0.5046 0.7241 -vt 0.6421 0.7241 -vt 0.3986 0.6268 -vt 0.3986 0.6832 -vt 0.5046 0.6268 -vt 0.0177 0.6268 -vt 0.1551 0.6255 -vt 0.8856 0.6268 -vt 0.1899 0.9579 -vt 0.1194 0.8696 -vt 0.2324 0.8696 -vt 0.1899 0.7813 -vt 0.0943 0.7595 -vt 0.0177 0.8206 -vt 0.0177 0.9186 -vt 0.0943 0.9797 -vt 0.2793 0.2349 -vt 0.2304 0.2758 -vt 0.6597 0.0177 -vt 0.6954 0.0993 -vt 0.6367 0.0768 -vt 0.7558 0.0777 -vt 0.7238 0.0440 -vt 0.8840 0.1330 -vt 0.7385 0.1141 -vt 0.9157 0.0886 -vt 0.9781 0.1232 -vt 0.9224 0.1276 -vt 0.2677 0.8141 -vt 0.3463 0.8037 -vt 0.3086 0.8339 -vt 0.6387 0.3550 -vt 0.7130 0.3801 -vt 0.6596 0.4053 -vt 0.7245 0.3245 -vt 0.6919 0.3383 -vt 0.8655 0.3566 -vt 0.7351 0.3577 -vt 0.9770 0.3365 -vt 0.9078 0.3751 -vt 0.9174 0.3282 -vt 0.2677 0.9018 -vt 0.3086 0.8821 -vt 0.6803 0.2948 -vt 0.6251 0.3035 -vt 0.7194 0.2854 -vt 0.8764 0.2832 -vt 0.9221 0.2861 -vt 0.3363 0.9565 -vt 0.3464 0.9122 -vt 0.6751 0.2482 -vt 0.6178 0.2499 -vt 0.7179 0.2431 -vt 0.9823 0.2484 -vt 0.9247 0.2452 -vt 0.3935 0.9014 -vt 0.6755 0.1996 -vt 0.6164 0.1941 -vt 0.7201 0.1992 -vt 0.8793 0.2446 -vt 0.9823 0.2060 -vt 0.9257 0.2051 -vt 0.4598 0.8580 -vt 0.4144 0.8579 -vt 0.6819 0.1498 -vt 0.6222 0.1361 -vt 0.7266 0.1555 -vt 0.8831 0.1684 -vt 0.9252 0.1659 -vt 0.4218 0.7790 -vt 0.3934 0.8145 -vt 0.3363 0.7595 -vt 0.8815 0.2060 -vt 0.8720 0.3208 -vt 0.8825 0.1012 -vt 0.9735 0.0816 -vt 0.9718 0.3817 -vt 0.9807 0.2918 -vt 0.4218 0.9370 -vt 0.9810 0.1644 -vn 0.1035 0.8806 0.4623 -vn 0.0964 0.9481 0.3030 -vn 0.0000 0.9780 0.2088 -vn 0.0659 0.9835 0.1683 -vn 0.2325 0.9320 0.2779 -vn 0.0553 0.9960 -0.0702 -vn 0.2827 0.9564 0.0728 -vn 0.1873 0.9776 -0.0961 -vn 0.2421 0.9703 0.0000 -vn 0.0921 0.9772 -0.1913 -vn -0.0277 0.9947 -0.0993 -vn 0.2308 0.9274 -0.2944 -vn 0.2771 0.9572 -0.0837 -vn 0.3724 0.9074 0.1947 -vn 0.0777 0.9770 -0.1985 -vn -0.1094 0.9539 0.2794 -vn 0.0364 0.9844 0.1721 -vn 0.1683 0.9835 0.0659 -vn 0.0674 0.9901 0.1230 -vn 0.4338 0.8823 0.1829 -vn 0.2845 0.9565 0.0649 -vn 0.0886 0.9961 0.0000 -vn 0.2000 0.9789 0.0424 -vn 0.1417 0.9830 0.1171 -vn 0.3021 0.9524 0.0412 -vn -0.0193 0.9986 -0.0493 -vn 0.0000 0.9777 0.2098 -vn 0.0005 0.9781 -0.2083 -vn 0.1879 0.9782 -0.0887 -vn 0.2249 0.0000 0.9744 -vn 0.9783 0.0000 -0.2071 -vn 0.9783 0.0000 0.2071 -vn 0.0000 0.0000 -1.0000 -vn -1.0000 0.0000 0.0000 -vn -0.3645 0.0000 -0.9312 -vn -0.9312 0.0000 -0.3645 -vn -0.9312 0.0000 0.3645 -vn 0.2615 0.7979 -0.5431 -vn 0.5877 0.7979 -0.1341 -vn 0.4713 0.7979 0.3758 -vn -0.0000 0.7979 0.6028 -vn -0.4713 0.7979 0.3758 -vn -0.5877 0.7979 -0.1341 -vn -0.2615 0.7979 -0.5431 -vn -0.1285 0.9864 -0.1025 -vn 0.0929 0.8937 0.4389 -vn -0.4335 0.0407 -0.9002 -vn -0.2867 0.7507 -0.5952 -vn -0.4339 0.0095 -0.9009 -vn -0.4338 0.0209 -0.9008 -vn -0.0408 -0.9956 -0.0848 -vn -0.9741 0.0407 -0.2223 -vn -0.6441 0.7507 -0.1470 -vn -0.9749 0.0095 -0.2225 -vn -0.9747 0.0209 -0.2225 -vn -0.0918 -0.9956 -0.0209 -vn -0.7812 0.0407 0.6230 -vn -0.5165 0.7507 0.4119 -vn -0.7818 0.0095 0.6235 -vn -0.7817 0.0209 0.6234 -vn -0.0736 -0.9956 0.0587 -vn -0.0000 0.0407 0.9992 -vn 0.0000 0.7507 0.6607 -vn 0.0000 0.0095 1.0000 -vn -0.0000 0.0209 0.9998 -vn -0.0000 -0.9956 0.0941 -vn 0.7812 0.0407 0.6230 -vn 0.5165 0.7507 0.4119 -vn 0.7818 0.0095 0.6235 -vn 0.7817 0.0209 0.6234 -vn 0.0736 -0.9956 0.0587 -vn 0.9741 0.0407 -0.2223 -vn 0.6441 0.7507 -0.1470 -vn 0.9749 0.0095 -0.2225 -vn 0.9747 0.0209 -0.2225 -vn 0.0918 -0.9956 -0.0209 -vn 0.4335 0.0407 -0.9002 -vn 0.2867 0.7507 -0.5952 -vn 0.4339 0.0095 -0.9009 -vn 0.4338 0.0209 -0.9008 -vn 0.0408 -0.9956 -0.0848 -vn 0.3918 -0.4298 -0.8135 -vn 0.8803 -0.4298 -0.2009 -vn 0.7059 -0.4298 0.5630 -vn -0.0000 -0.4298 0.9029 -vn -0.7059 -0.4298 0.5630 -vn -0.8803 -0.4298 -0.2009 -vn -0.3918 -0.4298 -0.8135 -vn 0.0210 0.9998 -0.0048 -vn 0.0482 0.9981 -0.0385 -vn -0.0166 0.9914 -0.1301 -vn -0.0090 0.9904 -0.1379 -vn 0.2820 0.9576 0.0597 -vn -0.0000 0.9846 0.1749 -vn -0.0921 0.9772 -0.1913 -vn -0.1734 0.9794 0.1036 -s off -f 1/1/1 7/2/1 6/3/1 -f 2/4/2 8/5/2 7/2/2 -f 4/6/3 8/5/3 3/7/3 -f 5/8/4 9/9/4 4/6/4 -f 6/3/5 12/10/5 11/11/5 -f 35/12/6 25/13/6 26/14/6 -f 7/2/7 37/15/7 12/10/7 -f 10/16/8 13/17/8 9/9/8 -f 12/10/9 15/18/9 11/11/9 -f 35/12/10 17/19/10 33/20/10 -f 13/17/11 19/21/11 18/22/11 -f 16/23/12 20/24/12 15/18/12 -f 17/19/13 21/25/13 16/23/13 -f 17/19/14 23/26/14 22/27/14 -f 26/14/15 24/28/15 23/26/15 -f 1/1/16 2/4/16 7/2/16 -f 2/4/3 3/7/3 8/5/3 -f 4/6/17 9/9/17 8/5/17 -f 5/8/18 10/16/18 9/9/18 -f 6/3/19 7/2/19 12/10/19 -f 25/13/20 39/29/20 9/9/20 -f 38/30/21 12/10/21 37/15/21 -f 10/16/22 14/31/22 13/17/22 -f 12/10/23 16/23/23 15/18/23 -f 8/5/24 36/32/24 7/2/24 -f 38/30/25 17/19/25 16/23/25 -f 13/17/22 14/31/22 19/21/22 -f 16/23/26 21/25/26 20/24/26 -f 17/19/27 22/27/27 21/25/27 -f 17/19/28 26/14/28 23/26/28 -f 26/14/29 19/33/29 24/28/29 -f 26/34/30 18/35/30 19/36/30 -f 26/34/31 13/37/31 18/35/31 -f 25/38/32 9/39/32 13/37/32 -f 22/40/33 31/41/33 21/42/33 -f 6/43/34 28/44/34 27/45/34 -f 15/46/34 28/44/34 11/47/34 -f 21/42/35 30/48/35 20/49/35 -f 20/49/36 29/50/36 15/46/36 -f 22/40/33 23/51/33 32/52/33 -f 6/43/37 27/45/37 1/53/37 -f 46/54/38 34/55/38 47/56/38 -f 47/56/39 34/55/39 67/57/39 -f 67/57/40 34/55/40 72/58/40 -f 72/58/41 34/55/41 52/59/41 -f 52/59/42 34/55/42 57/60/42 -f 57/60/43 34/55/43 62/61/43 -f 62/61/44 34/55/44 46/54/44 -f 40/62/45 41/63/45 39/29/45 -f 39/29/46 8/5/46 9/9/46 -f 38/64/47 42/65/47 33/66/47 -f 65/67/48 42/65/48 66/68/48 -f 65/67/49 44/69/49 43/70/49 -f 81/71/50 45/72/50 77/73/50 -f 62/74/51 45/75/51 63/76/51 -f 37/77/52 66/78/52 38/79/52 -f 60/80/53 66/78/53 61/81/53 -f 60/80/54 64/82/54 65/83/54 -f 58/84/55 81/85/55 80/86/55 -f 57/87/56 63/76/56 58/88/56 -f 56/89/57 37/77/57 36/90/57 -f 55/91/58 61/81/58 56/89/58 -f 54/92/59 60/80/59 55/91/59 -f 79/93/60 58/84/60 80/86/60 -f 52/94/61 58/88/61 53/95/61 -f 76/96/62 36/90/62 41/97/62 -f 75/98/63 56/89/63 76/96/63 -f 75/98/64 54/92/64 55/91/64 -f 73/99/65 79/93/65 83/100/65 -f 73/101/66 52/94/66 53/95/66 -f 71/102/67 41/97/67 40/103/67 -f 70/104/68 76/96/68 71/102/68 -f 70/104/69 74/105/69 75/98/69 -f 68/106/70 83/100/70 82/107/70 -f 67/108/71 73/101/71 68/109/71 -f 51/110/72 40/103/72 35/111/72 -f 50/112/73 71/102/73 51/110/73 -f 49/113/74 70/104/74 50/112/74 -f 78/114/75 68/106/75 82/107/75 -f 47/115/76 68/109/76 48/116/76 -f 42/65/77 35/111/77 33/66/77 -f 43/70/78 51/110/78 42/65/78 -f 44/69/79 50/112/79 43/70/79 -f 45/72/80 78/114/80 77/73/80 -f 46/117/81 48/116/81 45/75/81 -f 44/69/82 78/114/82 49/113/82 -f 49/113/83 82/107/83 69/118/83 -f 82/107/84 74/105/84 69/118/84 -f 83/100/85 54/92/85 74/105/85 -f 79/93/86 59/119/86 54/92/86 -f 80/86/87 64/82/87 59/119/87 -f 64/120/88 77/73/88 44/69/88 -f 35/12/89 40/62/89 25/13/89 -f 7/2/90 36/32/90 37/15/90 -f 35/12/91 26/14/91 17/19/91 -f 25/13/92 40/62/92 39/29/92 -f 38/30/93 16/23/93 12/10/93 -f 8/5/94 41/63/94 36/32/94 -f 38/30/95 33/20/95 17/19/95 -f 26/34/31 25/38/31 13/37/31 -f 22/40/33 32/52/33 31/41/33 -f 6/43/34 11/47/34 28/44/34 -f 15/46/34 29/50/34 28/44/34 -f 21/42/35 31/41/35 30/48/35 -f 20/49/36 30/48/36 29/50/36 -f 39/29/96 41/63/96 8/5/96 -f 38/64/47 66/68/47 42/65/47 -f 65/67/48 43/70/48 42/65/48 -f 65/67/49 64/120/49 44/69/49 -f 81/71/50 63/121/50 45/72/50 -f 62/74/51 46/117/51 45/75/51 -f 37/77/52 61/81/52 66/78/52 -f 60/80/53 65/83/53 66/78/53 -f 60/80/54 59/119/54 64/82/54 -f 58/84/55 63/122/55 81/85/55 -f 57/87/56 62/74/56 63/76/56 -f 56/89/57 61/81/57 37/77/57 -f 55/91/58 60/80/58 61/81/58 -f 54/92/59 59/119/59 60/80/59 -f 79/93/60 53/123/60 58/84/60 -f 52/94/61 57/87/61 58/88/61 -f 76/96/62 56/89/62 36/90/62 -f 75/98/63 55/91/63 56/89/63 -f 75/98/64 74/105/64 54/92/64 -f 73/99/65 53/123/65 79/93/65 -f 73/101/66 72/124/66 52/94/66 -f 71/102/67 76/96/67 41/97/67 -f 70/104/68 75/98/68 76/96/68 -f 70/104/69 69/118/69 74/105/69 -f 68/106/70 73/99/70 83/100/70 -f 67/108/71 72/124/71 73/101/71 -f 51/110/72 71/102/72 40/103/72 -f 50/112/73 70/104/73 71/102/73 -f 49/113/74 69/118/74 70/104/74 -f 78/114/75 48/125/75 68/106/75 -f 47/115/76 67/108/76 68/109/76 -f 42/65/77 51/110/77 35/111/77 -f 43/70/78 50/112/78 51/110/78 -f 44/69/79 49/113/79 50/112/79 -f 45/72/80 48/125/80 78/114/80 -f 46/117/81 47/115/81 48/116/81 -f 44/69/82 77/73/82 78/114/82 -f 49/113/83 78/114/83 82/107/83 -f 82/107/84 83/100/84 74/105/84 -f 83/100/85 79/93/85 54/92/85 -f 79/93/86 80/86/86 59/119/86 -f 80/86/87 81/85/87 64/82/87 -f 64/120/88 81/71/88 77/73/88 diff --git a/examples/shaders/resources/model/lowpoly-tower.png b/examples/shaders/resources/model/lowpoly-tower.png deleted file mode 100644 index 7c9239e2..00000000 Binary files a/examples/shaders/resources/model/lowpoly-tower.png and /dev/null differ diff --git a/examples/shaders/resources/shaders/glsl100/standard.fs b/examples/shaders/resources/shaders/glsl100/standard.fs deleted file mode 100644 index fe604e2a..00000000 --- a/examples/shaders/resources/shaders/glsl100/standard.fs +++ /dev/null @@ -1,152 +0,0 @@ -#version 100 - -precision mediump float; - -varying vec3 fragPosition; -varying vec2 fragTexCoord; -varying vec4 fragColor; -varying vec3 fragNormal; - -uniform sampler2D texture0; -uniform sampler2D texture1; -uniform sampler2D texture2; - -uniform vec4 colAmbient; -uniform vec4 colDiffuse; -uniform vec4 colSpecular; -uniform float glossiness; - -uniform int useNormal; -uniform int useSpecular; - -uniform mat4 modelMatrix; -uniform vec3 viewDir; - -struct Light { - int enabled; - int type; - vec3 position; - vec3 direction; - vec4 diffuse; - float intensity; - float radius; - float coneAngle; -}; - -const int maxLights = 8; -uniform Light lights[maxLights]; - -vec3 ComputeLightPoint(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1.0)); - vec3 surfaceToLight = l.position - surfacePos; - - // Diffuse shading - float brightness = clamp(float(dot(n, surfaceToLight)/(length(surfaceToLight)*length(n))), 0.0, 1.0); - float diff = 1.0/dot(surfaceToLight/l.radius, surfaceToLight/l.radius)*brightness*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(-l.direction + v); - spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; - } - - return (diff*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 ComputeLightDirectional(Light l, vec3 n, vec3 v, float s) -{ - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(float(dot(n, lightDir)), 0.0, 1.0)*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; - } - - // Combine results - return (diff*l.intensity*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 ComputeLightSpot(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 lightToSurface = normalize(surfacePos - l.position); - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(float(dot(n, lightDir)), 0.0, 1.0)*l.intensity; - - // Spot attenuation - float attenuation = clamp(float(dot(n, lightToSurface)), 0.0, 1.0); - attenuation = dot(lightToSurface, -lightDir); - - float lightToSurfaceAngle = degrees(acos(attenuation)); - if (lightToSurfaceAngle > l.coneAngle) attenuation = 0.0; - - float falloff = (l.coneAngle - lightToSurfaceAngle)/l.coneAngle; - - // Combine diffuse and attenuation - float diffAttenuation = diff*attenuation; - - // Specular shading - float spec = 0.0; - if (diffAttenuation > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; - } - - return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); -} - -void main() -{ - // Calculate fragment normal in screen space - // NOTE: important to multiply model matrix by fragment normal to apply model transformation (rotation and scale) - mat3 normalMatrix = mat3(modelMatrix); - vec3 normal = normalize(normalMatrix*fragNormal); - - // Normalize normal and view direction vectors - vec3 n = normalize(normal); - vec3 v = normalize(viewDir); - - // Calculate diffuse texture color fetching - vec4 texelColor = texture2D(texture0, fragTexCoord); - vec3 lighting = colAmbient.rgb; - - // Calculate normal texture color fetching or set to maximum normal value by default - if (useNormal == 1) - { - n *= texture2D(texture1, fragTexCoord).rgb; - n = normalize(n); - } - - // Calculate specular texture color fetching or set to maximum specular value by default - float spec = 1.0; - if (useSpecular == 1) spec = texture2D(texture2, fragTexCoord).r; - - for (int i = 0; i < maxLights; i++) - { - // Check if light is enabled - if (lights[i].enabled == 1) - { - // Calculate lighting based on light type - if(lights[i].type == 0) lighting += ComputeLightPoint(lights[i], n, v, spec); - else if(lights[i].type == 1) lighting += ComputeLightDirectional(lights[i], n, v, spec); - else if(lights[i].type == 2) lighting += ComputeLightSpot(lights[i], n, v, spec); - - // NOTE: It seems that too many ComputeLight*() operations inside for loop breaks the shader on RPI - } - } - - // Calculate final fragment color - gl_FragColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); -} diff --git a/examples/shaders/resources/shaders/glsl100/standard.vs b/examples/shaders/resources/shaders/glsl100/standard.vs deleted file mode 100644 index 49c5a3eb..00000000 --- a/examples/shaders/resources/shaders/glsl100/standard.vs +++ /dev/null @@ -1,23 +0,0 @@ -#version 100 - -attribute vec3 vertexPosition; -attribute vec3 vertexNormal; -attribute vec2 vertexTexCoord; -attribute vec4 vertexColor; - -varying vec3 fragPosition; -varying vec2 fragTexCoord; -varying vec4 fragColor; -varying vec3 fragNormal; - -uniform mat4 mvpMatrix; - -void main() -{ - fragPosition = vertexPosition; - fragTexCoord = vertexTexCoord; - fragColor = vertexColor; - fragNormal = vertexNormal; - - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/examples/shaders/resources/shaders/glsl330/standard.fs b/examples/shaders/resources/shaders/glsl330/standard.fs deleted file mode 100644 index 0d461484..00000000 --- a/examples/shaders/resources/shaders/glsl330/standard.fs +++ /dev/null @@ -1,150 +0,0 @@ -#version 330 - -in vec3 fragPosition; -in vec2 fragTexCoord; -in vec4 fragColor; -in vec3 fragNormal; - -out vec4 finalColor; - -uniform sampler2D texture0; -uniform sampler2D texture1; -uniform sampler2D texture2; - -uniform vec4 colAmbient; -uniform vec4 colDiffuse; -uniform vec4 colSpecular; -uniform float glossiness; - -uniform int useNormal; -uniform int useSpecular; - -uniform mat4 modelMatrix; -uniform vec3 viewDir; - -struct Light { - int enabled; - int type; - vec3 position; - vec3 direction; - vec4 diffuse; - float intensity; - float radius; - float coneAngle; -}; - -const int maxLights = 8; -uniform Light lights[maxLights]; - -vec3 ComputeLightPoint(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 surfaceToLight = l.position - surfacePos; - - // Diffuse shading - float brightness = clamp(float(dot(n, surfaceToLight)/(length(surfaceToLight)*length(n))), 0.0, 1.0); - float diff = 1.0/dot(surfaceToLight/l.radius, surfaceToLight/l.radius)*brightness*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(-l.direction + v); - spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; - } - - return (diff*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 ComputeLightDirectional(Light l, vec3 n, vec3 v, float s) -{ - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(float(dot(n, lightDir)), 0.0, 1.0)*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; - } - - // Combine results - return (diff*l.intensity*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 ComputeLightSpot(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 lightToSurface = normalize(surfacePos - l.position); - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(float(dot(n, lightDir)), 0.0, 1.0)*l.intensity; - - // Spot attenuation - float attenuation = clamp(float(dot(n, lightToSurface)), 0.0, 1.0); - attenuation = dot(lightToSurface, -lightDir); - - float lightToSurfaceAngle = degrees(acos(attenuation)); - if (lightToSurfaceAngle > l.coneAngle) attenuation = 0.0; - - float falloff = (l.coneAngle - lightToSurfaceAngle)/l.coneAngle; - - // Combine diffuse and attenuation - float diffAttenuation = diff*attenuation; - - // Specular shading - float spec = 0.0; - if (diffAttenuation > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(abs(dot(n, h)), 3.0 + glossiness)*s; - } - - return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); -} - -void main() -{ - // Calculate fragment normal in screen space - // NOTE: important to multiply model matrix by fragment normal to apply model transformation (rotation and scale) - mat3 normalMatrix = mat3(modelMatrix); - vec3 normal = normalize(normalMatrix*fragNormal); - - // Normalize normal and view direction vectors - vec3 n = normalize(normal); - vec3 v = normalize(viewDir); - - // Calculate diffuse texture color fetching - vec4 texelColor = texture(texture0, fragTexCoord); - vec3 lighting = colAmbient.rgb; - - // Calculate normal texture color fetching or set to maximum normal value by default - if (useNormal == 1) - { - n *= texture(texture1, fragTexCoord).rgb; - n = normalize(n); - } - - // Calculate specular texture color fetching or set to maximum specular value by default - float spec = 1.0; - if (useSpecular == 1) spec = texture(texture2, fragTexCoord).r; - - for (int i = 0; i < maxLights; i++) - { - // Check if light is enabled - if (lights[i].enabled == 1) - { - // Calculate lighting based on light type - if (lights[i].type == 0) lighting += ComputeLightPoint(lights[i], n, v, spec); - else if (lights[i].type == 1) lighting += ComputeLightDirectional(lights[i], n, v, spec); - else if (lights[i].type == 2) lighting += ComputeLightSpot(lights[i], n, v, spec); - } - } - - // Calculate final fragment color - finalColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); -} diff --git a/examples/shaders/resources/shaders/glsl330/standard.vs b/examples/shaders/resources/shaders/glsl330/standard.vs deleted file mode 100644 index fc0a5ff4..00000000 --- a/examples/shaders/resources/shaders/glsl330/standard.vs +++ /dev/null @@ -1,23 +0,0 @@ -#version 330 - -in vec3 vertexPosition; -in vec3 vertexNormal; -in vec2 vertexTexCoord; -in vec4 vertexColor; - -out vec3 fragPosition; -out vec2 fragTexCoord; -out vec4 fragColor; -out vec3 fragNormal; - -uniform mat4 mvpMatrix; - -void main() -{ - fragPosition = vertexPosition; - fragTexCoord = vertexTexCoord; - fragColor = vertexColor; - fragNormal = vertexNormal; - - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/examples/shaders/shaders_standard_lighting.c b/examples/shaders/shaders_standard_lighting.c deleted file mode 100644 index 16cd7ff6..00000000 --- a/examples/shaders/shaders_standard_lighting.c +++ /dev/null @@ -1,482 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Standard lighting (materials and lights) -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2016-2017 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#include // Required for: NULL -#include // Required for: strcpy() -#include // Required for: vector math - -//---------------------------------------------------------------------------------- -// Defines and Macros -//---------------------------------------------------------------------------------- -#define MAX_LIGHTS 8 // Max lights supported by standard shader - -//---------------------------------------------------------------------------------- -// Types and Structures Definition -//---------------------------------------------------------------------------------- - -// Light type -typedef struct LightData { - unsigned int id; // Light unique id - bool enabled; // Light enabled - int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT - - Vector3 position; // Light position - Vector3 target; // Light direction: LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target) - float radius; // Light attenuation radius light intensity reduced with distance (world distance) - - Color diffuse; // Light diffuse color - float intensity; // Light intensity level - - float coneAngle; // Light cone max angle: LIGHT_SPOT -} LightData, *Light; - -// Light types -typedef enum { LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT } LightType; - -//---------------------------------------------------------------------------------- -// Global Variables Definition -//---------------------------------------------------------------------------------- -static Light lights[MAX_LIGHTS]; // Lights pool -static int lightsCount = 0; // Enabled lights counter -static int lightsLocs[MAX_LIGHTS][8]; // Lights location points in shader: 8 possible points per light: - // enabled, type, position, target, radius, diffuse, intensity, coneAngle - -//---------------------------------------------------------------------------------- -// Module Functions Declaration -//---------------------------------------------------------------------------------- -static Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool -static void DestroyLight(Light light); // Destroy a light and take it out of the list -static void DrawLight(Light light); // Draw light in 3D world - -static void GetShaderLightsLocations(Shader shader); // Get shader locations for lights (up to MAX_LIGHTS) -static void SetShaderLightsValues(Shader shader); // Set shader uniform values for lights - -// Vector3 math functions -static float VectorLength(const Vector3 v); // Calculate vector lenght -static void VectorNormalize(Vector3 *v); // Normalize provided vector -static Vector3 VectorSubtract(Vector3 v1, Vector3 v2); // Substract two vectors - - -//https://www.gamedev.net/topic/655969-speed-gluniform-vs-uniform-buffer-objects/ -//https://www.reddit.com/r/opengl/comments/4ri20g/is_gluniform_more_expensive_than_glprogramuniform/ -//http://cg.alexandra.dk/?p=3778 - AZDO -//https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html - -//------------------------------------------------------------------------------------ -// Program main entry point -//------------------------------------------------------------------------------------ -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader"); - - // Define the camera to look into our 3d world - Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; - Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - - Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model - - Material material;// = LoadStandardMaterial(); - - material.shader = LoadShader("resources/shaders/glsl330/standard.vs", "resources/shaders/glsl330/standard.fs"); - - // Try to get lights location points (if available) - GetShaderLightsLocations(material.shader); - - material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture - material.texNormal = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture - material.texSpecular = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture - material.colDiffuse = WHITE; - material.colAmbient = (Color){0, 0, 10, 255}; - material.colSpecular = WHITE; - material.glossiness = 50.0f; - - dwarf.material = material; // Apply material to model - - Light spotLight = CreateLight(LIGHT_SPOT, (Vector3){3.0f, 5.0f, 2.0f}, (Color){255, 255, 255, 255}); - spotLight->target = (Vector3){0.0f, 0.0f, 0.0f}; - spotLight->intensity = 2.0f; - spotLight->diffuse = (Color){255, 100, 100, 255}; - spotLight->coneAngle = 60.0f; - - Light dirLight = CreateLight(LIGHT_DIRECTIONAL, (Vector3){0.0f, -3.0f, -3.0f}, (Color){255, 255, 255, 255}); - dirLight->target = (Vector3){1.0f, -2.0f, -2.0f}; - dirLight->intensity = 2.0f; - dirLight->diffuse = (Color){100, 255, 100, 255}; - - Light pointLight = CreateLight(LIGHT_POINT, (Vector3){0.0f, 4.0f, 5.0f}, (Color){255, 255, 255, 255}); - pointLight->intensity = 2.0f; - pointLight->diffuse = (Color){100, 100, 255, 255}; - pointLight->radius = 3.0f; - - // Set shader lights values for enabled lights - // NOTE: If values are not changed in real time, they can be set at initialization!!! - SetShaderLightsValues(material.shader); - - //SetShaderActive(0); - - // Setup orbital camera - SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - Begin3dMode(camera); - - DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture - - DrawLight(spotLight); // Draw spot light - DrawLight(dirLight); // Draw directional light - DrawLight(pointLight); // Draw point light - - DrawGrid(10, 1.0f); // Draw a grid - - End3dMode(); - - DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadMaterial(material); // Unload material and assigned textures - UnloadModel(dwarf); // Unload model - - // Destroy all created lights - DestroyLight(pointLight); - DestroyLight(dirLight); - DestroyLight(spotLight); - - // Unload lights - if (lightsCount > 0) - { - for (int i = 0; i < lightsCount; i++) free(lights[i]); - lightsCount = 0; - } - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} - -//-------------------------------------------------------------------------------------------- -// Module Functions Definitions -//-------------------------------------------------------------------------------------------- - -// Create a new light, initialize it and add to pool -Light CreateLight(int type, Vector3 position, Color diffuse) -{ - Light light = NULL; - - if (lightsCount < MAX_LIGHTS) - { - // Allocate dynamic memory - light = (Light)malloc(sizeof(LightData)); - - // Initialize light values with generic values - light->id = lightsCount; - light->type = type; - light->enabled = true; - - light->position = position; - light->target = (Vector3){ 0.0f, 0.0f, 0.0f }; - light->intensity = 1.0f; - light->diffuse = diffuse; - - // Add new light to the array - lights[lightsCount] = light; - - // Increase enabled lights count - lightsCount++; - } - else - { - // NOTE: Returning latest created light to avoid crashes - light = lights[lightsCount]; - } - - return light; -} - -// Destroy a light and take it out of the list -void DestroyLight(Light light) -{ - if (light != NULL) - { - int lightId = light->id; - - // Free dynamic memory allocation - free(lights[lightId]); - - // Remove *obj from the pointers array - for (int i = lightId; i < lightsCount; i++) - { - // Resort all the following pointers of the array - if ((i + 1) < lightsCount) - { - lights[i] = lights[i + 1]; - lights[i]->id = lights[i + 1]->id; - } - } - - // Decrease enabled physic objects count - lightsCount--; - } -} - -// Draw light in 3D world -void DrawLight(Light light) -{ - switch (light->type) - { - case LIGHT_POINT: - { - DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY)); - - DrawCircle3D(light->position, light->radius, (Vector3){ 0, 0, 0 }, 0.0f, (light->enabled ? light->diffuse : GRAY)); - DrawCircle3D(light->position, light->radius, (Vector3){ 1, 0, 0 }, 90.0f, (light->enabled ? light->diffuse : GRAY)); - DrawCircle3D(light->position, light->radius, (Vector3){ 0, 1, 0 },90.0f, (light->enabled ? light->diffuse : GRAY)); - } break; - case LIGHT_DIRECTIONAL: - { - DrawLine3D(light->position, light->target, (light->enabled ? light->diffuse : GRAY)); - - DrawSphereWires(light->position, 0.3f*light->intensity, 8, 8, (light->enabled ? light->diffuse : GRAY)); - DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY)); - } break; - case LIGHT_SPOT: - { - DrawLine3D(light->position, light->target, (light->enabled ? light->diffuse : GRAY)); - - Vector3 dir = VectorSubtract(light->target, light->position); - VectorNormalize(&dir); - - DrawCircle3D(light->position, 0.5f, dir, 0.0f, (light->enabled ? light->diffuse : GRAY)); - - //DrawCylinderWires(light->position, 0.0f, 0.3f*light->coneAngle/50, 0.6f, 5, (light->enabled ? light->diffuse : GRAY)); - DrawCubeWires(light->target, 0.3f, 0.3f, 0.3f, (light->enabled ? light->diffuse : GRAY)); - } break; - default: break; - } -} - -// Get shader locations for lights (up to MAX_LIGHTS) -static void GetShaderLightsLocations(Shader shader) -{ - char locName[32] = "lights[x].\0"; - char locNameUpdated[64]; - - for (int i = 0; i < MAX_LIGHTS; i++) - { - locName[7] = '0' + i; - - strcpy(locNameUpdated, locName); - strcat(locNameUpdated, "enabled\0"); - lightsLocs[i][0] = GetShaderLocation(shader, locNameUpdated); - - locNameUpdated[0] = '\0'; - strcpy(locNameUpdated, locName); - strcat(locNameUpdated, "type\0"); - lightsLocs[i][1] = GetShaderLocation(shader, locNameUpdated); - - locNameUpdated[0] = '\0'; - strcpy(locNameUpdated, locName); - strcat(locNameUpdated, "position\0"); - lightsLocs[i][2] = GetShaderLocation(shader, locNameUpdated); - - locNameUpdated[0] = '\0'; - strcpy(locNameUpdated, locName); - strcat(locNameUpdated, "direction\0"); - lightsLocs[i][3] = GetShaderLocation(shader, locNameUpdated); - - locNameUpdated[0] = '\0'; - strcpy(locNameUpdated, locName); - strcat(locNameUpdated, "radius\0"); - lightsLocs[i][4] = GetShaderLocation(shader, locNameUpdated); - - locNameUpdated[0] = '\0'; - strcpy(locNameUpdated, locName); - strcat(locNameUpdated, "diffuse\0"); - lightsLocs[i][5] = GetShaderLocation(shader, locNameUpdated); - - locNameUpdated[0] = '\0'; - strcpy(locNameUpdated, locName); - strcat(locNameUpdated, "intensity\0"); - lightsLocs[i][6] = GetShaderLocation(shader, locNameUpdated); - - locNameUpdated[0] = '\0'; - strcpy(locNameUpdated, locName); - strcat(locNameUpdated, "coneAngle\0"); - lightsLocs[i][7] = GetShaderLocation(shader, locNameUpdated); - } -} - -// Set shader uniform values for lights -// NOTE: It would be far easier with shader UBOs but are not supported on OpenGL ES 2.0 -// TODO: Replace glUniform1i(), glUniform1f(), glUniform3f(), glUniform4f(): -//SetShaderValue(Shader shader, int uniformLoc, float *value, int size) -//SetShaderValuei(Shader shader, int uniformLoc, int *value, int size) -static void SetShaderLightsValues(Shader shader) -{ - int tempInt[8] = { 0 }; - float tempFloat[8] = { 0.0f }; - - for (int i = 0; i < MAX_LIGHTS; i++) - { - if (i < lightsCount) - { - tempInt[0] = lights[i]->enabled; - SetShaderValuei(shader, lightsLocs[i][0], tempInt, 1); //glUniform1i(lightsLocs[i][0], lights[i]->enabled); - - tempInt[0] = lights[i]->type; - SetShaderValuei(shader, lightsLocs[i][1], tempInt, 1); //glUniform1i(lightsLocs[i][1], lights[i]->type); - - tempFloat[0] = (float)lights[i]->diffuse.r/255.0f; - tempFloat[1] = (float)lights[i]->diffuse.g/255.0f; - tempFloat[2] = (float)lights[i]->diffuse.b/255.0f; - tempFloat[3] = (float)lights[i]->diffuse.a/255.0f; - SetShaderValue(shader, lightsLocs[i][5], tempFloat, 4); - //glUniform4f(lightsLocs[i][5], (float)lights[i]->diffuse.r/255, (float)lights[i]->diffuse.g/255, (float)lights[i]->diffuse.b/255, (float)lights[i]->diffuse.a/255); - - tempFloat[0] = lights[i]->intensity; - SetShaderValue(shader, lightsLocs[i][6], tempFloat, 1); - - switch (lights[i]->type) - { - case LIGHT_POINT: - { - tempFloat[0] = lights[i]->position.x; - tempFloat[1] = lights[i]->position.y; - tempFloat[2] = lights[i]->position.z; - SetShaderValue(shader, lightsLocs[i][2], tempFloat, 3); - - tempFloat[0] = lights[i]->radius; - SetShaderValue(shader, lightsLocs[i][4], tempFloat, 1); - - //glUniform3f(lightsLocs[i][2], lights[i]->position.x, lights[i]->position.y, lights[i]->position.z); - //glUniform1f(lightsLocs[i][4], lights[i]->radius); - } break; - case LIGHT_DIRECTIONAL: - { - Vector3 direction = VectorSubtract(lights[i]->target, lights[i]->position); - VectorNormalize(&direction); - - tempFloat[0] = direction.x; - tempFloat[1] = direction.y; - tempFloat[2] = direction.z; - SetShaderValue(shader, lightsLocs[i][3], tempFloat, 3); - - //glUniform3f(lightsLocs[i][3], direction.x, direction.y, direction.z); - } break; - case LIGHT_SPOT: - { - tempFloat[0] = lights[i]->position.x; - tempFloat[1] = lights[i]->position.y; - tempFloat[2] = lights[i]->position.z; - SetShaderValue(shader, lightsLocs[i][2], tempFloat, 3); - - //glUniform3f(lightsLocs[i][2], lights[i]->position.x, lights[i]->position.y, lights[i]->position.z); - - Vector3 direction = VectorSubtract(lights[i]->target, lights[i]->position); - VectorNormalize(&direction); - - tempFloat[0] = direction.x; - tempFloat[1] = direction.y; - tempFloat[2] = direction.z; - SetShaderValue(shader, lightsLocs[i][3], tempFloat, 3); - //glUniform3f(lightsLocs[i][3], direction.x, direction.y, direction.z); - - tempFloat[0] = lights[i]->coneAngle; - SetShaderValue(shader, lightsLocs[i][7], tempFloat, 1); - //glUniform1f(lightsLocs[i][7], lights[i]->coneAngle); - } break; - default: break; - } - } - else - { - tempInt[0] = 0; - SetShaderValuei(shader, lightsLocs[i][0], tempInt, 1); //glUniform1i(lightsLocs[i][0], 0); // Light disabled - } - } -} - -// Calculate vector lenght -float VectorLength(const Vector3 v) -{ - float length; - - length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); - - return length; -} - -// Normalize provided vector -void VectorNormalize(Vector3 *v) -{ - float length, ilength; - - length = VectorLength(*v); - - if (length == 0.0f) length = 1.0f; - - ilength = 1.0f/length; - - v->x *= ilength; - v->y *= ilength; - v->z *= ilength; -} - -// Substract two vectors -Vector3 VectorSubtract(Vector3 v1, Vector3 v2) -{ - Vector3 result; - - result.x = v1.x - v2.x; - result.y = v1.y - v2.y; - result.z = v1.z - v2.z; - - return result; -} diff --git a/examples/shaders/shaders_standard_lighting.png b/examples/shaders/shaders_standard_lighting.png deleted file mode 100644 index 65efe47f..00000000 Binary files a/examples/shaders/shaders_standard_lighting.png and /dev/null differ diff --git a/examples/text/resources/KAISG.ttf b/examples/text/resources/KAISG.ttf new file mode 100644 index 00000000..04478b25 Binary files /dev/null and b/examples/text/resources/KAISG.ttf differ diff --git a/examples/text/resources/bmfont.fnt b/examples/text/resources/bmfont.fnt new file mode 100644 index 00000000..372c2c88 --- /dev/null +++ b/examples/text/resources/bmfont.fnt @@ -0,0 +1,99 @@ +info face="Arial Black" size=-32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 outline=0 +common lineHeight=45 base=35 scaleW=512 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 +page id=0 file="bmfont.png" +chars count=95 +char id=32 x=423 y=141 width=3 height=45 xoffset=-1 yoffset=0 xadvance=11 page=0 chnl=15 +char id=33 x=323 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 +char id=34 x=123 y=141 width=16 height=45 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15 +char id=35 x=221 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=36 x=244 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=37 x=70 y=0 width=30 height=45 xoffset=1 yoffset=0 xadvance=32 page=0 chnl=15 +char id=38 x=390 y=0 width=25 height=45 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=15 +char id=39 x=378 y=141 width=8 height=45 xoffset=1 yoffset=0 xadvance=9 page=0 chnl=15 +char id=40 x=222 y=141 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15 +char id=41 x=499 y=94 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15 +char id=42 x=497 y=47 width=13 height=45 xoffset=2 yoffset=0 xadvance=18 page=0 chnl=15 +char id=43 x=394 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=44 x=367 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 +char id=45 x=261 y=141 width=11 height=45 xoffset=0 yoffset=0 xadvance=11 page=0 chnl=15 +char id=46 x=356 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 +char id=47 x=248 y=141 width=11 height=45 xoffset=-1 yoffset=0 xadvance=9 page=0 chnl=15 +char id=48 x=382 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=49 x=496 y=0 width=14 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15 +char id=50 x=134 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=51 x=359 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=52 x=313 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=53 x=336 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=54 x=178 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=55 x=478 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=56 x=290 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=57 x=90 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=58 x=345 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 +char id=59 x=334 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 +char id=60 x=0 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=61 x=21 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=62 x=310 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=63 x=352 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=20 page=0 chnl=15 +char id=64 x=279 y=0 width=26 height=45 xoffset=-1 yoffset=0 xadvance=24 page=0 chnl=15 +char id=65 x=193 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15 +char id=66 x=150 y=47 width=22 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15 +char id=67 x=444 y=0 width=24 height=45 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=15 +char id=68 x=174 y=47 width=22 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15 +char id=69 x=156 y=94 width=20 height=45 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=15 +char id=70 x=63 y=141 width=18 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15 +char id=71 x=417 y=0 width=25 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15 +char id=72 x=125 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15 +char id=73 x=388 y=141 width=8 height=45 xoffset=2 yoffset=0 xadvance=12 page=0 chnl=15 +char id=74 x=200 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=75 x=251 y=0 width=26 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15 +char id=76 x=373 y=94 width=19 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15 +char id=77 x=134 y=0 width=28 height=45 xoffset=1 yoffset=0 xadvance=30 page=0 chnl=15 +char id=78 x=100 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15 +char id=79 x=363 y=0 width=25 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15 +char id=80 x=112 y=94 width=20 height=45 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=15 +char id=81 x=335 y=0 width=26 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15 +char id=82 x=470 y=0 width=24 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15 +char id=83 x=75 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15 +char id=84 x=50 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15 +char id=85 x=25 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15 +char id=86 x=307 y=0 width=26 height=45 xoffset=0 yoffset=0 xadvance=25 page=0 chnl=15 +char id=87 x=0 y=0 width=34 height=45 xoffset=-1 yoffset=0 xadvance=32 page=0 chnl=15 +char id=88 x=222 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15 +char id=89 x=164 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15 +char id=90 x=0 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15 +char id=91 x=274 y=141 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15 +char id=92 x=300 y=141 width=10 height=45 xoffset=-1 yoffset=0 xadvance=9 page=0 chnl=15 +char id=93 x=287 y=141 width=11 height=45 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15 +char id=94 x=457 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=95 x=103 y=141 width=18 height=45 xoffset=-1 yoffset=0 xadvance=16 page=0 chnl=15 +char id=96 x=312 y=141 width=9 height=45 xoffset=0 yoffset=0 xadvance=11 page=0 chnl=15 +char id=97 x=474 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=98 x=68 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=99 x=267 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=100 x=46 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=101 x=198 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=102 x=141 y=141 width=15 height=45 xoffset=-1 yoffset=0 xadvance=12 page=0 chnl=15 +char id=103 x=222 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=104 x=415 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=105 x=398 y=141 width=7 height=45 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=15 +char id=106 x=235 y=141 width=11 height=45 xoffset=-2 yoffset=0 xadvance=11 page=0 chnl=15 +char id=107 x=405 y=47 width=21 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=108 x=407 y=141 width=7 height=45 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=15 +char id=109 x=102 y=0 width=30 height=45 xoffset=1 yoffset=0 xadvance=32 page=0 chnl=15 +char id=110 x=331 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=111 x=428 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=112 x=266 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=113 x=288 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=114 x=158 y=141 width=15 height=45 xoffset=1 yoffset=0 xadvance=14 page=0 chnl=15 +char id=115 x=244 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15 +char id=116 x=175 y=141 width=14 height=45 xoffset=0 yoffset=0 xadvance=14 page=0 chnl=15 +char id=117 x=436 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 +char id=118 x=451 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15 +char id=119 x=36 y=0 width=32 height=45 xoffset=-1 yoffset=0 xadvance=30 page=0 chnl=15 +char id=120 x=0 y=94 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 +char id=121 x=23 y=94 width=21 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15 +char id=122 x=83 y=141 width=18 height=45 xoffset=0 yoffset=0 xadvance=18 page=0 chnl=15 +char id=123 x=191 y=141 width=14 height=45 xoffset=-1 yoffset=0 xadvance=12 page=0 chnl=15 +char id=124 x=416 y=141 width=5 height=45 xoffset=2 yoffset=0 xadvance=9 page=0 chnl=15 +char id=125 x=207 y=141 width=13 height=45 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15 +char id=126 x=42 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 diff --git a/examples/text/resources/bmfont.png b/examples/text/resources/bmfont.png new file mode 100644 index 00000000..9d621594 Binary files /dev/null and b/examples/text/resources/bmfont.png differ diff --git a/examples/text/resources/custom_alagard.png b/examples/text/resources/custom_alagard.png new file mode 100644 index 00000000..c3eb63b7 Binary files /dev/null and b/examples/text/resources/custom_alagard.png differ diff --git a/examples/text/resources/custom_jupiter_crash.png b/examples/text/resources/custom_jupiter_crash.png new file mode 100644 index 00000000..451b591f Binary files /dev/null and b/examples/text/resources/custom_jupiter_crash.png differ diff --git a/examples/text/resources/custom_mecha.png b/examples/text/resources/custom_mecha.png new file mode 100644 index 00000000..59caab2c Binary files /dev/null and b/examples/text/resources/custom_mecha.png differ diff --git a/examples/text/resources/fonts/KAISG.ttf b/examples/text/resources/fonts/KAISG.ttf deleted file mode 100644 index 04478b25..00000000 Binary files a/examples/text/resources/fonts/KAISG.ttf and /dev/null differ diff --git a/examples/text/resources/fonts/bmfont.fnt b/examples/text/resources/fonts/bmfont.fnt deleted file mode 100644 index 372c2c88..00000000 --- a/examples/text/resources/fonts/bmfont.fnt +++ /dev/null @@ -1,99 +0,0 @@ -info face="Arial Black" size=-32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 outline=0 -common lineHeight=45 base=35 scaleW=512 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 -page id=0 file="bmfont.png" -chars count=95 -char id=32 x=423 y=141 width=3 height=45 xoffset=-1 yoffset=0 xadvance=11 page=0 chnl=15 -char id=33 x=323 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 -char id=34 x=123 y=141 width=16 height=45 xoffset=0 yoffset=0 xadvance=16 page=0 chnl=15 -char id=35 x=221 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=36 x=244 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=37 x=70 y=0 width=30 height=45 xoffset=1 yoffset=0 xadvance=32 page=0 chnl=15 -char id=38 x=390 y=0 width=25 height=45 xoffset=2 yoffset=0 xadvance=28 page=0 chnl=15 -char id=39 x=378 y=141 width=8 height=45 xoffset=1 yoffset=0 xadvance=9 page=0 chnl=15 -char id=40 x=222 y=141 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15 -char id=41 x=499 y=94 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15 -char id=42 x=497 y=47 width=13 height=45 xoffset=2 yoffset=0 xadvance=18 page=0 chnl=15 -char id=43 x=394 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=44 x=367 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 -char id=45 x=261 y=141 width=11 height=45 xoffset=0 yoffset=0 xadvance=11 page=0 chnl=15 -char id=46 x=356 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 -char id=47 x=248 y=141 width=11 height=45 xoffset=-1 yoffset=0 xadvance=9 page=0 chnl=15 -char id=48 x=382 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=49 x=496 y=0 width=14 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15 -char id=50 x=134 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=51 x=359 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=52 x=313 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=53 x=336 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=54 x=178 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=55 x=478 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=56 x=290 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=57 x=90 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=58 x=345 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 -char id=59 x=334 y=141 width=9 height=45 xoffset=1 yoffset=0 xadvance=11 page=0 chnl=15 -char id=60 x=0 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=61 x=21 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=62 x=310 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=63 x=352 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=20 page=0 chnl=15 -char id=64 x=279 y=0 width=26 height=45 xoffset=-1 yoffset=0 xadvance=24 page=0 chnl=15 -char id=65 x=193 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15 -char id=66 x=150 y=47 width=22 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15 -char id=67 x=444 y=0 width=24 height=45 xoffset=1 yoffset=0 xadvance=25 page=0 chnl=15 -char id=68 x=174 y=47 width=22 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15 -char id=69 x=156 y=94 width=20 height=45 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=15 -char id=70 x=63 y=141 width=18 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15 -char id=71 x=417 y=0 width=25 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15 -char id=72 x=125 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15 -char id=73 x=388 y=141 width=8 height=45 xoffset=2 yoffset=0 xadvance=12 page=0 chnl=15 -char id=74 x=200 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=75 x=251 y=0 width=26 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15 -char id=76 x=373 y=94 width=19 height=45 xoffset=2 yoffset=0 xadvance=21 page=0 chnl=15 -char id=77 x=134 y=0 width=28 height=45 xoffset=1 yoffset=0 xadvance=30 page=0 chnl=15 -char id=78 x=100 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15 -char id=79 x=363 y=0 width=25 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15 -char id=80 x=112 y=94 width=20 height=45 xoffset=2 yoffset=0 xadvance=23 page=0 chnl=15 -char id=81 x=335 y=0 width=26 height=45 xoffset=1 yoffset=0 xadvance=27 page=0 chnl=15 -char id=82 x=470 y=0 width=24 height=45 xoffset=2 yoffset=0 xadvance=25 page=0 chnl=15 -char id=83 x=75 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15 -char id=84 x=50 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15 -char id=85 x=25 y=47 width=23 height=45 xoffset=2 yoffset=0 xadvance=27 page=0 chnl=15 -char id=86 x=307 y=0 width=26 height=45 xoffset=0 yoffset=0 xadvance=25 page=0 chnl=15 -char id=87 x=0 y=0 width=34 height=45 xoffset=-1 yoffset=0 xadvance=32 page=0 chnl=15 -char id=88 x=222 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15 -char id=89 x=164 y=0 width=27 height=45 xoffset=-1 yoffset=0 xadvance=25 page=0 chnl=15 -char id=90 x=0 y=47 width=23 height=45 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=15 -char id=91 x=274 y=141 width=11 height=45 xoffset=1 yoffset=0 xadvance=12 page=0 chnl=15 -char id=92 x=300 y=141 width=10 height=45 xoffset=-1 yoffset=0 xadvance=9 page=0 chnl=15 -char id=93 x=287 y=141 width=11 height=45 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15 -char id=94 x=457 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=95 x=103 y=141 width=18 height=45 xoffset=-1 yoffset=0 xadvance=16 page=0 chnl=15 -char id=96 x=312 y=141 width=9 height=45 xoffset=0 yoffset=0 xadvance=11 page=0 chnl=15 -char id=97 x=474 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=98 x=68 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=99 x=267 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=100 x=46 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=101 x=198 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=102 x=141 y=141 width=15 height=45 xoffset=-1 yoffset=0 xadvance=12 page=0 chnl=15 -char id=103 x=222 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=104 x=415 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=105 x=398 y=141 width=7 height=45 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=15 -char id=106 x=235 y=141 width=11 height=45 xoffset=-2 yoffset=0 xadvance=11 page=0 chnl=15 -char id=107 x=405 y=47 width=21 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=108 x=407 y=141 width=7 height=45 xoffset=2 yoffset=0 xadvance=11 page=0 chnl=15 -char id=109 x=102 y=0 width=30 height=45 xoffset=1 yoffset=0 xadvance=32 page=0 chnl=15 -char id=110 x=331 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=111 x=428 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=112 x=266 y=94 width=20 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=113 x=288 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=114 x=158 y=141 width=15 height=45 xoffset=1 yoffset=0 xadvance=14 page=0 chnl=15 -char id=115 x=244 y=94 width=20 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15 -char id=116 x=175 y=141 width=14 height=45 xoffset=0 yoffset=0 xadvance=14 page=0 chnl=15 -char id=117 x=436 y=94 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 -char id=118 x=451 y=47 width=21 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15 -char id=119 x=36 y=0 width=32 height=45 xoffset=-1 yoffset=0 xadvance=30 page=0 chnl=15 -char id=120 x=0 y=94 width=21 height=45 xoffset=0 yoffset=0 xadvance=21 page=0 chnl=15 -char id=121 x=23 y=94 width=21 height=45 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15 -char id=122 x=83 y=141 width=18 height=45 xoffset=0 yoffset=0 xadvance=18 page=0 chnl=15 -char id=123 x=191 y=141 width=14 height=45 xoffset=-1 yoffset=0 xadvance=12 page=0 chnl=15 -char id=124 x=416 y=141 width=5 height=45 xoffset=2 yoffset=0 xadvance=9 page=0 chnl=15 -char id=125 x=207 y=141 width=13 height=45 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15 -char id=126 x=42 y=141 width=19 height=45 xoffset=1 yoffset=0 xadvance=21 page=0 chnl=15 diff --git a/examples/text/resources/fonts/bmfont.png b/examples/text/resources/fonts/bmfont.png deleted file mode 100644 index 9d621594..00000000 Binary files a/examples/text/resources/fonts/bmfont.png and /dev/null differ diff --git a/examples/text/resources/fonts/custom_alagard.png b/examples/text/resources/fonts/custom_alagard.png deleted file mode 100644 index c3eb63b7..00000000 Binary files a/examples/text/resources/fonts/custom_alagard.png and /dev/null differ diff --git a/examples/text/resources/fonts/custom_jupiter_crash.png b/examples/text/resources/fonts/custom_jupiter_crash.png deleted file mode 100644 index 451b591f..00000000 Binary files a/examples/text/resources/fonts/custom_jupiter_crash.png and /dev/null differ diff --git a/examples/text/resources/fonts/custom_mecha.png b/examples/text/resources/fonts/custom_mecha.png deleted file mode 100644 index 59caab2c..00000000 Binary files a/examples/text/resources/fonts/custom_mecha.png and /dev/null differ diff --git a/examples/text/resources/fonts/pixantiqua.ttf b/examples/text/resources/fonts/pixantiqua.ttf deleted file mode 100644 index e012875d..00000000 Binary files a/examples/text/resources/fonts/pixantiqua.ttf and /dev/null differ diff --git a/examples/text/resources/fonts/pixantiqua_0.png b/examples/text/resources/fonts/pixantiqua_0.png deleted file mode 100644 index 2aa2870f..00000000 Binary files a/examples/text/resources/fonts/pixantiqua_0.png and /dev/null differ diff --git a/examples/text/resources/pixantiqua.ttf b/examples/text/resources/pixantiqua.ttf new file mode 100644 index 00000000..e012875d Binary files /dev/null and b/examples/text/resources/pixantiqua.ttf differ diff --git a/examples/text/resources/pixantiqua_0.png b/examples/text/resources/pixantiqua_0.png new file mode 100644 index 00000000..2aa2870f Binary files /dev/null and b/examples/text/resources/pixantiqua_0.png differ diff --git a/examples/text/text_bmfont_ttf.c b/examples/text/text_bmfont_ttf.c index 4d060915..0778fd11 100644 --- a/examples/text/text_bmfont_ttf.c +++ b/examples/text/text_bmfont_ttf.c @@ -24,8 +24,8 @@ int main() const char msgTtf[64] = "THIS SPRITE FONT has been GENERATED from a TTF"; // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) - SpriteFont fontBm = LoadSpriteFont("resources/fonts/bmfont.fnt"); // BMFont (AngelCode) - SpriteFont fontTtf = LoadSpriteFont("resources/fonts/pixantiqua.ttf"); // TTF font + SpriteFont fontBm = LoadSpriteFont("resources/bmfont.fnt"); // BMFont (AngelCode) + SpriteFont fontTtf = LoadSpriteFont("resources/pixantiqua.ttf"); // TTF font Vector2 fontPosition; diff --git a/examples/text/text_bmfont_unordered.c b/examples/text/text_bmfont_unordered.c index 6fec3256..01561bec 100644 --- a/examples/text/text_bmfont_unordered.c +++ b/examples/text/text_bmfont_unordered.c @@ -25,7 +25,7 @@ int main() const char msg[256] = "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ"; // NOTE: Loaded font has an unordered list of characters (chars in the range 32..255) - SpriteFont font = LoadSpriteFont("resources/fonts/pixantiqua.fnt"); // BMFont (AngelCode) + SpriteFont font = LoadSpriteFont("resources/pixantiqua.fnt"); // BMFont (AngelCode) SetTargetFPS(60); //-------------------------------------------------------------------------------------- diff --git a/examples/text/text_font_select.c b/examples/text/text_font_select.c deleted file mode 100644 index 5891bef7..00000000 --- a/examples/text/text_font_select.c +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - Font selector -* -* 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 [text] example - font selector"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - SpriteFont fonts[8]; // SpriteFont array - - fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading - fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading - fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading - fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // SpriteFont loading - fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // SpriteFont loading - fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading - fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading - fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading - - int currentFont = 0; // Selected font - - Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; - - const char fontNames[8][20] = { "[0] Alagard", "[1] PixelPlay", "[2] MECHA", "[3] Setback", - "[4] Romulus", "[5] PixAntiqua", "[6] Alpha Beta", "[7] Jupiter Crash" }; - - const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text - - Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].baseSize*3, 1); - - Vector2 mousePoint; - - Color btnNextOutColor = DARKBLUE; // Button color (outside line) - Color btnNextInColor = SKYBLUE; // Button color (inside) - - int framesCounter = 0; // Useful to count frames button is 'active' = clicked - - int positionY = 180; // Text selector and button Y position - - Rectangle btnNextRec = { 673, positionY, 109, 44 }; // Button rectangle (useful for collision) - - 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 - //---------------------------------------------------------------------------------- - - // Keyboard-based font selection (easy) - if (IsKeyPressed(KEY_RIGHT)) - { - if (currentFont < 7) currentFont++; - } - - if (IsKeyPressed(KEY_LEFT)) - { - if (currentFont > 0) currentFont--; - } - - if (IsKeyPressed('0')) currentFont = 0; - else if (IsKeyPressed('1')) currentFont = 1; - else if (IsKeyPressed('2')) currentFont = 2; - else if (IsKeyPressed('3')) currentFont = 3; - else if (IsKeyPressed('4')) currentFont = 4; - else if (IsKeyPressed('5')) currentFont = 5; - else if (IsKeyPressed('6')) currentFont = 6; - else if (IsKeyPressed('7')) currentFont = 7; - - // Mouse-based font selection (NEXT button logic) - mousePoint = GetMousePosition(); - - if (CheckCollisionPointRec(mousePoint, btnNextRec)) - { - // Mouse hover button logic - if (framesCounter == 0) - { - btnNextOutColor = DARKPURPLE; - btnNextInColor = PURPLE; - } - - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) - { - framesCounter = 20; // Frames button is 'active' - btnNextOutColor = MAROON; - btnNextInColor = RED; - } - } - else - { - // Mouse not hover button - btnNextOutColor = DARKBLUE; - btnNextInColor = SKYBLUE; - } - - if (framesCounter > 0) framesCounter--; - - if (framesCounter == 1) // We change font on frame 1 - { - currentFont++; - if (currentFont > 7) currentFont = 0; - } - - // Text measurement for better positioning on screen - textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].baseSize*3, 1); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("font selector - use arroys, button or numbers", 160, 80, 20, DARKGRAY); - DrawLine(120, 120, 680, 120, DARKGRAY); - - DrawRectangle(18, positionY, 644, 44, DARKGRAY); - DrawRectangle(20, positionY + 2, 640, 40, LIGHTGRAY); - DrawText(fontNames[currentFont], 30, positionY + 13, 20, BLACK); - DrawText("< >", 610, positionY + 8, 30, BLACK); - - DrawRectangleRec(btnNextRec, btnNextOutColor); - DrawRectangle(675, positionY + 2, 105, 40, btnNextInColor); - DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor); - - DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2, - 260 + (70 - textSize.y)/2 }, fonts[currentFont].baseSize*3, - 1, colors[currentFont]); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); // SpriteFont(s) unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/examples/text/text_font_select.png b/examples/text/text_font_select.png deleted file mode 100644 index 65040df6..00000000 Binary files a/examples/text/text_font_select.png and /dev/null differ diff --git a/examples/text/text_rbmf_fonts.c b/examples/text/text_rbmf_fonts.c index cd5da1fe..f4778b45 100644 --- a/examples/text/text_rbmf_fonts.c +++ b/examples/text/text_rbmf_fonts.c @@ -85,10 +85,9 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - for (int i = 0; i < 8; i++) - { - UnloadSpriteFont(fonts[i]); // SpriteFont unloading - } + + // SpriteFonts unloading + for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/text/text_sprite_fonts.c b/examples/text/text_sprite_fonts.c index bded266e..aefbfd1f 100644 --- a/examples/text/text_sprite_fonts.c +++ b/examples/text/text_sprite_fonts.c @@ -25,9 +25,9 @@ int main() const char msg3[50] = "...and a THIRD one! GREAT! :D"; // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) - SpriteFont font1 = LoadSpriteFont("resources/fonts/custom_mecha.png"); // SpriteFont loading - SpriteFont font2 = LoadSpriteFont("resources/fonts/custom_alagard.png"); // SpriteFont loading - SpriteFont font3 = LoadSpriteFont("resources/fonts/custom_jupiter_crash.png"); // SpriteFont loading + SpriteFont font1 = LoadSpriteFont("resources/custom_mecha.png"); // SpriteFont loading + SpriteFont font2 = LoadSpriteFont("resources/custom_alagard.png"); // SpriteFont loading + SpriteFont font3 = LoadSpriteFont("resources/custom_jupiter_crash.png"); // SpriteFont loading Vector2 fontPosition1, fontPosition2, fontPosition3; diff --git a/examples/text/text_ttf_loading.c b/examples/text/text_ttf_loading.c index 4aa0bef4..4e490399 100644 --- a/examples/text/text_ttf_loading.c +++ b/examples/text/text_ttf_loading.c @@ -25,7 +25,7 @@ int main() // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) // TTF SpriteFont loading with custom generation parameters - SpriteFont font = LoadSpriteFontTTF("resources/fonts/KAISG.ttf", 96, 0, 0); + SpriteFont font = LoadSpriteFontTTF("resources/KAISG.ttf", 96, 0, 0); // Generate mipmap levels to use trilinear filtering // NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR diff --git a/examples/textures/resources/texture_formats/sonic.png b/examples/textures/resources/texture_formats/sonic.png deleted file mode 100644 index 7a096847..00000000 Binary files a/examples/textures/resources/texture_formats/sonic.png and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_A1R5G5B5.dds b/examples/textures/resources/texture_formats/sonic_A1R5G5B5.dds deleted file mode 100644 index 5e2347db..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_A1R5G5B5.dds and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_A4R4G4B4.dds b/examples/textures/resources/texture_formats/sonic_A4R4G4B4.dds deleted file mode 100644 index c5ccaf0c..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_A4R4G4B4.dds and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_A8R8G8B8.dds b/examples/textures/resources/texture_formats/sonic_A8R8G8B8.dds deleted file mode 100644 index fb71b7be..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_A8R8G8B8.dds and /dev/null 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 deleted file mode 100644 index 9a98d9a0..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ASTC_4x4_ldr.astc and /dev/null 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 deleted file mode 100644 index 360a264a..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ASTC_8x8_ldr.astc and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_DXT1_RGB.dds b/examples/textures/resources/texture_formats/sonic_DXT1_RGB.dds deleted file mode 100644 index 9d0b4598..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_DXT1_RGB.dds and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_DXT1_RGBA.dds b/examples/textures/resources/texture_formats/sonic_DXT1_RGBA.dds deleted file mode 100644 index 102bae7f..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_DXT1_RGBA.dds and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_DXT3_RGBA.dds b/examples/textures/resources/texture_formats/sonic_DXT3_RGBA.dds deleted file mode 100644 index 46d965cb..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_DXT3_RGBA.dds and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_DXT5_RGBA.dds b/examples/textures/resources/texture_formats/sonic_DXT5_RGBA.dds deleted file mode 100644 index b3a59a79..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_DXT5_RGBA.dds and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_ETC1_RGB.ktx b/examples/textures/resources/texture_formats/sonic_ETC1_RGB.ktx deleted file mode 100644 index 66241b9d..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ETC1_RGB.ktx and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_ETC1_RGB.pkm b/examples/textures/resources/texture_formats/sonic_ETC1_RGB.pkm deleted file mode 100644 index c6fc6df4..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ETC1_RGB.pkm and /dev/null 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 deleted file mode 100644 index b01812cb..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx and /dev/null 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 deleted file mode 100644 index 61ac48ce..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.old.pkm and /dev/null 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 deleted file mode 100644 index 61ac48ce..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_ETC2_RGB.ktx b/examples/textures/resources/texture_formats/sonic_ETC2_RGB.ktx deleted file mode 100644 index 7f1207f7..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ETC2_RGB.ktx and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_ETC2_RGB.pkm b/examples/textures/resources/texture_formats/sonic_ETC2_RGB.pkm deleted file mode 100644 index f290f019..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_ETC2_RGB.pkm and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_GRAYSCALE.pvr b/examples/textures/resources/texture_formats/sonic_GRAYSCALE.pvr deleted file mode 100644 index d31e2651..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_GRAYSCALE.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_L8A8.pvr b/examples/textures/resources/texture_formats/sonic_L8A8.pvr deleted file mode 100644 index ccf5932e..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_L8A8.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_PVRT_RGB.pvr b/examples/textures/resources/texture_formats/sonic_PVRT_RGB.pvr deleted file mode 100644 index 22f3f66a..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_PVRT_RGB.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_PVRT_RGBA.pvr b/examples/textures/resources/texture_formats/sonic_PVRT_RGBA.pvr deleted file mode 100644 index feb9aeaf..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_PVRT_RGBA.pvr and /dev/null 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 deleted file mode 100644 index 9147e1bb..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_PVRT_RGBA_2bpp.pvr and /dev/null 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 deleted file mode 100644 index 2a8aea8c..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_PVRT_RGB_2bpp.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_R4G4B4A4.pvr b/examples/textures/resources/texture_formats/sonic_R4G4B4A4.pvr deleted file mode 100644 index 3f7368a3..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_R4G4B4A4.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_R5G5B5A1.pvr b/examples/textures/resources/texture_formats/sonic_R5G5B5A1.pvr deleted file mode 100644 index c7fa098d..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_R5G5B5A1.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_R5G6B5.dds b/examples/textures/resources/texture_formats/sonic_R5G6B5.dds deleted file mode 100644 index 217da954..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_R5G6B5.dds and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_R5G6B5.pvr b/examples/textures/resources/texture_formats/sonic_R5G6B5.pvr deleted file mode 100644 index 9bb8320e..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_R5G6B5.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_R8G8B8.pvr b/examples/textures/resources/texture_formats/sonic_R8G8B8.pvr deleted file mode 100644 index 072cf3ef..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_R8G8B8.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_R8G8B8A8.pvr b/examples/textures/resources/texture_formats/sonic_R8G8B8A8.pvr deleted file mode 100644 index f82534f9..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_R8G8B8A8.pvr and /dev/null differ diff --git a/examples/textures/resources/texture_formats/sonic_R8G8B8A8.raw b/examples/textures/resources/texture_formats/sonic_R8G8B8A8.raw deleted file mode 100644 index fc5858e7..00000000 Binary files a/examples/textures/resources/texture_formats/sonic_R8G8B8A8.raw and /dev/null differ diff --git a/examples/textures/textures_formats_loading.c b/examples/textures/textures_formats_loading.c deleted file mode 100644 index f416ce38..00000000 --- a/examples/textures/textures_formats_loading.c +++ /dev/null @@ -1,244 +0,0 @@ -/******************************************************************************************* -* -* 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 deleted file mode 100644 index 6778080f..00000000 Binary files a/examples/textures/textures_formats_loading.png and /dev/null differ diff --git a/examples/textures/textures_particles_trail_blending.c b/examples/textures/textures_particles_trail_blending.c deleted file mode 100644 index 0b47c790..00000000 --- a/examples/textures/textures_particles_trail_blending.c +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************************* -* -* 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 deleted file mode 100644 index b0c40fd2..00000000 Binary files a/examples/textures/textures_particles_trail_blending.png and /dev/null differ -- cgit v1.2.3 From 4315b82ea7b42b68572f14c595aa46f030d82a43 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 14 Apr 2017 13:58:39 +0200 Subject: Replaced some images and updated examples --- examples/shaders/resources/fudesumi.png | Bin 0 -> 219234 bytes examples/shaders/resources/sonic.png | Bin 116512 -> 0 bytes examples/shaders/shaders_shapes_textures.c | 21 +++++++++------------ examples/shaders/shaders_shapes_textures.png | Bin 110700 -> 167756 bytes examples/textures/resources/fudesumi.png | Bin 0 -> 219234 bytes examples/textures/resources/fudesumi.raw | Bin 0 -> 786432 bytes examples/textures/textures_raw_data.c | 24 +++++++++++++----------- examples/textures/textures_raw_data.png | Bin 87424 -> 246014 bytes examples/textures/textures_srcrec_dstrec.c | 12 +++++++----- examples/textures/textures_srcrec_dstrec.png | Bin 47563 -> 37887 bytes 10 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 examples/shaders/resources/fudesumi.png delete mode 100644 examples/shaders/resources/sonic.png create mode 100644 examples/textures/resources/fudesumi.png create mode 100644 examples/textures/resources/fudesumi.raw (limited to 'examples/textures') diff --git a/examples/shaders/resources/fudesumi.png b/examples/shaders/resources/fudesumi.png new file mode 100644 index 00000000..8ba983dc Binary files /dev/null and b/examples/shaders/resources/fudesumi.png differ diff --git a/examples/shaders/resources/sonic.png b/examples/shaders/resources/sonic.png deleted file mode 100644 index 7a096847..00000000 Binary files a/examples/shaders/resources/sonic.png and /dev/null differ diff --git a/examples/shaders/shaders_shapes_textures.c b/examples/shaders/shaders_shapes_textures.c index 0a14469f..40e99a8f 100644 --- a/examples/shaders/shaders_shapes_textures.c +++ b/examples/shaders/shaders_shapes_textures.c @@ -9,7 +9,7 @@ * on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders * raylib comes with shaders ready for both versions, check raylib/shaders install folder * -* This example has been created using raylib 1.3 (www.raylib.com) +* This example has been created using raylib 1.7 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * * Copyright (c) 2015 Ramon Santamaria (@raysan5) @@ -18,9 +18,6 @@ #include "raylib.h" -#include -#include - int main() { // Initialization @@ -30,14 +27,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders"); - Texture2D sonic = LoadTexture("resources/texture_formats/sonic.png"); + Texture2D fudesumi = LoadTexture("resources/fudesumi.png"); // NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version Shader shader = LoadShader("resources/shaders/glsl330/base.vs", "resources/shaders/glsl330/grayscale.fs"); - - // Shader usage is also different than models/postprocessing, shader is just activated when required - + SetTargetFPS(60); //-------------------------------------------------------------------------------------- @@ -91,21 +86,23 @@ int main() // Activate our custom shader to be applied on next shapes/textures drawings BeginShaderMode(shader); - DrawTexture(sonic, 380, -10, WHITE); // Using custom shader + DrawTexture(fudesumi, 500, -30, WHITE); // Using custom shader // Activate our default shader for next drawings EndShaderMode(); + DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight - 20, 10, GRAY); + EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadTexture(sonic); // Unload texture + UnloadShader(shader); // Unload shader + UnloadTexture(fudesumi); // Unload texture - CloseWindow(); // Close window and OpenGL context + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; diff --git a/examples/shaders/shaders_shapes_textures.png b/examples/shaders/shaders_shapes_textures.png index ee5fed42..63a2283c 100644 Binary files a/examples/shaders/shaders_shapes_textures.png and b/examples/shaders/shaders_shapes_textures.png differ diff --git a/examples/textures/resources/fudesumi.png b/examples/textures/resources/fudesumi.png new file mode 100644 index 00000000..8ba983dc Binary files /dev/null and b/examples/textures/resources/fudesumi.png differ diff --git a/examples/textures/resources/fudesumi.raw b/examples/textures/resources/fudesumi.raw new file mode 100644 index 00000000..e05fa0e1 Binary files /dev/null and b/examples/textures/resources/fudesumi.raw differ diff --git a/examples/textures/textures_raw_data.c b/examples/textures/textures_raw_data.c index d1922180..b038792b 100644 --- a/examples/textures/textures_raw_data.c +++ b/examples/textures/textures_raw_data.c @@ -27,9 +27,9 @@ int main() // 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 + Image fudesumiRaw = LoadImageRaw("resources/fudesumi.raw", 384, 512, UNCOMPRESSED_R8G8B8A8, 0); + Texture2D fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM) + UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data // Generate a checked texture by code (1024x1024 pixels) int width = 1024; @@ -42,8 +42,8 @@ int main() { 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; + if (((x/32+y/32)/1)%2 == 0) pixels[y*height + x] = ORANGE; + else pixels[y*height + x] = GOLD; } } @@ -70,12 +70,14 @@ int main() ClearBackground(RAYWHITE); - DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.3f)); - DrawTexture(sonic, 330, -20, WHITE); + DrawTexture(checked, screenWidth/2 - checked.width/2, screenHeight/2 - checked.height/2, Fade(WHITE, 0.5f)); + DrawTexture(fudesumi, 430, -30, 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); + DrawText("CHECKED TEXTURE ", 84, 100, 30, BROWN); + DrawText("GENERATED by CODE", 72, 164, 30, BROWN); + DrawText("and RAW IMAGE LOADING", 46, 226, 30, BROWN); + + DrawText("(c) Fudesumi sprite by Eiden Marsal", 310, screenHeight - 20, 10, BROWN); EndDrawing(); //---------------------------------------------------------------------------------- @@ -83,7 +85,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadTexture(sonic); // Texture unloading + UnloadTexture(fudesumi); // Texture unloading UnloadTexture(checked); // Texture unloading CloseWindow(); // Close window and OpenGL context diff --git a/examples/textures/textures_raw_data.png b/examples/textures/textures_raw_data.png index 374d2266..437e4b53 100644 Binary files a/examples/textures/textures_raw_data.png and b/examples/textures/textures_raw_data.png differ diff --git a/examples/textures/textures_srcrec_dstrec.c b/examples/textures/textures_srcrec_dstrec.c index 6d824ce6..53ffd1d0 100644 --- a/examples/textures/textures_srcrec_dstrec.c +++ b/examples/textures/textures_srcrec_dstrec.c @@ -21,10 +21,10 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - Texture2D guybrush = LoadTexture("resources/guybrush.png"); // Texture loading + Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading - int frameWidth = guybrush.width/7; - int frameHeight = guybrush.height; + int frameWidth = scarfy.width/6; + int frameHeight = scarfy.height; // NOTE: Source rectangle (part of the texture to use for drawing) Rectangle sourceRec = { 0, 0, frameWidth, frameHeight }; @@ -59,10 +59,12 @@ int main() // 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); + DrawTexturePro(scarfy, sourceRec, destRec, origin, rotation, WHITE); DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY); DrawLine(0, destRec.y, screenWidth, destRec.y, GRAY); + + DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, GRAY); EndDrawing(); //---------------------------------------------------------------------------------- @@ -70,7 +72,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadTexture(guybrush); // Texture unloading + UnloadTexture(scarfy); // Texture unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/textures/textures_srcrec_dstrec.png b/examples/textures/textures_srcrec_dstrec.png index 9ea00fe4..7691ff2e 100644 Binary files a/examples/textures/textures_srcrec_dstrec.png and b/examples/textures/textures_srcrec_dstrec.png differ -- cgit v1.2.3 From b4d28cc7a1a0d9f5ce0c556535c612e67215bd18 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 16 Apr 2017 19:08:19 +0200 Subject: Working on examples... - Removed rbmf font example - Reviewed physac examples --- examples/models/models_mesh_picking.c | 195 +++++++++++++++++++++ examples/models/models_mesh_picking.png | Bin 0 -> 97991 bytes examples/models/models_ray_picking.c | 197 ---------------------- examples/others/particles_trail_blending.c | 135 --------------- examples/physac/physics_demo.c | 9 +- examples/physac/physics_friction.c | 10 +- examples/physac/physics_movement.c | 12 +- examples/physac/physics_restitution.c | 10 +- examples/physac/physics_shatter.c | 10 +- examples/text/resources/fonts/alagard.png | Bin 0 -> 4424 bytes examples/text/resources/fonts/alagard.rbmf | Bin 2159 -> 0 bytes examples/text/resources/fonts/alpha_beta.png | Bin 0 -> 2442 bytes examples/text/resources/fonts/alpha_beta.rbmf | Bin 2160 -> 0 bytes examples/text/resources/fonts/jupiter_crash.png | Bin 0 -> 3478 bytes examples/text/resources/fonts/jupiter_crash.rbmf | Bin 2160 -> 0 bytes examples/text/resources/fonts/mecha.png | Bin 0 -> 2399 bytes examples/text/resources/fonts/mecha.rbmf | Bin 2160 -> 0 bytes examples/text/resources/fonts/pixantiqua.fnt | 188 --------------------- examples/text/resources/fonts/pixantiqua.png | Bin 0 -> 3003 bytes examples/text/resources/fonts/pixantiqua.rbmf | Bin 2160 -> 0 bytes examples/text/resources/fonts/pixelplay.png | Bin 0 -> 2912 bytes examples/text/resources/fonts/pixelplay.rbmf | Bin 2160 -> 0 bytes examples/text/resources/fonts/romulus.png | Bin 0 -> 2932 bytes examples/text/resources/fonts/romulus.rbmf | Bin 2160 -> 0 bytes examples/text/resources/fonts/setback.png | Bin 0 -> 2539 bytes examples/text/resources/fonts/setback.rbmf | Bin 2160 -> 0 bytes examples/text/resources/pixantiqua.fnt | 188 +++++++++++++++++++++ examples/text/text_raylib_fonts.c | 103 +++++++++++ examples/text/text_raylib_fonts.png | Bin 0 -> 20204 bytes examples/text/text_rbmf_fonts.c | 96 ----------- examples/text/text_rbmf_fonts.png | Bin 19458 -> 0 bytes examples/textures/textures_particles_blending.c | 135 +++++++++++++++ examples/textures/textures_particles_blending.png | Bin 0 -> 421110 bytes 33 files changed, 656 insertions(+), 632 deletions(-) create mode 100644 examples/models/models_mesh_picking.c create mode 100644 examples/models/models_mesh_picking.png delete mode 100644 examples/models/models_ray_picking.c delete mode 100644 examples/others/particles_trail_blending.c create mode 100644 examples/text/resources/fonts/alagard.png delete mode 100644 examples/text/resources/fonts/alagard.rbmf create mode 100644 examples/text/resources/fonts/alpha_beta.png delete mode 100644 examples/text/resources/fonts/alpha_beta.rbmf create mode 100644 examples/text/resources/fonts/jupiter_crash.png delete mode 100644 examples/text/resources/fonts/jupiter_crash.rbmf create mode 100644 examples/text/resources/fonts/mecha.png delete mode 100644 examples/text/resources/fonts/mecha.rbmf delete mode 100644 examples/text/resources/fonts/pixantiqua.fnt create mode 100644 examples/text/resources/fonts/pixantiqua.png delete mode 100644 examples/text/resources/fonts/pixantiqua.rbmf create mode 100644 examples/text/resources/fonts/pixelplay.png delete mode 100644 examples/text/resources/fonts/pixelplay.rbmf create mode 100644 examples/text/resources/fonts/romulus.png delete mode 100644 examples/text/resources/fonts/romulus.rbmf create mode 100644 examples/text/resources/fonts/setback.png delete mode 100644 examples/text/resources/fonts/setback.rbmf create mode 100644 examples/text/resources/pixantiqua.fnt create mode 100644 examples/text/text_raylib_fonts.c create mode 100644 examples/text/text_raylib_fonts.png delete mode 100644 examples/text/text_rbmf_fonts.c delete mode 100644 examples/text/text_rbmf_fonts.png create mode 100644 examples/textures/textures_particles_blending.c create mode 100644 examples/textures/textures_particles_blending.png (limited to 'examples/textures') diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c new file mode 100644 index 00000000..0b5247ec --- /dev/null +++ b/examples/models/models_mesh_picking.c @@ -0,0 +1,195 @@ +/******************************************************************************************* +* +* raylib [models] example - Mesh picking in 3d mode, ground plane, triangle, mesh +* +* This example has been created using raylib 1.7 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2015 Ramon Santamaria (@raysan5) +* Example contributed by Joel Davis (@joeld42) +* +********************************************************************************************/ + +#include "raylib.h" +#include "raymath.h" + +#define FLT_MAX 3.40282347E+38F // Maximum value of a float, defined in + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking"); + + // Define the camera to look into our 3d world + Camera camera; + camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position + camera.target = (Vector3){ 0.0f, 2.3f, 0.0f }; // Camera looking at point + camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target) + camera.fovy = 45.0f; // Camera field-of-view Y + + Ray ray; // Picking ray + + Model tower = LoadModel("resources/tower.obj"); // Load OBJ model + Texture2D texture = LoadTexture("resources/tower.png"); // Load model texture + tower.material.texDiffuse = texture; // Set model diffuse texture + + Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position + BoundingBox towerBBox = CalculateBoundingBox(tower.mesh); + bool hitMeshBBox = false; + bool hitTriangle = false; + + // Test triangle + Vector3 ta = (Vector3){ -25.0, 0.5, 0.0 }; + Vector3 tb = (Vector3){ -4.0, 2.5, 1.0 }; + Vector3 tc = (Vector3){ -8.0, 6.5, 0.0 }; + + Vector3 bary = { 0.0f, 0.0f, 0.0f }; + + SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + UpdateCamera(&camera); // Update camera + + // Display information about closest hit + RayHitInfo nearestHit; + char *hitObjectName = "None"; + nearestHit.distance = FLT_MAX; + nearestHit.hit = false; + Color cursorColor = WHITE; + + // Get ray and test against ground, triangle, and mesh + ray = GetMouseRay(GetMousePosition(), camera); + + // Check ray collision aginst ground plane + RayHitInfo groundHitInfo = GetCollisionRayGround(ray, 0.0f); + + if ((groundHitInfo.hit) && (groundHitInfo.distance < nearestHit.distance)) + { + nearestHit = groundHitInfo; + cursorColor = GREEN; + hitObjectName = "Ground"; + } + + // Check ray collision against test triangle + RayHitInfo triHitInfo = GetCollisionRayTriangle(ray, ta, tb, tc); + + if ((triHitInfo.hit) && (triHitInfo.distance < nearestHit.distance)) + { + nearestHit = triHitInfo; + cursorColor = PURPLE; + hitObjectName = "Triangle"; + + bary = VectorBarycenter(nearestHit.hitPosition, ta, tb, tc); + hitTriangle = true; + } + else hitTriangle = false; + + RayHitInfo meshHitInfo; + + // Check ray collision against bounding box first, before trying the full ray-mesh test + if (CheckCollisionRayBox(ray, towerBBox)) + { + hitMeshBBox = true; + + // Check ray collision against mesh + meshHitInfo = GetCollisionRayMesh(ray, &tower.mesh); + + if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance)) + { + nearestHit = meshHitInfo; + cursorColor = ORANGE; + hitObjectName = "Mesh"; + } + + } hitMeshBBox = false; + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + Begin3dMode(camera); + + // Draw the tower + DrawModel(tower, towerPos, 1.0, WHITE); + + // Draw the test triangle + DrawLine3D(ta, tb, PURPLE); + DrawLine3D(tb, tc, PURPLE); + DrawLine3D(tc, ta, PURPLE); + + // Draw the mesh bbox if we hit it + if (hitMeshBBox) DrawBoundingBox(towerBBox, LIME); + + // If we hit something, draw the cursor at the hit point + if (nearestHit.hit) + { + DrawCube(nearestHit.hitPosition, 0.3, 0.3, 0.3, cursorColor); + DrawCubeWires(nearestHit.hitPosition, 0.3, 0.3, 0.3, RED); + + Vector3 normalEnd; + normalEnd.x = nearestHit.hitPosition.x + nearestHit.hitNormal.x; + normalEnd.y = nearestHit.hitPosition.y + nearestHit.hitNormal.y; + normalEnd.z = nearestHit.hitPosition.z + nearestHit.hitNormal.z; + + DrawLine3D(nearestHit.hitPosition, normalEnd, RED); + } + + DrawRay(ray, MAROON); + + DrawGrid(100, 1.0f); + + End3dMode(); + + // Draw some debug GUI text + DrawText(FormatText("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK); + + if (nearestHit.hit) + { + int ypos = 70; + + DrawText(FormatText("Distance: %3.2f", nearestHit.distance), 10, ypos, 10, BLACK); + + DrawText(FormatText("Hit Pos: %3.2f %3.2f %3.2f", + nearestHit.hitPosition.x, + nearestHit.hitPosition.y, + nearestHit.hitPosition.z), 10, ypos + 15, 10, BLACK); + + DrawText(FormatText("Hit Norm: %3.2f %3.2f %3.2f", + nearestHit.hitNormal.x, + nearestHit.hitNormal.y, + nearestHit.hitNormal.z), 10, ypos + 30, 10, BLACK); + + if (hitTriangle) DrawText(FormatText("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK); + } + + DrawText("Use Mouse to Move Camera", 10, 430, 10, GRAY); + + DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + UnloadModel(tower); // Unload model + UnloadTexture(texture); // Unload texture + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/models/models_mesh_picking.png b/examples/models/models_mesh_picking.png new file mode 100644 index 00000000..045db585 Binary files /dev/null and b/examples/models/models_mesh_picking.png differ diff --git a/examples/models/models_ray_picking.c b/examples/models/models_ray_picking.c deleted file mode 100644 index 55914fa2..00000000 --- a/examples/models/models_ray_picking.c +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************************* -* -* raylib [models] example - Ray picking in 3d mode, ground plane, triangle, mesh -* -* This example has been created using raylib 1.7 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* Example contributed by Joel Davis (@joeld42) -* -********************************************************************************************/ - -#include "raylib.h" -#include "raymath.h" - -#include -#include - - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d ray picking"); - - // Define the camera to look into our 3d world - Camera camera; - camera.position = (Vector3){ 10.0f, 8.0f, 10.0f }; // Camera position - camera.target = (Vector3){ 0.0f, 2.3f, 0.0f }; // Camera looking at point - camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target) - camera.fovy = 45.0f; // Camera field-of-view Y - - Ray ray; // Picking line ray - - Model tower = LoadModel("resources/tower.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/tower.png"); // Load model texture - tower.material.texDiffuse = texture; // Set model diffuse texture - - Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position - BoundingBox towerBBox = CalculateBoundingBox(tower.mesh); - bool hitMeshBBox = false; - bool hitTriangle = false; - - // Test triangle - Vector3 ta = (Vector3){ -25.0, 0.5, 0.0 }; - Vector3 tb = (Vector3){ -4.0, 2.5, 1.0 }; - Vector3 tc = (Vector3){ -8.0, 6.5, 0.0 }; - - Vector3 bary = { 0.0f, 0.0f, 0.0f }; - - SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - - // Display information about closest hit - RayHitInfo nearestHit; - char *hitObjectName = "None"; - nearestHit.distance = FLT_MAX; - nearestHit.hit = false; - Color cursorColor = WHITE; - - // Get ray and test against ground, triangle, and mesh - ray = GetMouseRay(GetMousePosition(), camera); - - // Check ray collision aginst ground plane - RayHitInfo groundHitInfo = GetCollisionRayGround(ray, 0.0f); - - if ((groundHitInfo.hit) && (groundHitInfo.distance < nearestHit.distance)) - { - nearestHit = groundHitInfo; - cursorColor = GREEN; - hitObjectName = "Ground"; - } - - // Check ray collision against test triangle - RayHitInfo triHitInfo = GetCollisionRayTriangle(ray, ta, tb, tc); - - if ((triHitInfo.hit) && (triHitInfo.distance < nearestHit.distance)) - { - nearestHit = triHitInfo; - cursorColor = PURPLE; - hitObjectName = "Triangle"; - - bary = Barycenter(nearestHit.hitPosition, ta, tb, tc); - hitTriangle = true; - } - else hitTriangle = false; - - RayHitInfo meshHitInfo; - - // Check ray collision against bounding box first, before trying the full ray-mesh test - if (CheckCollisionRayBox(ray, towerBBox)) - { - hitMeshBBox = true; - - // Check ray collision against mesh - meshHitInfo = GetCollisionRayMesh(ray, &tower.mesh); - - if ((meshHitInfo.hit) && (meshHitInfo.distance < nearestHit.distance)) - { - nearestHit = meshHitInfo; - cursorColor = ORANGE; - hitObjectName = "Mesh"; - } - - } hitMeshBBox = false; - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - Begin3dMode(camera); - - // Draw the tower - DrawModel(tower, towerPos, 1.0, WHITE); - - // Draw the test triangle - DrawLine3D(ta, tb, PURPLE); - DrawLine3D(tb, tc, PURPLE); - DrawLine3D(tc, ta, PURPLE); - - // Draw the mesh bbox if we hit it - if (hitMeshBBox) DrawBoundingBox(towerBBox, LIME); - - // If we hit something, draw the cursor at the hit point - if (nearestHit.hit) - { - DrawCube(nearestHit.hitPosition, 0.5, 0.5, 0.5, cursorColor); - DrawCubeWires(nearestHit.hitPosition, 0.5, 0.5, 0.5, YELLOW); - - Vector3 normalEnd; - normalEnd.x = nearestHit.hitPosition.x + nearestHit.hitNormal.x; - normalEnd.y = nearestHit.hitPosition.y + nearestHit.hitNormal.y; - normalEnd.z = nearestHit.hitPosition.z + nearestHit.hitNormal.z; - - DrawLine3D(nearestHit.hitPosition, normalEnd, YELLOW); - } - - DrawRay(ray, MAROON); - - DrawGrid(100, 1.0f); - - End3dMode(); - - // Draw some debug GUI text - DrawText(FormatText("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK); - - if (nearestHit.hit) - { - int ypos = 70; - - DrawText(FormatText("Distance: %3.2f", nearestHit.distance), 10, ypos, 10, BLACK); - - DrawText(FormatText("Hit Pos: %3.2f %3.2f %3.2f", - nearestHit.hitPosition.x, - nearestHit.hitPosition.y, - nearestHit.hitPosition.z), 10, ypos + 15, 10, BLACK); - - DrawText(FormatText("Hit Norm: %3.2f %3.2f %3.2f", - nearestHit.hitNormal.x, - nearestHit.hitNormal.y, - nearestHit.hitNormal.z), 10, ypos + 30, 10, BLACK); - - if (hitTriangle) DrawText(FormatText("Barycenter: %3.2f %3.2f %3.2f", bary.x, bary.y, bary.z), 10, ypos + 45, 10, BLACK); - } - - DrawText("Use Mouse to Move Camera", 10, 430, 10, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadModel(tower); // Unload model - UnloadTexture(texture); // Unload texture - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/examples/others/particles_trail_blending.c b/examples/others/particles_trail_blending.c deleted file mode 100644 index 0b47c790..00000000 --- a/examples/others/particles_trail_blending.c +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************************* -* -* 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/physac/physics_demo.c b/examples/physac/physics_demo.c index b12ac708..9bf04d50 100644 --- a/examples/physac/physics_demo.c +++ b/examples/physac/physics_demo.c @@ -2,9 +2,11 @@ * * Physac - Physics demo * -* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) +* +* Use the following line to compile: * -* Use the following code to compile (-static -lpthread): * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * @@ -15,7 +17,7 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION -#include "../src/physac.h" +#include "physac.h" int main() { @@ -123,3 +125,4 @@ int main() return 0; } + diff --git a/examples/physac/physics_friction.c b/examples/physac/physics_friction.c index db1b5f4c..25f31d3f 100644 --- a/examples/physac/physics_friction.c +++ b/examples/physac/physics_friction.c @@ -2,9 +2,11 @@ * * Physac - Physics friction * -* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) +* +* Use the following line to compile: * -* Use the following code to compile (-static -lpthread): * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * @@ -15,7 +17,7 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION -#include "../src/physac.h" +#include "physac.h" int main() { @@ -132,8 +134,10 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- ClosePhysics(); // Unitialize physics + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } + diff --git a/examples/physac/physics_movement.c b/examples/physac/physics_movement.c index 3345404d..f81316ed 100644 --- a/examples/physac/physics_movement.c +++ b/examples/physac/physics_movement.c @@ -2,9 +2,11 @@ * * Physac - Physics movement * -* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) +* +* Use the following line to compile: * -* Use the following code to compile (-static -lpthread): * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * @@ -15,9 +17,9 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION -#include "../src/physac.h" +#include "physac.h" -#define VELOCITY 0.5f +#define VELOCITY 0.5f int main() { @@ -118,8 +120,10 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- ClosePhysics(); // Unitialize physics + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } + diff --git a/examples/physac/physics_restitution.c b/examples/physac/physics_restitution.c index 534d125e..d58ec6e3 100644 --- a/examples/physac/physics_restitution.c +++ b/examples/physac/physics_restitution.c @@ -2,9 +2,11 @@ * * Physac - Physics restitution * -* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) +* +* Use the following line to compile: * -* Use the following code to compile (-static -lpthread): * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * @@ -15,7 +17,7 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION -#include "../src/physac.h" +#include "physac.h" int main() { @@ -111,8 +113,10 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- ClosePhysics(); // Unitialize physics + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } + diff --git a/examples/physac/physics_shatter.c b/examples/physac/physics_shatter.c index fac90714..4e3b0cb6 100644 --- a/examples/physac/physics_shatter.c +++ b/examples/physac/physics_shatter.c @@ -2,9 +2,11 @@ * * Physac - Body shatter * -* NOTE: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 1: Physac requires multi-threading, when InitPhysics() a second thread is created to manage physics calculations. +* NOTE 2: Physac requires static C library linkage to avoid dependency on MinGW DLL (-static -lpthread) +* +* Use the following line to compile: * -* Use the following code to compile (-static -lpthread): * gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread * -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition * @@ -15,7 +17,7 @@ #include "raylib.h" #define PHYSAC_IMPLEMENTATION -#include "../src/physac.h" +#include "physac.h" int main() { @@ -103,8 +105,10 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- ClosePhysics(); // Unitialize physics + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } + diff --git a/examples/text/resources/fonts/alagard.png b/examples/text/resources/fonts/alagard.png new file mode 100644 index 00000000..3ac4bf1c Binary files /dev/null and b/examples/text/resources/fonts/alagard.png differ diff --git a/examples/text/resources/fonts/alagard.rbmf b/examples/text/resources/fonts/alagard.rbmf deleted file mode 100644 index 8c9b68d3..00000000 Binary files a/examples/text/resources/fonts/alagard.rbmf and /dev/null differ diff --git a/examples/text/resources/fonts/alpha_beta.png b/examples/text/resources/fonts/alpha_beta.png new file mode 100644 index 00000000..c362bfb1 Binary files /dev/null and b/examples/text/resources/fonts/alpha_beta.png differ diff --git a/examples/text/resources/fonts/alpha_beta.rbmf b/examples/text/resources/fonts/alpha_beta.rbmf deleted file mode 100644 index bdb2e752..00000000 Binary files a/examples/text/resources/fonts/alpha_beta.rbmf and /dev/null differ diff --git a/examples/text/resources/fonts/jupiter_crash.png b/examples/text/resources/fonts/jupiter_crash.png new file mode 100644 index 00000000..1f5172fb Binary files /dev/null and b/examples/text/resources/fonts/jupiter_crash.png differ diff --git a/examples/text/resources/fonts/jupiter_crash.rbmf b/examples/text/resources/fonts/jupiter_crash.rbmf deleted file mode 100644 index d797e0d6..00000000 Binary files a/examples/text/resources/fonts/jupiter_crash.rbmf and /dev/null differ diff --git a/examples/text/resources/fonts/mecha.png b/examples/text/resources/fonts/mecha.png new file mode 100644 index 00000000..8022d18c Binary files /dev/null and b/examples/text/resources/fonts/mecha.png differ diff --git a/examples/text/resources/fonts/mecha.rbmf b/examples/text/resources/fonts/mecha.rbmf deleted file mode 100644 index 0266a065..00000000 Binary files a/examples/text/resources/fonts/mecha.rbmf and /dev/null differ diff --git a/examples/text/resources/fonts/pixantiqua.fnt b/examples/text/resources/fonts/pixantiqua.fnt deleted file mode 100644 index 971b9b0b..00000000 --- a/examples/text/resources/fonts/pixantiqua.fnt +++ /dev/null @@ -1,188 +0,0 @@ -info face="PixAntiqua" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=2,2,2,2 spacing=2,2 outline=0 -common lineHeight=32 base=27 scaleW=512 scaleH=512 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 -page id=0 file="pixantiqua_0.png" -chars count=184 -char id=32 x=9 y=304 width=7 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=33 x=391 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=34 x=240 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=35 x=468 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=36 x=152 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=37 x=176 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=38 x=303 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=39 x=495 y=266 width=8 height=36 xoffset=-3 yoffset=-2 xadvance=5 page=0 chnl=15 -char id=40 x=256 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=199 x=432 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=200 x=126 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=201 x=147 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=202 x=288 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=203 x=189 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=204 x=468 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=205 x=486 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=206 x=0 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=207 x=72 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=208 x=329 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=209 x=277 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=210 x=182 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=211 x=26 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=41 x=272 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=42 x=288 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=43 x=414 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=44 x=378 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=45 x=414 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=46 x=443 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=47 x=392 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=48 x=485 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=49 x=450 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=50 x=21 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=51 x=42 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=59 x=456 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=60 x=168 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=61 x=309 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=62 x=336 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=63 x=315 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=64 x=364 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=65 x=390 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=66 x=120 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=67 x=144 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=68 x=168 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=69 x=294 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=52 x=488 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=53 x=63 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=54 x=24 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=55 x=48 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=56 x=72 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=57 x=96 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=58 x=404 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=70 x=252 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=71 x=192 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=72 x=78 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=78 x=78 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=79 x=355 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=80 x=264 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=81 x=381 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=82 x=288 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=83 x=312 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=91 x=144 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=92 x=108 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=93 x=304 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=94 x=34 y=0 width=32 height=36 xoffset=-3 yoffset=-2 xadvance=29 page=0 chnl=15 -char id=95 x=231 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=96 x=442 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=97 x=408 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=98 x=432 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=99 x=210 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=84 x=336 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=85 x=360 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=86 x=0 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=87 x=68 y=0 width=30 height=36 xoffset=-3 yoffset=-2 xadvance=27 page=0 chnl=15 -char id=88 x=26 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=89 x=384 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=90 x=84 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=100 x=456 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=101 x=480 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=102 x=54 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=103 x=0 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=104 x=24 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=105 x=469 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=106 x=18 y=266 width=16 height=36 xoffset=-8 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=107 x=48 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=108 x=417 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=109 x=161 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 -char id=110 x=72 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=111 x=96 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=117 x=192 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=118 x=216 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=119 x=248 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 -char id=120 x=240 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=121 x=264 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=122 x=288 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=123 x=432 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=124 x=365 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=125 x=378 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=126 x=393 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=127 x=132 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 -char id=160 x=0 y=304 width=7 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=161 x=352 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=162 x=351 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=163 x=336 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=165 x=360 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=167 x=384 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=169 x=433 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=170 x=224 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=171 x=105 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=172 x=0 y=0 width=32 height=36 xoffset=-3 yoffset=-2 xadvance=29 page=0 chnl=15 -char id=173 x=494 y=38 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=174 x=52 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=175 x=52 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=176 x=126 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=177 x=435 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=178 x=320 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=179 x=336 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=181 x=459 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=112 x=120 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=113 x=144 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=114 x=396 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=115 x=168 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=116 x=36 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=182 x=408 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=183 x=498 y=190 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=185 x=192 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=186 x=208 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=187 x=477 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=191 x=456 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=192 x=407 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=193 x=234 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=194 x=416 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=195 x=156 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=196 x=130 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=197 x=104 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=198 x=190 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 -char id=212 x=0 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=213 x=338 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=214 x=312 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=215 x=357 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=216 x=286 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=217 x=456 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=218 x=480 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=219 x=0 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=220 x=24 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=221 x=48 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=222 x=260 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=223 x=72 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=224 x=96 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=225 x=120 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=226 x=144 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=227 x=168 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=228 x=192 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=229 x=216 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=230 x=219 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 -char id=231 x=372 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=73 x=90 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 -char id=74 x=216 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=75 x=240 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=76 x=273 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=77 x=100 y=0 width=30 height=36 xoffset=-3 yoffset=-2 xadvance=27 page=0 chnl=15 -char id=232 x=312 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=233 x=240 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=234 x=264 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=235 x=104 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=236 x=430 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=237 x=482 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=238 x=160 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 -char id=239 x=176 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 -char id=240 x=128 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=241 x=200 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=242 x=224 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=243 x=248 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=244 x=272 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=245 x=296 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=246 x=320 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=247 x=330 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=248 x=208 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 -char id=249 x=344 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=250 x=368 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=251 x=416 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=252 x=440 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=253 x=464 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 -char id=254 x=0 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 -char id=255 x=0 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 diff --git a/examples/text/resources/fonts/pixantiqua.png b/examples/text/resources/fonts/pixantiqua.png new file mode 100644 index 00000000..ce422e7e Binary files /dev/null and b/examples/text/resources/fonts/pixantiqua.png differ diff --git a/examples/text/resources/fonts/pixantiqua.rbmf b/examples/text/resources/fonts/pixantiqua.rbmf deleted file mode 100644 index 04ef0e25..00000000 Binary files a/examples/text/resources/fonts/pixantiqua.rbmf and /dev/null differ diff --git a/examples/text/resources/fonts/pixelplay.png b/examples/text/resources/fonts/pixelplay.png new file mode 100644 index 00000000..bf8f8818 Binary files /dev/null and b/examples/text/resources/fonts/pixelplay.png differ diff --git a/examples/text/resources/fonts/pixelplay.rbmf b/examples/text/resources/fonts/pixelplay.rbmf deleted file mode 100644 index 31d14038..00000000 Binary files a/examples/text/resources/fonts/pixelplay.rbmf and /dev/null differ diff --git a/examples/text/resources/fonts/romulus.png b/examples/text/resources/fonts/romulus.png new file mode 100644 index 00000000..46ccc327 Binary files /dev/null and b/examples/text/resources/fonts/romulus.png differ diff --git a/examples/text/resources/fonts/romulus.rbmf b/examples/text/resources/fonts/romulus.rbmf deleted file mode 100644 index be9da01a..00000000 Binary files a/examples/text/resources/fonts/romulus.rbmf and /dev/null differ diff --git a/examples/text/resources/fonts/setback.png b/examples/text/resources/fonts/setback.png new file mode 100644 index 00000000..086f3e27 Binary files /dev/null and b/examples/text/resources/fonts/setback.png differ diff --git a/examples/text/resources/fonts/setback.rbmf b/examples/text/resources/fonts/setback.rbmf deleted file mode 100644 index 09572215..00000000 Binary files a/examples/text/resources/fonts/setback.rbmf and /dev/null differ diff --git a/examples/text/resources/pixantiqua.fnt b/examples/text/resources/pixantiqua.fnt new file mode 100644 index 00000000..971b9b0b --- /dev/null +++ b/examples/text/resources/pixantiqua.fnt @@ -0,0 +1,188 @@ +info face="PixAntiqua" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=2,2,2,2 spacing=2,2 outline=0 +common lineHeight=32 base=27 scaleW=512 scaleH=512 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 +page id=0 file="pixantiqua_0.png" +chars count=184 +char id=32 x=9 y=304 width=7 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=33 x=391 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=34 x=240 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=35 x=468 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=36 x=152 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=37 x=176 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=38 x=303 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=39 x=495 y=266 width=8 height=36 xoffset=-3 yoffset=-2 xadvance=5 page=0 chnl=15 +char id=40 x=256 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=199 x=432 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=200 x=126 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=201 x=147 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=202 x=288 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=203 x=189 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=204 x=468 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=205 x=486 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=206 x=0 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=207 x=72 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=208 x=329 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=209 x=277 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=210 x=182 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=211 x=26 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=41 x=272 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=42 x=288 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=43 x=414 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=44 x=378 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=45 x=414 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=46 x=443 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=47 x=392 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=48 x=485 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=49 x=450 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=50 x=21 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=51 x=42 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=59 x=456 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=60 x=168 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=61 x=309 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=62 x=336 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=63 x=315 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=64 x=364 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=65 x=390 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=66 x=120 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=67 x=144 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=68 x=168 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=69 x=294 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=52 x=488 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=53 x=63 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=54 x=24 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=55 x=48 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=56 x=72 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=57 x=96 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=58 x=404 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=70 x=252 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=71 x=192 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=72 x=78 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=78 x=78 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=79 x=355 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=80 x=264 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=81 x=381 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=82 x=288 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=83 x=312 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=91 x=144 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=92 x=108 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=93 x=304 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=94 x=34 y=0 width=32 height=36 xoffset=-3 yoffset=-2 xadvance=29 page=0 chnl=15 +char id=95 x=231 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=96 x=442 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=97 x=408 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=98 x=432 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=99 x=210 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=84 x=336 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=85 x=360 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=86 x=0 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=87 x=68 y=0 width=30 height=36 xoffset=-3 yoffset=-2 xadvance=27 page=0 chnl=15 +char id=88 x=26 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=89 x=384 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=90 x=84 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=100 x=456 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=101 x=480 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=102 x=54 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=103 x=0 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=104 x=24 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=105 x=469 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=106 x=18 y=266 width=16 height=36 xoffset=-8 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=107 x=48 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=108 x=417 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=109 x=161 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 +char id=110 x=72 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=111 x=96 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=117 x=192 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=118 x=216 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=119 x=248 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 +char id=120 x=240 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=121 x=264 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=122 x=288 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=123 x=432 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=124 x=365 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=125 x=378 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=126 x=393 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=127 x=132 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 +char id=160 x=0 y=304 width=7 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=161 x=352 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=162 x=351 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=163 x=336 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=165 x=360 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=167 x=384 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=169 x=433 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=170 x=224 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=171 x=105 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=172 x=0 y=0 width=32 height=36 xoffset=-3 yoffset=-2 xadvance=29 page=0 chnl=15 +char id=173 x=494 y=38 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=174 x=52 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=175 x=52 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=176 x=126 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=177 x=435 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=178 x=320 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=179 x=336 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=181 x=459 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=112 x=120 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=113 x=144 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=114 x=396 y=228 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=115 x=168 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=116 x=36 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=182 x=408 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=183 x=498 y=190 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=185 x=192 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=186 x=208 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=187 x=477 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=191 x=456 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=192 x=407 y=0 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=193 x=234 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=194 x=416 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=195 x=156 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=196 x=130 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=197 x=104 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=198 x=190 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 +char id=212 x=0 y=76 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=213 x=338 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=214 x=312 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=215 x=357 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=216 x=286 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=217 x=456 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=218 x=480 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=219 x=0 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=220 x=24 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=221 x=48 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=222 x=260 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=223 x=72 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=224 x=96 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=225 x=120 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=226 x=144 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=227 x=168 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=228 x=192 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=229 x=216 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=230 x=219 y=0 width=27 height=36 xoffset=-3 yoffset=-2 xadvance=24 page=0 chnl=15 +char id=231 x=372 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=73 x=90 y=266 width=16 height=36 xoffset=-3 yoffset=-2 xadvance=13 page=0 chnl=15 +char id=74 x=216 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=75 x=240 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=76 x=273 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=77 x=100 y=0 width=30 height=36 xoffset=-3 yoffset=-2 xadvance=27 page=0 chnl=15 +char id=232 x=312 y=152 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=233 x=240 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=234 x=264 y=190 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=235 x=104 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=236 x=430 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=237 x=482 y=266 width=11 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=238 x=160 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=11 page=0 chnl=15 +char id=239 x=176 y=266 width=14 height=36 xoffset=-3 yoffset=-2 xadvance=8 page=0 chnl=15 +char id=240 x=128 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=241 x=200 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=242 x=224 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=243 x=248 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=244 x=272 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=245 x=296 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=246 x=320 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=247 x=330 y=190 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=248 x=208 y=38 width=24 height=36 xoffset=-3 yoffset=-2 xadvance=21 page=0 chnl=15 +char id=249 x=344 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=250 x=368 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=251 x=416 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=252 x=440 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=253 x=464 y=76 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 +char id=254 x=0 y=228 width=19 height=36 xoffset=-3 yoffset=-2 xadvance=16 page=0 chnl=15 +char id=255 x=0 y=114 width=22 height=36 xoffset=-3 yoffset=-2 xadvance=19 page=0 chnl=15 diff --git a/examples/text/text_raylib_fonts.c b/examples/text/text_raylib_fonts.c new file mode 100644 index 00000000..6d8ef2b6 --- /dev/null +++ b/examples/text/text_raylib_fonts.c @@ -0,0 +1,103 @@ +/******************************************************************************************* +* +* raylib [text] example - raylib font loading and usage +* +* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!) +* To view details and credits for those fonts, check raylib license file +* +* This example has been created using raylib 1.7 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2017 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +#define MAX_FONTS 8 + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); + + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) + SpriteFont fonts[MAX_FONTS]; + + fonts[0] = LoadSpriteFont("resources/fonts/alagard.png"); + fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.png"); + fonts[2] = LoadSpriteFont("resources/fonts/mecha.png"); + fonts[3] = LoadSpriteFont("resources/fonts/setback.png"); + fonts[4] = LoadSpriteFont("resources/fonts/romulus.png"); + fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.png"); + fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.png"); + fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.png"); + + const char *messages[MAX_FONTS] = { "ALAGARD FONT designed by Hewett Tsoi", + "PIXELPLAY FONT designed by Aleksander Shevchuk", + "MECHA FONT designed by Captain Falcon", + "SETBACK FONT designed by Brian Kent (AEnigma)", + "ROMULUS FONT designed by Hewett Tsoi", + "PIXANTIQUA FONT designed by Gerhard Grossmann", + "ALPHA_BETA FONT designed by Brian Kent (AEnigma)", + "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" }; + + const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 }; + + Vector2 positions[MAX_FONTS]; + + for (int i = 0; i < MAX_FONTS; i++) + { + positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2; + positions[i].y = 60 + fonts[i].baseSize + 45*i; + } + + // Small Y position corrections + positions[3].y += 8; + positions[4].y += 2; + positions[7].y -= 8; + + Color colors[MAX_FONTS] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY); + DrawLine(220, 50, 590, 50, DARKGRAY); + + for (int i = 0; i < MAX_FONTS; i++) + { + DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]); + } + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + + // SpriteFonts unloading + for (int i = 0; i < MAX_FONTS; i++) UnloadSpriteFont(fonts[i]); + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/text/text_raylib_fonts.png b/examples/text/text_raylib_fonts.png new file mode 100644 index 00000000..8f428a67 Binary files /dev/null and b/examples/text/text_raylib_fonts.png differ diff --git a/examples/text/text_rbmf_fonts.c b/examples/text/text_rbmf_fonts.c deleted file mode 100644 index f4778b45..00000000 --- a/examples/text/text_rbmf_fonts.c +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - raylib bitmap font (rbmf) loading and usage -* -* NOTE: raylib is distributed with some free to use fonts (even for commercial pourposes!) -* To view details and credits for those fonts, check raylib license file -* -* This example has been created using raylib 1.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 [text] example - rBMF fonts"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - SpriteFont fonts[8]; - - fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // rBMF font loading - fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // rBMF font loading - fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // rBMF font loading - fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // rBMF font loading - fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // rBMF font loading - fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // rBMF font loading - fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // rBMF font loading - fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // rBMF font loading - - const char *messages[8] = { "ALAGARD FONT designed by Hewett Tsoi", - "PIXELPLAY FONT designed by Aleksander Shevchuk", - "MECHA FONT designed by Captain Falcon", - "SETBACK FONT designed by Brian Kent (AEnigma)", - "ROMULUS FONT designed by Hewett Tsoi", - "PIXANTIQUA FONT designed by Gerhard Grossmann", - "ALPHA_BETA FONT designed by Brian Kent (AEnigma)", - "JUPITER_CRASH FONT designed by Brian Kent (AEnigma)" }; - - const int spacings[8] = { 2, 4, 8, 4, 3, 4, 4, 1 }; - - Vector2 positions[8]; - - for (int i = 0; i < 8; i++) - { - positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2; - positions[i].y = 60 + fonts[i].baseSize + 50*i; - } - - Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD }; - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - // TODO: Update your variables here - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY); - DrawLine(220, 50, 590, 50, DARKGRAY); - - for (int i = 0; i < 8; i++) - { - DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]); - } - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - - // SpriteFonts unloading - for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -} \ No newline at end of file diff --git a/examples/text/text_rbmf_fonts.png b/examples/text/text_rbmf_fonts.png deleted file mode 100644 index c047c503..00000000 Binary files a/examples/text/text_rbmf_fonts.png and /dev/null differ diff --git a/examples/textures/textures_particles_blending.c b/examples/textures/textures_particles_blending.c new file mode 100644 index 00000000..842ac77d --- /dev/null +++ b/examples/textures/textures_particles_blending.c @@ -0,0 +1,135 @@ +/******************************************************************************************* +* +* raylib example - particles blending +* +* This example has been created using raylib 1.7 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2017 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 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_blending.png b/examples/textures/textures_particles_blending.png new file mode 100644 index 00000000..f90a87fd Binary files /dev/null and b/examples/textures/textures_particles_blending.png differ -- cgit v1.2.3