diff options
29 files changed, 75 insertions, 51 deletions
diff --git a/examples/models/models_ray_picking.c b/examples/models/models_mesh_picking.c index 55914fa2..0b5247ec 100644 --- a/examples/models/models_ray_picking.c +++ b/examples/models/models_mesh_picking.c @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raylib [models] example - Ray picking in 3d mode, ground plane, triangle, mesh +* 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) @@ -13,9 +13,7 @@ #include "raylib.h" #include "raymath.h" -#include <stdio.h> -#include <float.h> - +#define FLT_MAX 3.40282347E+38F // Maximum value of a float, defined in <float.h> int main() { @@ -24,7 +22,7 @@ int main() int screenWidth = 800; int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [models] example - 3d ray picking"); + InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking"); // Define the camera to look into our 3d world Camera camera; @@ -33,7 +31,7 @@ int main() 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 + Ray ray; // Picking ray Model tower = LoadModel("resources/tower.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/tower.png"); // Load model texture @@ -91,7 +89,7 @@ int main() cursorColor = PURPLE; hitObjectName = "Triangle"; - bary = Barycenter(nearestHit.hitPosition, ta, tb, tc); + bary = VectorBarycenter(nearestHit.hitPosition, ta, tb, tc); hitTriangle = true; } else hitTriangle = false; @@ -138,15 +136,15 @@ int main() // 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); + 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, YELLOW); + DrawLine3D(nearestHit.hitPosition, normalEnd, RED); } DrawRay(ray, MAROON); diff --git a/examples/models/models_mesh_picking.png b/examples/models/models_mesh_picking.png Binary files differnew file mode 100644 index 00000000..045db585 --- /dev/null +++ b/examples/models/models_mesh_picking.png 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 Binary files differnew file mode 100644 index 00000000..3ac4bf1c --- /dev/null +++ b/examples/text/resources/fonts/alagard.png diff --git a/examples/text/resources/fonts/alagard.rbmf b/examples/text/resources/fonts/alagard.rbmf Binary files differdeleted file mode 100644 index 8c9b68d3..00000000 --- a/examples/text/resources/fonts/alagard.rbmf +++ /dev/null diff --git a/examples/text/resources/fonts/alpha_beta.png b/examples/text/resources/fonts/alpha_beta.png Binary files differnew file mode 100644 index 00000000..c362bfb1 --- /dev/null +++ b/examples/text/resources/fonts/alpha_beta.png diff --git a/examples/text/resources/fonts/alpha_beta.rbmf b/examples/text/resources/fonts/alpha_beta.rbmf Binary files differdeleted file mode 100644 index bdb2e752..00000000 --- a/examples/text/resources/fonts/alpha_beta.rbmf +++ /dev/null diff --git a/examples/text/resources/fonts/jupiter_crash.png b/examples/text/resources/fonts/jupiter_crash.png Binary files differnew file mode 100644 index 00000000..1f5172fb --- /dev/null +++ b/examples/text/resources/fonts/jupiter_crash.png diff --git a/examples/text/resources/fonts/jupiter_crash.rbmf b/examples/text/resources/fonts/jupiter_crash.rbmf Binary files differdeleted file mode 100644 index d797e0d6..00000000 --- a/examples/text/resources/fonts/jupiter_crash.rbmf +++ /dev/null diff --git a/examples/text/resources/fonts/mecha.png b/examples/text/resources/fonts/mecha.png Binary files differnew file mode 100644 index 00000000..8022d18c --- /dev/null +++ b/examples/text/resources/fonts/mecha.png diff --git a/examples/text/resources/fonts/mecha.rbmf b/examples/text/resources/fonts/mecha.rbmf Binary files differdeleted file mode 100644 index 0266a065..00000000 --- a/examples/text/resources/fonts/mecha.rbmf +++ /dev/null diff --git a/examples/text/resources/fonts/pixantiqua.png b/examples/text/resources/fonts/pixantiqua.png Binary files differnew file mode 100644 index 00000000..ce422e7e --- /dev/null +++ b/examples/text/resources/fonts/pixantiqua.png diff --git a/examples/text/resources/fonts/pixantiqua.rbmf b/examples/text/resources/fonts/pixantiqua.rbmf Binary files differdeleted file mode 100644 index 04ef0e25..00000000 --- a/examples/text/resources/fonts/pixantiqua.rbmf +++ /dev/null diff --git a/examples/text/resources/fonts/pixelplay.png b/examples/text/resources/fonts/pixelplay.png Binary files differnew file mode 100644 index 00000000..bf8f8818 --- /dev/null +++ b/examples/text/resources/fonts/pixelplay.png diff --git a/examples/text/resources/fonts/pixelplay.rbmf b/examples/text/resources/fonts/pixelplay.rbmf Binary files differdeleted file mode 100644 index 31d14038..00000000 --- a/examples/text/resources/fonts/pixelplay.rbmf +++ /dev/null diff --git a/examples/text/resources/fonts/romulus.png b/examples/text/resources/fonts/romulus.png Binary files differnew file mode 100644 index 00000000..46ccc327 --- /dev/null +++ b/examples/text/resources/fonts/romulus.png diff --git a/examples/text/resources/fonts/romulus.rbmf b/examples/text/resources/fonts/romulus.rbmf Binary files differdeleted file mode 100644 index be9da01a..00000000 --- a/examples/text/resources/fonts/romulus.rbmf +++ /dev/null diff --git a/examples/text/resources/fonts/setback.png b/examples/text/resources/fonts/setback.png Binary files differnew file mode 100644 index 00000000..086f3e27 --- /dev/null +++ b/examples/text/resources/fonts/setback.png diff --git a/examples/text/resources/fonts/setback.rbmf b/examples/text/resources/fonts/setback.rbmf Binary files differdeleted file mode 100644 index 09572215..00000000 --- a/examples/text/resources/fonts/setback.rbmf +++ /dev/null diff --git a/examples/text/resources/fonts/pixantiqua.fnt b/examples/text/resources/pixantiqua.fnt index 971b9b0b..971b9b0b 100644 --- a/examples/text/resources/fonts/pixantiqua.fnt +++ b/examples/text/resources/pixantiqua.fnt diff --git a/examples/text/text_rbmf_fonts.c b/examples/text/text_raylib_fonts.c index f4778b45..6d8ef2b6 100644 --- a/examples/text/text_rbmf_fonts.c +++ b/examples/text/text_raylib_fonts.c @@ -1,19 +1,21 @@ /******************************************************************************************* * -* raylib [text] example - raylib bitmap font (rbmf) loading and usage +* 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.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) +* Copyright (c) 2017 Ramon Santamaria (@raysan5) * ********************************************************************************************/ #include "raylib.h" +#define MAX_FONTS 8 + int main() { // Initialization @@ -21,21 +23,21 @@ int main() int screenWidth = 800; int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [text] example - rBMF fonts"); + InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - SpriteFont fonts[8]; + SpriteFont fonts[MAX_FONTS]; - 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 + 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[8] = { "ALAGARD FONT designed by Hewett Tsoi", + 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)", @@ -44,17 +46,22 @@ int main() "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 }; + const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 }; - Vector2 positions[8]; + Vector2 positions[MAX_FONTS]; - for (int i = 0; i < 8; i++) + 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 + 50*i; + positions[i].y = 60 + fonts[i].baseSize + 45*i; } - Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD }; + // 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 @@ -74,7 +81,7 @@ int main() DrawText("free fonts included with raylib", 250, 20, 20, DARKGRAY); DrawLine(220, 50, 590, 50, DARKGRAY); - for (int i = 0; i < 8; i++) + for (int i = 0; i < MAX_FONTS; i++) { DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]); } @@ -87,7 +94,7 @@ int main() //-------------------------------------------------------------------------------------- // SpriteFonts unloading - for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); + for (int i = 0; i < MAX_FONTS; i++) UnloadSpriteFont(fonts[i]); CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/text/text_raylib_fonts.png b/examples/text/text_raylib_fonts.png Binary files differnew file mode 100644 index 00000000..8f428a67 --- /dev/null +++ b/examples/text/text_raylib_fonts.png diff --git a/examples/text/text_rbmf_fonts.png b/examples/text/text_rbmf_fonts.png Binary files differdeleted file mode 100644 index c047c503..00000000 --- a/examples/text/text_rbmf_fonts.png +++ /dev/null diff --git a/examples/others/particles_trail_blending.c b/examples/textures/textures_particles_blending.c index 0b47c790..842ac77d 100644 --- a/examples/others/particles_trail_blending.c +++ b/examples/textures/textures_particles_blending.c @@ -1,11 +1,11 @@ /******************************************************************************************* * -* raylib example - particles trail blending +* raylib example - particles blending * -* 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) +* Copyright (c) 2017 Ramon Santamaria (@raysan5) * ********************************************************************************************/ @@ -30,7 +30,7 @@ int main() int screenWidth = 800; int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles trail blending"); + InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending"); // Particles pool, reuse them! Particle mouseTail[MAX_PARTICLES]; diff --git a/examples/textures/textures_particles_blending.png b/examples/textures/textures_particles_blending.png Binary files differnew file mode 100644 index 00000000..f90a87fd --- /dev/null +++ b/examples/textures/textures_particles_blending.png |
