diff options
Diffstat (limited to 'examples')
67 files changed, 149 insertions, 496 deletions
diff --git a/examples/Makefile b/examples/Makefile index 97971029..18a5d1f4 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -4,7 +4,7 @@ # # NOTE: By default examples are compiled using raylib static library and OpenAL Soft shared library # -# Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) +# Copyright (c) 2013-2017 Ramon Santamaria (@raysan5) # # This software is provided "as-is", without any express or implied warranty. In no event # will the authors be held liable for any damages arising from the use of this software. @@ -23,13 +23,22 @@ # #************************************************************************************************** +.PHONY: all clean + # define raylib platform to compile for # possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB # WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop() PLATFORM ?= PLATFORM_DESKTOP # define NO to use OpenAL Soft as static library (shared by default) -SHARED_OPENAL ?= YES +SHARED_OPENAL ?= NO + +ifeq ($(PLATFORM),PLATFORM_WEB) + SHARED_OPENAL = NO +endif + +# define raylib directory for include and library +RAYLIB_PATH ?= C:\raylib\raylib # determine PLATFORM_OS in case PLATFORM_DESKTOP selected ifeq ($(PLATFORM),PLATFORM_DESKTOP) @@ -74,7 +83,7 @@ endif # -std=gnu99 defines C language mode (GNU C from 1999 revision) # -fgnu89-inline declaring inline functions support (GCC optimized) # -Wno-missing-braces ignore invalid warning (GCC bug 53119) -# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB +# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) CFLAGS = -O2 -s -Wall -std=c99 @@ -88,10 +97,11 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif ifeq ($(PLATFORM),PLATFORM_WEB) CFLAGS = -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -s USE_GLFW=3 -s ASSERTIONS=1 --profiling - # -O2 # if used, also set --memory-init-file 0 - # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) - #-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing - #-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) + # -O2 # if used, also set --memory-init-file 0 + # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) + # -s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing + # -s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB) + # --preload-file file.res # embbed file.res resource into .data file endif ifeq ($(PLATFORM),PLATFORM_RPI) CFLAGS = -O2 -s -Wall -std=gnu99 -fgnu89-inline @@ -101,24 +111,24 @@ endif # define raylib release directory for compiled library ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) - RAYLIB_PATH = ../release/win32/mingw32 + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/win32/mingw32 endif ifeq ($(PLATFORM_OS),LINUX) - RAYLIB_PATH = ../release/linux + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/linux endif ifeq ($(PLATFORM_OS),OSX) - RAYLIB_PATH = ../release/osx + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/osx endif endif ifeq ($(PLATFORM),PLATFORM_WEB) - RAYLIB_PATH = ../release/html5 + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/html5 endif ifeq ($(PLATFORM),PLATFORM_RPI) - RAYLIB_PATH = ../release/rpi + RAYLIB_RELEASE = $(RAYLIB_PATH)/release/rpi endif # define any directories containing required header files -INCLUDES = -I. -I../src -I../src/external -I$(RAYLIB_PATH) +INCLUDES = -I. -I$(RAYLIB_RELEASE) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external ifeq ($(PLATFORM),PLATFORM_RPI) INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads @@ -127,9 +137,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # external libraries headers # GLFW3 - INCLUDES += -I../src/external/glfw3/include + INCLUDES += -I$(RAYLIB_PATH)/src/external/glfw3/include # OpenAL Soft - INCLUDES += -I../src/external/openal_soft/include + INCLUDES += -I$(RAYLIB_PATH)/src/external/openal_soft/include endif ifeq ($(PLATFORM_OS),LINUX) # you may optionally create this directory and install raylib @@ -142,7 +152,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) endif # define library paths containing required libs -LFLAGS = -L. -L../src -L$(RAYLIB_PATH) +LFLAGS = -L. -L$(RAYLIB_RELEASE) -L$(RAYLIB_PATH)/src ifeq ($(PLATFORM),PLATFORM_RPI) LFLAGS += -L/opt/vc/lib @@ -152,9 +162,9 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # external libraries to link with # GLFW3 - LFLAGS += -L../src/external/glfw3/lib/$(LIBPATH) + LFLAGS += -L$(RAYLIB_PATH)/src/external/glfw3/lib/$(LIBPATH) # OpenAL Soft - LFLAGS += -L../src/external/openal_soft/lib/$(LIBPATH) + LFLAGS += -L$(RAYLIB_PATH)/src/external/openal_soft/lib/$(LIBPATH) endif endif @@ -166,7 +176,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) # requires the following packages: # libglfw3-dev libopenal-dev libegl1-mesa-dev LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -lpthread -ldl - # on XWindow could require also below libraries, just uncomment + # on XWindow requires also below libraries LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor else ifeq ($(PLATFORM_OS),OSX) @@ -194,19 +204,20 @@ ifeq ($(PLATFORM),PLATFORM_RPI) LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal endif ifeq ($(PLATFORM),PLATFORM_WEB) - # just adjust the correct path to libraylib.bc - LIBS = ../release/html5/libraylib.bc + # NOTE: Set the correct path to libraylib.bc + LIBS = $(RAYLIB_RELEASE)/libraylib.bc endif # define additional parameters and flags for windows ifeq ($(PLATFORM_OS),WINDOWS) # resources file contains windows exe icon # -Wl,--subsystem,windows hides the console window - WINFLAGS = ../src/resources -Wl,--subsystem,windows + WINFLAGS = $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows endif ifeq ($(PLATFORM),PLATFORM_WEB) EXT = .html + WEB_SHELL = --shell-file $(RAYLIB_PATH)\templates\web_shell\shell.html endif # define all object files required @@ -232,28 +243,31 @@ EXAMPLES = \ shapes/shapes_basic_shapes \ shapes/shapes_colors_palette \ shapes/shapes_logo_raylib_anim \ + shapes/shapes_lines_bezier \ textures/textures_logo_raylib \ textures/textures_image_loading \ textures/textures_rectangle \ textures/textures_srcrec_dstrec \ textures/textures_to_image \ textures/textures_raw_data \ + textures/textures_particles_blending \ textures/textures_image_processing \ textures/textures_image_drawing \ text/text_sprite_fonts \ text/text_bmfont_ttf \ - text/text_rbmf_fonts \ + text/text_raylib_fonts \ text/text_format_text \ text/text_writing_anim \ text/text_ttf_loading \ text/text_bmfont_unordered \ + text/text_input_box \ models/models_geometric_shapes \ models/models_box_collisions \ models/models_billboard \ models/models_obj_loading \ models/models_heightmap \ models/models_cubicmap \ - models/models_ray_picking \ + models/models_mesh_picking \ shaders/shaders_model_shader \ shaders/shaders_shapes_textures \ shaders/shaders_custom_uniform \ @@ -270,8 +284,7 @@ EXAMPLES = \ fix_dylib \ -# typing 'make' will invoke the default target entry called 'all', -# in this case, the 'default' target entry is raylib +# typing 'make' will invoke the default target entry all: examples # generic compilation pattern @@ -372,6 +385,10 @@ shapes/shapes_colors_palette: shapes/shapes_colors_palette.c # compile [shapes] example - raylib logo animation shapes/shapes_logo_raylib_anim: shapes/shapes_logo_raylib_anim.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) + +# compile [shapes] example - lines bezier +shapes/shapes_lines_bezier: shapes/shapes_lines_bezier.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) # compile [textures] example - raylib logo texture loading textures/textures_logo_raylib: textures/textures_logo_raylib.c @@ -396,6 +413,10 @@ textures/textures_to_image: textures/textures_to_image.c # compile [textures] example - texture raw data textures/textures_raw_data: textures/textures_raw_data.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) + +# compile [textures] example - texture particles blending +textures/textures_particles_blending: textures/textures_particles_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 @@ -413,8 +434,8 @@ text/text_sprite_fonts: text/text_sprite_fonts.c text/text_bmfont_ttf: text/text_bmfont_ttf.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) -# compile [text] example - raylib bitmap fonts (rBMF) -text/text_rbmf_fonts: text/text_rbmf_fonts.c +# compile [text] example - raylib fonts +text/text_raylib_fonts: text/text_raylib_fonts.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) # compile [text] example - text formatting @@ -432,6 +453,10 @@ text/text_ttf_loading: text/text_ttf_loading.c # compile [text] example - text bmfont unordered text/text_bmfont_unordered: text/text_bmfont_unordered.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) + +# compile [text] example - text input box +text/text_input_box: text/text_input_box.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) # compile [models] example - basic geometric 3d shapes models/models_geometric_shapes: models/models_geometric_shapes.c @@ -461,8 +486,8 @@ models/models_heightmap: models/models_heightmap.c models/models_cubicmap: models/models_cubicmap.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) -# compile [models] example - model ray picking -models/models_ray_picking: models/models_ray_picking.c +# compile [models] example - model mesh picking +models/models_mesh_picking: models/models_mesh_picking.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) # compile [shaders] example - model shader @@ -499,23 +524,23 @@ audio/audio_raw_stream: audio/audio_raw_stream.c # compile [physac] example - physics demo physac/physics_demo: physac/physics_demo.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS) + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS) # compile [physac] example - physics friction physac/physics_friction: physac/physics_friction.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS) + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS) # compile [physac] example - physics movement physac/physics_movement: physac/physics_movement.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS) + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS) # compile [physac] example - physics restitution physac/physics_restitution: physac/physics_restitution.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS) + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS) # compile [physac] example - physics shatter physac/physics_shatter: physac/physics_shatter.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -lpthread -D$(PLATFORM) $(WINFLAGS) + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -static -lpthread -D$(PLATFORM) $(WINFLAGS) # fix dylib install path name for each executable (MAC) fix_dylib: @@ -533,7 +558,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),LINUX) find -type f -executable | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f else - del *.o *.exe + del *.o *.exe /s endif endif endif 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/others/font_selector.c b/examples/others/font_selector.c deleted file mode 100644 index 5891bef7..00000000 --- a/examples/others/font_selector.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/others/image_formats_loading.c b/examples/others/image_formats_loading.c deleted file mode 100644 index 446f3f3e..00000000 --- a/examples/others/image_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/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/resources/formats/sonic.png b/examples/others/resources/formats/sonic.png Binary files differdeleted file mode 100644 index 7a096847..00000000 --- a/examples/others/resources/formats/sonic.png +++ /dev/null diff --git a/examples/others/resources/formats/sonic_A1R5G5B5.dds b/examples/others/resources/formats/sonic_A1R5G5B5.dds Binary files differdeleted file mode 100644 index 5e2347db..00000000 --- a/examples/others/resources/formats/sonic_A1R5G5B5.dds +++ /dev/null diff --git a/examples/others/resources/formats/sonic_A4R4G4B4.dds b/examples/others/resources/formats/sonic_A4R4G4B4.dds Binary files differdeleted file mode 100644 index c5ccaf0c..00000000 --- a/examples/others/resources/formats/sonic_A4R4G4B4.dds +++ /dev/null diff --git a/examples/others/resources/formats/sonic_A8R8G8B8.dds b/examples/others/resources/formats/sonic_A8R8G8B8.dds Binary files differdeleted file mode 100644 index fb71b7be..00000000 --- a/examples/others/resources/formats/sonic_A8R8G8B8.dds +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ASTC_4x4_ldr.astc b/examples/others/resources/formats/sonic_ASTC_4x4_ldr.astc Binary files differdeleted file mode 100644 index 9a98d9a0..00000000 --- a/examples/others/resources/formats/sonic_ASTC_4x4_ldr.astc +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ASTC_8x8_ldr.astc b/examples/others/resources/formats/sonic_ASTC_8x8_ldr.astc Binary files differdeleted file mode 100644 index 360a264a..00000000 --- a/examples/others/resources/formats/sonic_ASTC_8x8_ldr.astc +++ /dev/null diff --git a/examples/others/resources/formats/sonic_DXT1_RGB.dds b/examples/others/resources/formats/sonic_DXT1_RGB.dds Binary files differdeleted file mode 100644 index 9d0b4598..00000000 --- a/examples/others/resources/formats/sonic_DXT1_RGB.dds +++ /dev/null diff --git a/examples/others/resources/formats/sonic_DXT1_RGBA.dds b/examples/others/resources/formats/sonic_DXT1_RGBA.dds Binary files differdeleted file mode 100644 index 102bae7f..00000000 --- a/examples/others/resources/formats/sonic_DXT1_RGBA.dds +++ /dev/null diff --git a/examples/others/resources/formats/sonic_DXT3_RGBA.dds b/examples/others/resources/formats/sonic_DXT3_RGBA.dds Binary files differdeleted file mode 100644 index 46d965cb..00000000 --- a/examples/others/resources/formats/sonic_DXT3_RGBA.dds +++ /dev/null diff --git a/examples/others/resources/formats/sonic_DXT5_RGBA.dds b/examples/others/resources/formats/sonic_DXT5_RGBA.dds Binary files differdeleted file mode 100644 index b3a59a79..00000000 --- a/examples/others/resources/formats/sonic_DXT5_RGBA.dds +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ETC1_RGB.ktx b/examples/others/resources/formats/sonic_ETC1_RGB.ktx Binary files differdeleted file mode 100644 index 66241b9d..00000000 --- a/examples/others/resources/formats/sonic_ETC1_RGB.ktx +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ETC1_RGB.pkm b/examples/others/resources/formats/sonic_ETC1_RGB.pkm Binary files differdeleted file mode 100644 index c6fc6df4..00000000 --- a/examples/others/resources/formats/sonic_ETC1_RGB.pkm +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.ktx b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.ktx Binary files differdeleted file mode 100644 index b01812cb..00000000 --- a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.ktx +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.old.pkm b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.old.pkm Binary files differdeleted file mode 100644 index 61ac48ce..00000000 --- a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.old.pkm +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.pkm b/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.pkm Binary files differdeleted file mode 100644 index 61ac48ce..00000000 --- a/examples/others/resources/formats/sonic_ETC2_EAC_RGBA.pkm +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ETC2_RGB.ktx b/examples/others/resources/formats/sonic_ETC2_RGB.ktx Binary files differdeleted file mode 100644 index 7f1207f7..00000000 --- a/examples/others/resources/formats/sonic_ETC2_RGB.ktx +++ /dev/null diff --git a/examples/others/resources/formats/sonic_ETC2_RGB.pkm b/examples/others/resources/formats/sonic_ETC2_RGB.pkm Binary files differdeleted file mode 100644 index f290f019..00000000 --- a/examples/others/resources/formats/sonic_ETC2_RGB.pkm +++ /dev/null diff --git a/examples/others/resources/formats/sonic_GRAYSCALE.pvr b/examples/others/resources/formats/sonic_GRAYSCALE.pvr Binary files differdeleted file mode 100644 index d31e2651..00000000 --- a/examples/others/resources/formats/sonic_GRAYSCALE.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_L8A8.pvr b/examples/others/resources/formats/sonic_L8A8.pvr Binary files differdeleted file mode 100644 index ccf5932e..00000000 --- a/examples/others/resources/formats/sonic_L8A8.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_PVRT_RGB.pvr b/examples/others/resources/formats/sonic_PVRT_RGB.pvr Binary files differdeleted file mode 100644 index 22f3f66a..00000000 --- a/examples/others/resources/formats/sonic_PVRT_RGB.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_PVRT_RGBA.pvr b/examples/others/resources/formats/sonic_PVRT_RGBA.pvr Binary files differdeleted file mode 100644 index feb9aeaf..00000000 --- a/examples/others/resources/formats/sonic_PVRT_RGBA.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_PVRT_RGBA_2bpp.pvr b/examples/others/resources/formats/sonic_PVRT_RGBA_2bpp.pvr Binary files differdeleted file mode 100644 index 9147e1bb..00000000 --- a/examples/others/resources/formats/sonic_PVRT_RGBA_2bpp.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_PVRT_RGB_2bpp.pvr b/examples/others/resources/formats/sonic_PVRT_RGB_2bpp.pvr Binary files differdeleted file mode 100644 index 2a8aea8c..00000000 --- a/examples/others/resources/formats/sonic_PVRT_RGB_2bpp.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_R4G4B4A4.pvr b/examples/others/resources/formats/sonic_R4G4B4A4.pvr Binary files differdeleted file mode 100644 index 3f7368a3..00000000 --- a/examples/others/resources/formats/sonic_R4G4B4A4.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_R5G5B5A1.pvr b/examples/others/resources/formats/sonic_R5G5B5A1.pvr Binary files differdeleted file mode 100644 index c7fa098d..00000000 --- a/examples/others/resources/formats/sonic_R5G5B5A1.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_R5G6B5.dds b/examples/others/resources/formats/sonic_R5G6B5.dds Binary files differdeleted file mode 100644 index 217da954..00000000 --- a/examples/others/resources/formats/sonic_R5G6B5.dds +++ /dev/null diff --git a/examples/others/resources/formats/sonic_R5G6B5.pvr b/examples/others/resources/formats/sonic_R5G6B5.pvr Binary files differdeleted file mode 100644 index 9bb8320e..00000000 --- a/examples/others/resources/formats/sonic_R5G6B5.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_R8G8B8.pvr b/examples/others/resources/formats/sonic_R8G8B8.pvr Binary files differdeleted file mode 100644 index 072cf3ef..00000000 --- a/examples/others/resources/formats/sonic_R8G8B8.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_R8G8B8A8.pvr b/examples/others/resources/formats/sonic_R8G8B8A8.pvr Binary files differdeleted file mode 100644 index f82534f9..00000000 --- a/examples/others/resources/formats/sonic_R8G8B8A8.pvr +++ /dev/null diff --git a/examples/others/resources/formats/sonic_R8G8B8A8.raw b/examples/others/resources/formats/sonic_R8G8B8A8.raw Binary files differdeleted file mode 100644 index fc5858e7..00000000 --- a/examples/others/resources/formats/sonic_R8G8B8A8.raw +++ /dev/null diff --git a/examples/physac/physics_demo.c b/examples/physac/physics_demo.c index b12ac708..1b54d51b 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() { @@ -26,7 +28,6 @@ int main() SetConfigFlags(FLAG_MSAA_4X_HINT); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics demo"); - SetTargetFPS(60); // Physac logo drawing position int logoX = screenWidth - MeasureText("Physac", 30) - 10; @@ -42,6 +43,8 @@ int main() // Create obstacle circle physics body PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10); circle->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop @@ -118,8 +121,10 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- ClosePhysics(); // Unitialize physics + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } + diff --git a/examples/physac/physics_friction.c b/examples/physac/physics_friction.c index db1b5f4c..9472729a 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() { @@ -26,7 +28,6 @@ int main() SetConfigFlags(FLAG_MSAA_4X_HINT); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics friction"); - SetTargetFPS(60); // Physac logo drawing position int logoX = screenWidth - MeasureText("Physac", 30) - 10; @@ -61,6 +62,8 @@ int main() bodyB->staticFriction = 1; bodyB->dynamicFriction = 1; SetPhysicsBodyRotation(bodyB, 330*DEG2RAD); + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop @@ -132,8 +135,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..4b2c9ab0 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() { @@ -28,7 +30,6 @@ int main() SetConfigFlags(FLAG_MSAA_4X_HINT); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics movement"); - SetTargetFPS(60); // Physac logo drawing position int logoX = screenWidth - MeasureText("Physac", 30) - 10; @@ -54,6 +55,8 @@ int main() // Create movement physics body PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight/2 }, 50, 50, 1); body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop @@ -118,8 +121,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..2be8f42e 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() { @@ -26,7 +28,6 @@ int main() SetConfigFlags(FLAG_MSAA_4X_HINT); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics restitution"); - SetTargetFPS(60); // Physac logo drawing position int logoX = screenWidth - MeasureText("Physac", 30) - 10; @@ -47,6 +48,8 @@ int main() circleB->restitution = 0.5f; PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/2 }, 30, 10); circleC->restitution = 1; + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop @@ -111,8 +114,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..6b474cd3 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() { @@ -26,7 +28,6 @@ int main() SetConfigFlags(FLAG_MSAA_4X_HINT); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Body shatter"); - SetTargetFPS(60); // Physac logo drawing position int logoX = screenWidth - MeasureText("Physac", 30) - 10; @@ -38,6 +39,8 @@ int main() // Create random polygon physics body to shatter PhysicsBody body = CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); + + SetTargetFPS(60); //-------------------------------------------------------------------------------------- // Main game loop @@ -103,8 +106,10 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- ClosePhysics(); // Unitialize physics + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } + diff --git a/examples/shaders/resources/fudesumi.png b/examples/shaders/resources/fudesumi.png Binary files differindex 8ba983dc..9d9038fa 100644 --- a/examples/shaders/resources/fudesumi.png +++ b/examples/shaders/resources/fudesumi.png 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/text/text_ttf_loading.c b/examples/text/text_ttf_loading.c index 4e490399..02b7f95f 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/KAISG.ttf", 96, 0, 0); + SpriteFont font = LoadSpriteFontEx("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 @@ -82,7 +82,7 @@ int main() if (count == 1) // Only support one ttf file dropped { UnloadSpriteFont(font); - font = LoadSpriteFontTTF(droppedFiles[0], fontSize, 0, 0); + font = LoadSpriteFontEx(droppedFiles[0], fontSize, 0, 0); ClearDroppedFiles(); } } diff --git a/examples/textures/resources/fudesumi.png b/examples/textures/resources/fudesumi.png Binary files differindex 8ba983dc..9d9038fa 100644 --- a/examples/textures/resources/fudesumi.png +++ b/examples/textures/resources/fudesumi.png diff --git a/examples/textures/resources/fudesumi.raw b/examples/textures/resources/fudesumi.raw Binary files differindex e05fa0e1..dad6ff0a 100644 --- a/examples/textures/resources/fudesumi.raw +++ b/examples/textures/resources/fudesumi.raw diff --git a/examples/textures/resources/scarfy.png b/examples/textures/resources/scarfy.png Binary files differindex a377a712..beb5ffa0 100644 --- a/examples/textures/resources/scarfy.png +++ b/examples/textures/resources/scarfy.png 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 |
