diff options
Diffstat (limited to 'examples')
37 files changed, 136 insertions, 117 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1f05d529..fd65a74b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(examples) -include("../utils.cmake") +include("../cmake/utils.cmake") # Make sure raylib has been built # TODO `build` directory should maybe be something else... @@ -40,6 +40,29 @@ if(NOT HAVE_OCULUS_CAPI) endif() list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/standard_lighting.c) +if(${PLATFORM} MATCHES "Android") + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/others/rlgl_standalone.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_picking.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_vr_simulator.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_free.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_3d_camera_first_person.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/core/core_world_screen.c) + + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_material_pbr.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_cubicmap.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_skybox.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_picking.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_mesh_generation.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_heightmap.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/models/models_billboard.c) + + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_custom_uniform.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_model_shader.c) + list(REMOVE_ITEM example_sources ${CMAKE_CURRENT_SOURCE_DIR}/shaders/shaders_postprocessing.c) + +endif() + # Do each example foreach(example_source ${example_sources}) diff --git a/examples/Makefile b/examples/Makefile index becb91dc..64cec3d1 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -25,7 +25,7 @@ # Define required raylib variables PROJECT_NAME ?= raylib_examples -RAYLIB_VERSION ?= 1.9.7 +RAYLIB_VERSION ?= 2.0.0 RAYLIB_API_VERSION ?= 1 RAYLIB_PATH ?= .. @@ -207,7 +207,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # resources file contains windows exe icon # -Wl,--subsystem,windows hides the console window - CFLAGS += $(RAYLIB_PATH)/src/resources -Wl,--subsystem,windows + CFLAGS += $(RAYLIB_PATH)/src/raylib_icon -Wl,--subsystem,windows endif ifeq ($(PLATFORM_OS),LINUX) ifeq ($(RAYLIB_BUILD_MODE),DEBUG) @@ -215,7 +215,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) #CC = clang endif ifeq ($(RAYLIB_LIBTYPE),STATIC) - CFLAGS += -no-pie -D_DEFAULT_SOURCE + CFLAGS += -D_DEFAULT_SOURCE endif ifeq ($(RAYLIB_LIBTYPE),SHARED) # Explicitly enable runtime link to libraylib.so diff --git a/examples/core/core_2d_camera.c b/examples/core/core_2d_camera.c index f2f219ef..7c35c907 100644 --- a/examples/core/core_2d_camera.c +++ b/examples/core/core_2d_camera.c @@ -97,7 +97,7 @@ int main() ClearBackground(RAYWHITE); - Begin2dMode(camera); + BeginMode2D(camera); DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY); @@ -108,7 +108,7 @@ int main() DrawRectangle(camera.target.x, -500, 1, screenHeight*4, GREEN); DrawRectangle(-500, camera.target.y, screenWidth*4, 1, GREEN); - End2dMode(); + EndMode2D(); DrawText("SCREEN AREA", 640, 10, 20, RED); diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c index 775e6c57..d3a8f2e4 100644 --- a/examples/core/core_3d_camera_first_person.c +++ b/examples/core/core_3d_camera_first_person.c @@ -61,7 +61,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall @@ -75,7 +75,7 @@ int main() DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON); } - End3dMode(); + EndMode3D(); DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f)); DrawRectangleLines( 10, 10, 220, 70, BLUE); diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c index d446e14a..9131ddf8 100644 --- a/examples/core/core_3d_camera_free.c +++ b/examples/core/core_3d_camera_free.c @@ -21,11 +21,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); // Define the camera to look into our 3d world - Camera camera; + Camera3D camera; camera.position = (Vector3){ 10.0f, 10.0f, 10.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 + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; @@ -50,14 +51,14 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5f)); DrawRectangleLines( 10, 10, 320, 133, BLUE); diff --git a/examples/core/core_3d_mode.c b/examples/core/core_3d_mode.c index 5f761655..39c0752a 100644 --- a/examples/core/core_3d_mode.c +++ b/examples/core/core_3d_mode.c @@ -21,11 +21,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode"); // Define the camera to look into our 3d world - Camera camera; + Camera3D camera; camera.position = (Vector3){ 0.0f, 10.0f, 10.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 + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; @@ -46,14 +47,14 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY); diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c index 56e80f2a..1c63e2a7 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -26,6 +26,7 @@ int main() 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 + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; Vector3 cubeSize = { 2.0f, 2.0f, 2.0f }; @@ -63,7 +64,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); if (collision) { @@ -81,7 +82,7 @@ int main() DrawRay(ray, MAROON); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY); diff --git a/examples/core/core_input_keys.c b/examples/core/core_input_keys.c index b2305246..69384fd9 100644 --- a/examples/core/core_input_keys.c +++ b/examples/core/core_input_keys.c @@ -30,10 +30,10 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8f; - if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8f; - if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8f; - if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8f; + if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f; + if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f; + if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f; + if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f; //---------------------------------------------------------------------------------- // Draw diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c index d919c410..35136114 100644 --- a/examples/core/core_vr_simulator.c +++ b/examples/core/core_vr_simulator.c @@ -57,14 +57,14 @@ int main() BeginVrDrawing(); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(40, 1.0f); - End3dMode(); + EndMode3D(); EndVrDrawing(); diff --git a/examples/core/core_world_screen.c b/examples/core/core_world_screen.c index 78ca6eb4..460f6b85 100644 --- a/examples/core/core_world_screen.c +++ b/examples/core/core_world_screen.c @@ -54,14 +54,14 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawText("Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100 / 100", 20) / 2, cubeScreenPosition.y, 20, BLACK); DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2, 25, 20, GRAY); diff --git a/examples/models/models_billboard.c b/examples/models/models_billboard.c index 3b3efc47..8ce6a44f 100644 --- a/examples/models/models_billboard.c +++ b/examples/models/models_billboard.c @@ -51,13 +51,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawBillboard(camera, bill, billPosition, 2.0f, WHITE); DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawFPS(10, 10); diff --git a/examples/models/models_box_collisions.c b/examples/models/models_box_collisions.c index eb72c54c..41f6056c 100644 --- a/examples/models/models_box_collisions.c +++ b/examples/models/models_box_collisions.c @@ -87,7 +87,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); // Draw enemy-box DrawCube(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, GRAY); @@ -102,7 +102,7 @@ int main() DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("Move player with cursors to collide", 220, 40, 20, GRAY); diff --git a/examples/models/models_cubicmap.c b/examples/models/models_cubicmap.c index 47b88748..c8d62c46 100644 --- a/examples/models/models_cubicmap.c +++ b/examples/models/models_cubicmap.c @@ -56,11 +56,11 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(model, mapPosition, 1.0f, WHITE); - End3dMode(); + EndMode3D(); DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE); DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); diff --git a/examples/models/models_geometric_shapes.c b/examples/models/models_geometric_shapes.c index 7a1e7e48..82ca4c60 100644 --- a/examples/models/models_geometric_shapes.c +++ b/examples/models/models_geometric_shapes.c @@ -45,7 +45,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); @@ -63,7 +63,7 @@ int main() DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawFPS(10, 10); diff --git a/examples/models/models_heightmap.c b/examples/models/models_heightmap.c index 55474185..d131b127 100644 --- a/examples/models/models_heightmap.c +++ b/examples/models/models_heightmap.c @@ -53,13 +53,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(model, mapPosition, 1.0f, RED); DrawGrid(20, 1.0f); - End3dMode(); + EndMode3D(); DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE); DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN); diff --git a/examples/models/models_material_pbr.c b/examples/models/models_material_pbr.c index 4ad2c9e7..d50ef3da 100644 --- a/examples/models/models_material_pbr.c +++ b/examples/models/models_material_pbr.c @@ -38,6 +38,7 @@ int main() // Load model and PBR material Model model = LoadModel("resources/pbr/trooper.obj"); + MeshTangents(&model.mesh); model.material = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f); // Define lights attributes @@ -72,13 +73,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(model, Vector3Zero(), 1.0f, WHITE); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawFPS(10, 10); @@ -121,7 +122,7 @@ static Material LoadMaterialPBR(Color albedo, float metalness, float roughness) mat.shader.locs[LOC_MAP_BRDF] = GetShaderLocation(mat.shader, "brdfLUT"); // Set view matrix location - mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "mMatrix"); + mat.shader.locs[LOC_MATRIX_MODEL] = GetShaderLocation(mat.shader, "matModel"); mat.shader.locs[LOC_MATRIX_VIEW] = GetShaderLocation(mat.shader, "view"); mat.shader.locs[LOC_VECTOR_VIEW] = GetShaderLocation(mat.shader, "viewPos"); diff --git a/examples/models/models_mesh_generation.c b/examples/models/models_mesh_generation.c index d9c28ac2..c02bd91a 100644 --- a/examples/models/models_mesh_generation.c +++ b/examples/models/models_mesh_generation.c @@ -72,13 +72,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(models[currentModel], position, 1.0f, WHITE); DrawGrid(10, 1.0); - End3dMode(); + EndMode3D(); DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f)); DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f)); diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c index e09f9860..56b9397a 100644 --- a/examples/models/models_mesh_picking.c +++ b/examples/models/models_mesh_picking.c @@ -30,6 +30,7 @@ int main() 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 + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Ray ray; // Picking ray @@ -120,7 +121,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); // Draw the tower DrawModel(tower, towerPos, 1.0, WHITE); @@ -151,7 +152,7 @@ int main() DrawGrid(100, 1.0f); - End3dMode(); + EndMode3D(); // Draw some debug GUI text DrawText(FormatText("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK); diff --git a/examples/models/models_obj_loading.c b/examples/models/models_obj_loading.c index 4f89130f..45eb3e98 100644 --- a/examples/models/models_obj_loading.c +++ b/examples/models/models_obj_loading.c @@ -22,11 +22,11 @@ int main() // Define the camera to look into our 3d world Camera camera = { 0 }; - camera.position = (Vector3){ 3.0f, 3.0f, 3.0f }; - camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; + camera.position = (Vector3){ 3.0f, 3.0f, 3.0f }; // Camera position + camera.target = (Vector3){ 0.0f, 1.5f, 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 + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture @@ -50,7 +50,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture @@ -58,7 +58,7 @@ int main() DrawGizmo(position); // Draw gizmo - End3dMode(); + EndMode3D(); DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c index cb5ea053..f9b54b6d 100644 --- a/examples/models/models_orthographic_projection.c +++ b/examples/models/models_orthographic_projection.c @@ -57,7 +57,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); @@ -75,7 +75,7 @@ int main() DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, DARKGRAY); diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index 700824d3..589f139b 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -60,13 +60,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawFPS(10, 10); diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c index c559e67b..0dcf8c70 100644 --- a/examples/models/models_yaw_pitch_roll.c +++ b/examples/models/models_yaw_pitch_roll.c @@ -137,12 +137,12 @@ int main() EndTextureMode(); // Draw 3D model (recomended to draw 3D always before 2D) - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(model, (Vector3){ 0, 6.0f, 0 }, 1.0f, WHITE); // Draw 3d model with texture DrawGrid(10, 10.0f); - End3dMode(); + EndMode3D(); // Draw 2D GUI stuff DrawAngleGauge(texAngleGauge, 80, 70, roll, "roll", RED); diff --git a/examples/models/resources/shaders/pbr.vs b/examples/models/resources/shaders/pbr.vs index 885cb199..8bd3faa1 100644 --- a/examples/models/resources/shaders/pbr.vs +++ b/examples/models/resources/shaders/pbr.vs @@ -16,7 +16,7 @@ in vec4 vertexTangent; // Input uniform values uniform mat4 mvp; -uniform mat4 mMatrix; +uniform mat4 matModel; // Output vertex attributes (to fragment shader) out vec3 fragPosition; @@ -31,10 +31,10 @@ void main() vec3 vertexBinormal = cross(vertexNormal, vec3(vertexTangent)); // Calculate fragment normal based on normal transformations - mat3 normalMatrix = transpose(inverse(mat3(mMatrix))); + mat3 normalMatrix = transpose(inverse(mat3(matModel))); // Calculate fragment position based on model transformations - fragPosition = vec3(mMatrix*vec4(vertexPosition, 1.0f)); + fragPosition = vec3(matModel*vec4(vertexPosition, 1.0f)); // Send vertex attributes to fragment shader fragTexCoord = vertexTexCoord; diff --git a/examples/others/oculus_rift.c b/examples/others/oculus_rift.c index af2a87c1..cdfa5f11 100644 --- a/examples/others/oculus_rift.c +++ b/examples/others/oculus_rift.c @@ -151,14 +151,14 @@ int main() if (vrDeviceReady) BeginOculusDrawing(); else BeginVrDrawing(); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(40, 1.0f); - End3dMode(); + EndMode3D(); if (vrDeviceReady) EndOculusDrawing(); else EndVrDrawing(); diff --git a/examples/others/standard_lighting.c b/examples/others/standard_lighting.c index a7f634e2..f450a2a5 100644 --- a/examples/others/standard_lighting.c +++ b/examples/others/standard_lighting.c @@ -159,7 +159,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture @@ -169,7 +169,7 @@ int main() DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c index 4e160455..ddee4187 100644 --- a/examples/shaders/shaders_custom_uniform.c +++ b/examples/shaders/shaders_custom_uniform.c @@ -85,13 +85,13 @@ int main() BeginTextureMode(target); // Enable drawing to texture - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, RED); diff --git a/examples/shaders/shaders_model_shader.c b/examples/shaders/shaders_model_shader.c index 51acc836..3ce9c6a3 100644 --- a/examples/shaders/shaders_model_shader.c +++ b/examples/shaders/shaders_model_shader.c @@ -66,13 +66,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c index 5eeda896..80660d68 100644 --- a/examples/shaders/shaders_postprocessing.c +++ b/examples/shaders/shaders_postprocessing.c @@ -130,13 +130,13 @@ int main() BeginTextureMode(target); // Enable drawing to texture - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); EndTextureMode(); // End drawing to texture (now we have a texture available for next passes) diff --git a/examples/text/text_bmfont_ttf.c b/examples/text/text_bmfont_ttf.c index 0778fd11..f71f5ddb 100644 --- a/examples/text/text_bmfont_ttf.c +++ b/examples/text/text_bmfont_ttf.c @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raylib [text] example - BMFont and TTF SpriteFonts loading +* raylib [text] example - BMFont and TTF Fonts loading * * This example has been created using raylib 1.4 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) @@ -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/bmfont.fnt"); // BMFont (AngelCode) - SpriteFont fontTtf = LoadSpriteFont("resources/pixantiqua.ttf"); // TTF font + Font fontBm = LoadFont("resources/bmfont.fnt"); // BMFont (AngelCode) + Font fontTtf = LoadFont("resources/pixantiqua.ttf"); // TTF font Vector2 fontPosition; @@ -58,8 +58,8 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadSpriteFont(fontBm); // AngelCode SpriteFont unloading - UnloadSpriteFont(fontTtf); // TTF SpriteFont unloading + UnloadFont(fontBm); // AngelCode Font unloading + UnloadFont(fontTtf); // TTF Font unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/text/text_bmfont_unordered.c b/examples/text/text_bmfont_unordered.c index 01561bec..a5147619 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/pixantiqua.fnt"); // BMFont (AngelCode) + Font font = LoadFont("resources/pixantiqua.fnt"); // BMFont (AngelCode) SetTargetFPS(60); //-------------------------------------------------------------------------------------- @@ -56,7 +56,7 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadSpriteFont(font); // AngelCode SpriteFont unloading + UnloadFont(font); // AngelCode Font unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/text/text_raylib_fonts.c b/examples/text/text_raylib_fonts.c index 6d8ef2b6..3c930ac2 100644 --- a/examples/text/text_raylib_fonts.c +++ b/examples/text/text_raylib_fonts.c @@ -26,16 +26,16 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - SpriteFont fonts[MAX_FONTS]; + Font 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"); + fonts[0] = LoadFont("resources/fonts/alagard.png"); + fonts[1] = LoadFont("resources/fonts/pixelplay.png"); + fonts[2] = LoadFont("resources/fonts/mecha.png"); + fonts[3] = LoadFont("resources/fonts/setback.png"); + fonts[4] = LoadFont("resources/fonts/romulus.png"); + fonts[5] = LoadFont("resources/fonts/pixantiqua.png"); + fonts[6] = LoadFont("resources/fonts/alpha_beta.png"); + fonts[7] = LoadFont("resources/fonts/jupiter_crash.png"); const char *messages[MAX_FONTS] = { "ALAGARD FONT designed by Hewett Tsoi", "PIXELPLAY FONT designed by Aleksander Shevchuk", @@ -93,8 +93,8 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - // SpriteFonts unloading - for (int i = 0; i < MAX_FONTS; i++) UnloadSpriteFont(fonts[i]); + // Fonts unloading + for (int i = 0; i < MAX_FONTS; i++) UnloadFont(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 aefbfd1f..7ce2fef5 100644 --- a/examples/text/text_sprite_fonts.c +++ b/examples/text/text_sprite_fonts.c @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raylib [text] example - SpriteFont loading and usage +* raylib [text] example - Font loading and usage * * This example has been created using raylib 1.0 (www.raylib.com) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) @@ -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/custom_mecha.png"); // SpriteFont loading - SpriteFont font2 = LoadSpriteFont("resources/custom_alagard.png"); // SpriteFont loading - SpriteFont font3 = LoadSpriteFont("resources/custom_jupiter_crash.png"); // SpriteFont loading + Font font1 = LoadFont("resources/custom_mecha.png"); // Font loading + Font font2 = LoadFont("resources/custom_alagard.png"); // Font loading + Font font3 = LoadFont("resources/custom_jupiter_crash.png"); // Font loading Vector2 fontPosition1, fontPosition2, fontPosition3; @@ -66,9 +66,9 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- - UnloadSpriteFont(font1); // SpriteFont unloading - UnloadSpriteFont(font2); // SpriteFont unloading - UnloadSpriteFont(font3); // SpriteFont unloading + UnloadFont(font1); // Font unloading + UnloadFont(font2); // Font unloading + UnloadFont(font3); // Font unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/text/text_ttf_loading.c b/examples/text/text_ttf_loading.c index fedfbfb8..42fb58bf 100644 --- a/examples/text/text_ttf_loading.c +++ b/examples/text/text_ttf_loading.c @@ -20,12 +20,12 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading"); - const char msg[50] = "TTF SpriteFont"; + const char msg[50] = "TTF Font"; // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) - // TTF SpriteFont loading with custom generation parameters - SpriteFont font = LoadSpriteFontEx("resources/KAISG.ttf", 96, 0, 0); + // TTF Font loading with custom generation parameters + Font font = LoadFontEx("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 @@ -85,8 +85,8 @@ int main() if (count == 1) // Only support one ttf file dropped { - UnloadSpriteFont(font); - font = LoadSpriteFontEx(droppedFiles[0], fontSize, 0, 0); + UnloadFont(font); + font = LoadFontEx(droppedFiles[0], fontSize, 0, 0); ClearDroppedFiles(); } } @@ -127,7 +127,7 @@ int main() #if defined(PLATFORM_DESKTOP) ClearDroppedFiles(); // Clear internal buffers #endif - UnloadSpriteFont(font); // SpriteFont unloading + UnloadFont(font); // Font unloading CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- diff --git a/examples/textures/textures_image_drawing.c b/examples/textures/textures_image_drawing.c index ac128af9..b179612d 100644 --- a/examples/textures/textures_image_drawing.c +++ b/examples/textures/textures_image_drawing.c @@ -38,12 +38,12 @@ int main() UnloadImage(cat); // Unload image from RAM // Load custom font for frawing on image - SpriteFont font = LoadSpriteFont("resources/custom_jupiter_crash.png"); + Font font = LoadFont("resources/custom_jupiter_crash.png"); // Draw over image using custom font ImageDrawTextEx(&parrots, (Vector2){ 300, 230 }, font, "PARROTS & CAT", font.baseSize, -2, WHITE); - UnloadSpriteFont(font); // Unload custom spritefont (already drawn used on image) + UnloadFont(font); // Unload custom spritefont (already drawn used on image) Texture2D texture = LoadTextureFromImage(parrots); // Image converted to texture, uploaded to GPU memory (VRAM) UnloadImage(parrots); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM diff --git a/examples/textures/textures_image_generation.c b/examples/textures/textures_image_generation.c index 790c34f1..b9608c89 100644 --- a/examples/textures/textures_image_generation.c +++ b/examples/textures/textures_image_generation.c @@ -58,7 +58,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_RIGHT)) { currentTexture = (currentTexture + 1)%NUM_TEXTURES; // Cycle between the textures } diff --git a/examples/textures/textures_image_processing.c b/examples/textures/textures_image_processing.c index 58b746e0..427faa60 100644 --- a/examples/textures/textures_image_processing.c +++ b/examples/textures/textures_image_processing.c @@ -51,7 +51,7 @@ int main() // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) Image image = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM) - ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update) + ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update) <-- ISSUE Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) int currentProcess = NONE; @@ -121,18 +121,9 @@ int main() // Draw rectangles for (int i = 0; i < NUM_PROCESSES; i++) { - if (i == currentProcess) - { - DrawRectangleRec(selectRecs[i], SKYBLUE); - DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE); - DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKBLUE); - } - else - { - DrawRectangleRec(selectRecs[i], LIGHTGRAY); - DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY); - DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKGRAY); - } + DrawRectangleRec(selectRecs[i], (i == currentProcess) ? SKYBLUE : LIGHTGRAY); + DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, (i == currentProcess) ? BLUE : GRAY); + DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, (i == currentProcess) ? DARKBLUE : DARKGRAY); } DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE); diff --git a/examples/textures/textures_image_text.c b/examples/textures/textures_image_text.c index 1d4231f7..0a939b8d 100644 --- a/examples/textures/textures_image_text.c +++ b/examples/textures/textures_image_text.c @@ -20,8 +20,8 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing"); - // TTF SpriteFont loading with custom generation parameters - SpriteFont font = LoadSpriteFontEx("resources/KAISG.ttf", 64, 0, 0); + // TTF Font loading with custom generation parameters + Font font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0); Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM) @@ -74,7 +74,7 @@ int main() //-------------------------------------------------------------------------------------- UnloadTexture(texture); // Texture unloading - UnloadSpriteFont(font); // Unload custom spritefont + UnloadFont(font); // Unload custom spritefont CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- |
