From ca5f7ebd102656f8451a4cf99638bb94c9d00264 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 29 Apr 2018 11:37:39 +0200 Subject: Added compile flag: SUPPORT_SCREEN_CAPTURE Allow compiling the library with support for automatic screen capture (KEY_F12) --- src/core.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 7772027b..86b7b8b4 100644 --- a/src/core.c +++ b/src/core.c @@ -50,6 +50,9 @@ * #define SUPPORT_BUSY_WAIT_LOOP * Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used * +* #define SUPPORT_SCREEN_CAPTURE +* Allow automatic screen capture of current screen pressing F12, defined in KeyCallback() +* * #define SUPPORT_GIF_RECORDING * Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback() * @@ -2791,10 +2794,12 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i } else #endif // SUPPORT_GIF_RECORDING + #if defined(SUPPORT_SCREEN_CAPTURE) { TakeScreenshot(FormatText("screenshot%03i.png", screenshotCounter)); screenshotCounter++; } + #endif // SUPPORT_SCREEN_CAPTURE } #endif // PLATFORM_DESKTOP else @@ -3456,12 +3461,14 @@ static void ProcessKeyboard(void) // Check exit key (same functionality as GLFW3 KeyCallback()) if (currentKeyState[exitKey] == 1) windowShouldClose = true; +#if defined(SUPPORT_SCREEN_CAPTURE) // Check screen capture key (raylib key: KEY_F12) if (currentKeyState[301] == 1) { TakeScreenshot(FormatText("screenshot%03i.png", screenshotCounter)); screenshotCounter++; } +#endif } // Restore default keyboard input -- cgit v1.2.3 From ada6668b2458f0e58e588611b2e0d70a90970827 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 29 Apr 2018 11:49:10 +0200 Subject: Expose file-dropping functions symbols --- src/core.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 86b7b8b4..d1ef6522 100644 --- a/src/core.c +++ b/src/core.c @@ -84,9 +84,8 @@ * **********************************************************************************************/ -#include "config.h" - -#include "raylib.h" +#include "config.h" // Defines module configuration flags +#include "raylib.h" // Declares module functions #if (defined(__linux__) || defined(PLATFORM_WEB)) && _POSIX_C_SOURCE < 199309L #undef _POSIX_C_SOURCE @@ -96,8 +95,8 @@ #define RAYMATH_IMPLEMENTATION // Define external out-of-line implementation of raymath here #include "raymath.h" // Required for: Vector3 and Matrix functions -#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 -#include "utils.h" // Required for: fopen() Android mapping +#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2 +#include "utils.h" // Required for: fopen() Android mapping #if defined(SUPPORT_GESTURES_SYSTEM) #define GESTURES_IMPLEMENTATION @@ -111,7 +110,7 @@ #if defined(SUPPORT_GIF_RECORDING) #define RGIF_IMPLEMENTATION - #include "external/rgif.h" // Support GIF recording + #include "external/rgif.h" // Support GIF recording #endif #include // Standard input / output lib @@ -295,8 +294,6 @@ static bool cursorHidden = false; // Track if cursor is hidden static bool cursorOnScreen = false; // Tracks if cursor is inside client area #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP) -static int screenshotCounter = 0; // Screenshots counter - // Register mouse states static char previousMouseState[3] = { 0 }; // Registers previous mouse button state static char currentMouseState[3] = { 0 }; // Registers current mouse button state @@ -345,9 +342,13 @@ static double targetTime = 0.0; // Desired time for one frame, if 0 static unsigned char configFlags = 0; // Configuration flags (bit based) static bool showLogo = false; // Track if showing logo at init is enabled +#if defined(SUPPORT_SCREEN_CAPTURE) +static int screenshotCounter = 0; // Screenshots counter +#endif + #if defined(SUPPORT_GIF_RECORDING) -static int gifFramesCounter = 0; -static bool gifRecording = false; +static int gifFramesCounter = 0; // GIF frames counter +static bool gifRecording = false; // GIF recording state #endif //---------------------------------------------------------------------------------- @@ -748,7 +749,6 @@ void SetWindowSize(int width, int height) #endif } - // Get current screen width int GetScreenWidth(void) { @@ -1376,24 +1376,32 @@ bool ChangeDirectory(const char *dir) return (CHDIR(dir) == 0); } -#if defined(PLATFORM_DESKTOP) // Check if a file has been dropped into window bool IsFileDropped(void) { +#if defined(PLATFORM_DESKTOP) if (dropFilesCount > 0) return true; else return false; +#else + return false; +#endif } // Get dropped files names char **GetDroppedFiles(int *count) { +#if defined(PLATFORM_DESKTOP) *count = dropFilesCount; return dropFilesPath; +#else + return NULL; +#endif } // Clear dropped files paths buffer void ClearDroppedFiles(void) { +#if defined(PLATFORM_DESKTOP) if (dropFilesCount > 0) { for (int i = 0; i < dropFilesCount; i++) free(dropFilesPath[i]); @@ -1402,8 +1410,8 @@ void ClearDroppedFiles(void) dropFilesCount = 0; } -} #endif +} // Save integer value to storage file (to defined position) // NOTE: Storage positions is directly related to file memory layout (4 bytes each integer) -- cgit v1.2.3 From dff10284666ad30823fa88ec57d0ae8eac7e7fad Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 29 Apr 2018 18:39:46 +0200 Subject: Replaced ColorToFloat() by ColorNormalize() --- src/core.c | 26 +++++++++++++------------- src/raylib.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index d1ef6522..3f071fc6 100644 --- a/src/core.c +++ b/src/core.c @@ -1156,25 +1156,25 @@ double GetTime(void) #endif } -// Returns normalized float array for a Color -float *ColorToFloat(Color color) -{ - static float buffer[4]; - - buffer[0] = (float)color.r/255; - buffer[1] = (float)color.g/255; - buffer[2] = (float)color.b/255; - buffer[3] = (float)color.a/255; - - return buffer; -} - // Returns hexadecimal value for a Color int ColorToInt(Color color) { return (((int)color.r << 24) | ((int)color.g << 16) | ((int)color.b << 8) | (int)color.a); } +// Returns color normalized as float [0..1] +Vector4 ColorNormalize(Color color) +{ + Vector4 result; + + result.x = (float)color.r/255.0f; + result.y = (float)color.g/255.0f; + result.z = (float)color.b/255.0f; + result.w = (float)color.a/255.0f; + + return result; +} + // Returns HSV values for a Color // NOTE: Hue is returned as degrees [0..360] Vector3 ColorToHSV(Color color) diff --git a/src/raylib.h b/src/raylib.h index 4315afc5..b03a93f3 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -745,8 +745,8 @@ RLAPI float GetFrameTime(void); // Returns tim RLAPI double GetTime(void); // Returns elapsed time in seconds since InitWindow() // Color-related functions -RLAPI float *ColorToFloat(Color color); // Returns normalized float array for a Color RLAPI int ColorToInt(Color color); // Returns hexadecimal value for a Color +RLAPI Vector4 ColorNormalize(Color color); // Returns color normalized as float [0..1] RLAPI Vector3 ColorToHSV(Color color); // Returns HSV values for a Color RLAPI Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value RLAPI Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f -- cgit v1.2.3 From 6045062a05a0cc5bd654ad2c2e7d88f94579cd73 Mon Sep 17 00:00:00 2001 From: Ray San Date: Fri, 4 May 2018 16:54:05 +0200 Subject: Renamed some functions - Renamed Begin3dMode() --> BeginMode3D() - Renamed Begin2dMode() --> BeginMode2D() - Renamed End3dMode() --> EndMode3D() - Renamed End2dMode() --> EndMode2D() --- examples/core/core_2d_camera.c | 4 ++-- examples/core/core_3d_camera_first_person.c | 4 ++-- examples/core/core_3d_camera_free.c | 4 ++-- examples/core/core_3d_mode.c | 4 ++-- examples/core/core_3d_picking.c | 4 ++-- examples/core/core_vr_simulator.c | 4 ++-- examples/core/core_world_screen.c | 4 ++-- examples/models/models_billboard.c | 4 ++-- examples/models/models_box_collisions.c | 4 ++-- examples/models/models_cubicmap.c | 4 ++-- examples/models/models_geometric_shapes.c | 4 ++-- examples/models/models_heightmap.c | 4 ++-- examples/models/models_material_pbr.c | 4 ++-- examples/models/models_mesh_generation.c | 4 ++-- examples/models/models_mesh_picking.c | 4 ++-- examples/models/models_obj_loading.c | 4 ++-- examples/models/models_orthographic_projection.c | 4 ++-- examples/models/models_skybox.c | 4 ++-- examples/models/models_yaw_pitch_roll.c | 4 ++-- examples/others/oculus_rift.c | 4 ++-- examples/others/standard_lighting.c | 4 ++-- examples/shaders/shaders_custom_uniform.c | 4 ++-- examples/shaders/shaders_model_shader.c | 4 ++-- examples/shaders/shaders_postprocessing.c | 4 ++-- src/core.c | 12 ++++++------ src/raylib.h | 10 +++++----- src/rlgl.c | 2 +- 27 files changed, 60 insertions(+), 60 deletions(-) (limited to 'src/core.c') 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 a583e706..81f04c13 100644 --- a/examples/core/core_3d_camera_free.c +++ b/examples/core/core_3d_camera_free.c @@ -50,14 +50,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 a94ec648..705bcb7a 100644 --- a/examples/core/core_3d_mode.c +++ b/examples/core/core_3d_mode.c @@ -46,14 +46,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..cd390d91 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -63,7 +63,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); if (collision) { @@ -81,7 +81,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_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 ee13fddf..33f13e2c 100644 --- a/examples/models/models_material_pbr.c +++ b/examples/models/models_material_pbr.c @@ -73,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); 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..17b8812d 100644 --- a/examples/models/models_mesh_picking.c +++ b/examples/models/models_mesh_picking.c @@ -120,7 +120,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); // Draw the tower DrawModel(tower, towerPos, 1.0, WHITE); @@ -151,7 +151,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..4e9b2986 100644 --- a/examples/models/models_obj_loading.c +++ b/examples/models/models_obj_loading.c @@ -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/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/src/core.c b/src/core.c index 3f071fc6..5587f82b 100644 --- a/src/core.c +++ b/src/core.c @@ -117,7 +117,7 @@ #include // Required for: malloc(), free(), rand(), atexit() #include // Required for: typedef unsigned long long int uint64_t, used by hi-res timer #include // Required for: time() - Android/RPI hi-res timer (NOTE: Linux only!) -#include // Required for: tan() [Used in Begin3dMode() to set perspective] +#include // Required for: tan() [Used in BeginMode3D() to set perspective] #include // Required for: strrchr(), strcmp() //#include // Macros for reporting and retrieving error conditions through error codes #include // Required for: tolower() [Used in IsFileExtension()] @@ -888,7 +888,7 @@ void EndDrawing(void) } // Initialize 2D mode with custom camera (2D) -void Begin2dMode(Camera2D camera) +void BeginMode2D(Camera2D camera) { rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) @@ -906,7 +906,7 @@ void Begin2dMode(Camera2D camera) } // Ends 2D mode with custom camera -void End2dMode(void) +void EndMode2D(void) { rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) @@ -914,7 +914,7 @@ void End2dMode(void) } // Initializes 3D mode with custom camera (3D) -void Begin3dMode(Camera camera) +void BeginMode3D(Camera3D camera) { rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) @@ -954,7 +954,7 @@ void Begin3dMode(Camera camera) } // Ends 3D mode and returns to default 2D orthographic mode -void End3dMode(void) +void EndMode3D(void) { rlglDraw(); // Process internal buffers (update + draw) @@ -2912,7 +2912,7 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height) rlLoadIdentity(); // Reset current matrix (MODELVIEW) rlClearScreenBuffers(); // Clear screen buffers (color and depth) - // Window size must be updated to be used on 3D mode to get new aspect ratio (Begin3dMode()) + // Window size must be updated to be used on 3D mode to get new aspect ratio (BeginMode3D()) // NOTE: Be careful! GLFW3 will choose the closest fullscreen resolution supported by current monitor, // for example, if reescaling back to 800x450 (desired), it could set 720x480 (closest fullscreen supported) screenWidth = width; diff --git a/src/raylib.h b/src/raylib.h index 6d3aaaf9..b5a6a191 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -6,7 +6,7 @@ * - Written in plain C code (C99) in PascalCase/camelCase notation * - Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2 - choose at compile) * - Unique OpenGL abstraction layer (usable as standalone module): [rlgl] -* - Powerful fonts module with SpriteFonts support (XNA fonts, AngelCode fonts, TTF) +* - Powerful fonts module with Fonts support (XNA fonts, AngelCode fonts, TTF) * - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC) * - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more! * - Flexible Materials system, supporting classic maps and PBR maps @@ -728,10 +728,10 @@ RLAPI void DisableCursor(void); // Disables cu RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color) RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) -RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D) -RLAPI void End2dMode(void); // Ends 2D mode with custom camera -RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D) -RLAPI void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode +RLAPI void BeginMode2D(Camera2D camera); // Initialize 2D mode with custom camera (2D) +RLAPI void EndMode2D(void); // Ends 2D mode with custom camera +RLAPI void BeginMode3D(Camera3D camera); // Initializes 3D mode with custom camera (3D) +RLAPI void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing RLAPI void EndTextureMode(void); // Ends drawing to render texture diff --git a/src/rlgl.c b/src/rlgl.c index 68bd3670..93a0b0f8 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1947,7 +1947,7 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform) if (material.shader.locs[LOC_MATRIX_PROJECTION] != -1) SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_PROJECTION], projection); // At this point the modelview matrix just contains the view matrix (camera) - // That's because Begin3dMode() sets it an no model-drawing function modifies it, all use rlPushMatrix() and rlPopMatrix() + // That's because BeginMode3D() sets it an no model-drawing function modifies it, all use rlPushMatrix() and rlPopMatrix() Matrix matView = modelview; // View matrix (camera) Matrix matProjection = projection; // Projection matrix (perspective) -- cgit v1.2.3 From f14492432d590cef90cb747a2063f6998a61f108 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 4 May 2018 23:03:56 +0200 Subject: Avoid exposing native GLFW3 functionality Try to avoid types conflict with Font --- src/core.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index 5587f82b..ece76138 100644 --- a/src/core.c +++ b/src/core.c @@ -141,13 +141,7 @@ #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) //#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3 #include // GLFW3 library: Windows, OpenGL context and Input management - - #if defined(__linux__) - #define GLFW_EXPOSE_NATIVE_X11 // Linux specific definitions for getting - #define GLFW_EXPOSE_NATIVE_GLX // native functions like glfwGetX11Window - #include // which are required for hiding mouse - #endif - //#include // OpenGL functions (GLFW3 already includes gl.h) + // NOTE: GLFW3 already includes gl.h (OpenGL) headers #if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32) // NOTE: Those functions require linking with winmm library -- cgit v1.2.3 From 1d3e4ef437bc7e8e0bdd9607370f0cce85e9f150 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 17 May 2018 00:04:12 +0200 Subject: Corrected issue on file extension check --- src/core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index ece76138..cae9a1c8 100644 --- a/src/core.c +++ b/src/core.c @@ -1310,6 +1310,7 @@ bool IsFileExtension(const char *fileName, const char *ext) } } } + else result = false; #else if (strcmp(fileExt, ext) == 0) result = true; #endif -- cgit v1.2.3 From 0b05169aa74e7c298f44e214f2cf5aeed82f11cb Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 17 May 2018 00:58:58 +0200 Subject: Some warnings review --- src/core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core.c') diff --git a/src/core.c b/src/core.c index cae9a1c8..5cd9bfd4 100644 --- a/src/core.c +++ b/src/core.c @@ -1026,7 +1026,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera) // Calculate view matrix from camera look at Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up); - Matrix matProj; + Matrix matProj = MatrixIdentity(); if (camera.type == CAMERA_PERSPECTIVE) { @@ -1038,6 +1038,7 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera) float aspect = (float)screenWidth/(float)screenHeight; double top = camera.fovy/2.0; double right = top*aspect; + // Calculate projection matrix from orthographic matProj = MatrixOrtho(-right, right, -top, top, 0.01, 1000.0); } @@ -1067,18 +1068,19 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera) Vector2 GetWorldToScreen(Vector3 position, Camera camera) { // Calculate projection matrix (from perspective instead of frustum - Matrix matProj; + Matrix matProj = MatrixIdentity(); - if(camera.type == CAMERA_PERSPECTIVE) + if (camera.type == CAMERA_PERSPECTIVE) { // Calculate projection matrix from perspective matProj = MatrixPerspective(camera.fovy*DEG2RAD, ((double)GetScreenWidth()/(double)GetScreenHeight()), 0.01, 1000.0); } - else if(camera.type == CAMERA_ORTHOGRAPHIC) + else if (camera.type == CAMERA_ORTHOGRAPHIC) { float aspect = (float)screenWidth/(float)screenHeight; double top = camera.fovy/2.0; double right = top*aspect; + // Calculate projection matrix from orthographic matProj = MatrixOrtho(-right, right, -top, top, 0.01, 1000.0); } -- cgit v1.2.3