From c35c531551a6bf1d6b9cf41d8837231c4d942f8d Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:34:17 -0300 Subject: [PATCH 01/23] Fix SetWindowIcon() for SDL (#3578) --- src/platforms/rcore_desktop_sdl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 0d3b091fe..58b337ff7 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -499,9 +499,9 @@ void SetWindowIcon(Image image) bmask = 0x001F, amask = 0; depth = 16, pitch = image.width * 2; break; - case PIXELFORMAT_UNCOMPRESSED_R8G8B8: - rmask = 0xFF0000, gmask = 0x00FF00; - bmask = 0x0000FF, amask = 0; + case PIXELFORMAT_UNCOMPRESSED_R8G8B8: // Uses BGR for 24-bit + rmask = 0x0000FF, gmask = 0x00FF00; + bmask = 0xFF0000, amask = 0; depth = 24, pitch = image.width * 3; break; case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: From 811abcb19faba710839a254ee3781a8d0ab23337 Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:36:09 -0300 Subject: [PATCH 02/23] Fix rcamera.h so mouse/keyboard and gamepad can coexist for input (#3579) --- src/rcamera.h | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/rcamera.h b/src/rcamera.h index c999370f5..0232dd488 100644 --- a/src/rcamera.h +++ b/src/rcamera.h @@ -471,31 +471,30 @@ void UpdateCamera(Camera *camera, int mode) if (IsKeyDown(KEY_E)) CameraRoll(camera, CAMERA_ROTATION_SPEED); // Camera movement - if (!IsGamepadAvailable(0)) + // Camera pan (for CAMERA_FREE) + if ((mode == CAMERA_FREE) && (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE))) { - // Camera pan (for CAMERA_FREE) - if ((mode == CAMERA_FREE) && (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE))) - { - const Vector2 mouseDelta = GetMouseDelta(); - if (mouseDelta.x > 0.0f) CameraMoveRight(camera, CAMERA_PAN_SPEED, moveInWorldPlane); - if (mouseDelta.x < 0.0f) CameraMoveRight(camera, -CAMERA_PAN_SPEED, moveInWorldPlane); - if (mouseDelta.y > 0.0f) CameraMoveUp(camera, -CAMERA_PAN_SPEED); - if (mouseDelta.y < 0.0f) CameraMoveUp(camera, CAMERA_PAN_SPEED); - } - else - { - // Mouse support - CameraYaw(camera, -mousePositionDelta.x*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget); - CameraPitch(camera, -mousePositionDelta.y*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp); - } - - // Keyboard support - if (IsKeyDown(KEY_W)) CameraMoveForward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane); - if (IsKeyDown(KEY_A)) CameraMoveRight(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane); - if (IsKeyDown(KEY_S)) CameraMoveForward(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane); - if (IsKeyDown(KEY_D)) CameraMoveRight(camera, CAMERA_MOVE_SPEED, moveInWorldPlane); + const Vector2 mouseDelta = GetMouseDelta(); + if (mouseDelta.x > 0.0f) CameraMoveRight(camera, CAMERA_PAN_SPEED, moveInWorldPlane); + if (mouseDelta.x < 0.0f) CameraMoveRight(camera, -CAMERA_PAN_SPEED, moveInWorldPlane); + if (mouseDelta.y > 0.0f) CameraMoveUp(camera, -CAMERA_PAN_SPEED); + if (mouseDelta.y < 0.0f) CameraMoveUp(camera, CAMERA_PAN_SPEED); } else + { + // Mouse support + CameraYaw(camera, -mousePositionDelta.x*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget); + CameraPitch(camera, -mousePositionDelta.y*CAMERA_MOUSE_MOVE_SENSITIVITY, lockView, rotateAroundTarget, rotateUp); + } + + // Keyboard support + if (IsKeyDown(KEY_W)) CameraMoveForward(camera, CAMERA_MOVE_SPEED, moveInWorldPlane); + if (IsKeyDown(KEY_A)) CameraMoveRight(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane); + if (IsKeyDown(KEY_S)) CameraMoveForward(camera, -CAMERA_MOVE_SPEED, moveInWorldPlane); + if (IsKeyDown(KEY_D)) CameraMoveRight(camera, CAMERA_MOVE_SPEED, moveInWorldPlane); + + // Gamepad movement + if (IsGamepadAvailable(0)) { // Gamepad controller support CameraYaw(camera, -(GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X) * 2)*CAMERA_MOUSE_MOVE_SENSITIVITY, rotateAroundTarget); From 1906f1eddf5220f6324471ebf4929f229115d2bb Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Tue, 28 Nov 2023 16:37:04 -0300 Subject: [PATCH 03/23] Fix SetMousePosition() for SDL (#3580) --- src/platforms/rcore_desktop_sdl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 58b337ff7..4a3195d8b 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -941,6 +941,8 @@ int SetGamepadMappings(const char *mappings) // Set mouse position XY void SetMousePosition(int x, int y) { + SDL_WarpMouseInWindow(platform.window, x, y); + CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y }; CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; } From fe53ba80dd684c501eb1c6d297fbf842bb42e515 Mon Sep 17 00:00:00 2001 From: RadsammyT <32146976+RadsammyT@users.noreply.github.com> Date: Tue, 28 Nov 2023 14:39:10 -0500 Subject: [PATCH 04/23] Fix typos in src/platforms/rcore_*.c (#3581) --- src/platforms/rcore_desktop.c | 4 ++-- src/platforms/rcore_desktop_sdl.c | 12 ++++++------ src/platforms/rcore_drm.c | 2 +- src/platforms/rcore_template.c | 6 +++--- src/platforms/rcore_web.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/platforms/rcore_desktop.c b/src/platforms/rcore_desktop.c index 05c390f97..0aca73134 100644 --- a/src/platforms/rcore_desktop.c +++ b/src/platforms/rcore_desktop.c @@ -129,7 +129,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i static void CharCallback(GLFWwindow *window, unsigned int key); // GLFW3 Char Key Callback, runs on key pressed (get char value) static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods); // GLFW3 Mouse Button Callback, runs on mouse button pressed static void MouseCursorPosCallback(GLFWwindow *window, double x, double y); // GLFW3 Cursor Position Callback, runs on mouse move -static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset); // GLFW3 Srolling Callback, runs on mouse wheel +static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset); // GLFW3 Scrolling Callback, runs on mouse wheel static void CursorEnterCallback(GLFWwindow *window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area static void JoystickCallback(int jid, int event); // GLFW3 Joystick Connected/Disconnected Callback @@ -1137,7 +1137,7 @@ void PollInputEvents(void) //for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.position[i] = (Vector2){ 0, 0 }; // Map touch position to mouse position for convenience - // WARNING: If the target desktop device supports touch screen, this behavious should be reviewed! + // WARNING: If the target desktop device supports touch screen, this behaviour should be reviewed! // TODO: GLFW does not support multi-touch input just yet // https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch // https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 4a3195d8b..a274f25dc 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -48,7 +48,7 @@ * **********************************************************************************************/ -#include "SDL.h" // SDL base library (window/rendered, input, timming... functionality) +#include "SDL.h" // SDL base library (window/rendered, input, timing... functionality) #if defined(GRAPHICS_API_OPENGL_ES2) // It seems it does not need to be included to work @@ -598,7 +598,7 @@ void SetWindowMonitor(int monitor) // NOTE: // 1. SDL started supporting moving exclusive fullscreen windows between displays on SDL3, // see commit https://github.com/libsdl-org/SDL/commit/3f5ef7dd422057edbcf3e736107e34be4b75d9ba - // 2. A workround for SDL2 is leaving fullscreen, moving the window, then entering full screen again. + // 2. A workaround for SDL2 is leaving fullscreen, moving the window, then entering full screen again. const bool wasFullscreen = ((CORE.Window.flags & FLAG_FULLSCREEN_MODE) > 0) ? true : false; const int screenWidth = CORE.Window.screen.width; @@ -617,7 +617,7 @@ void SetWindowMonitor(int monitor) // ending up positioned partly outside the target display. // 2. The workaround for that is, previously to moving the window, // setting the window size to the target display size, so they match. - // 3. It was't done here because we can't assume changing the window size automatically + // 3. It wasn't done here because we can't assume changing the window size automatically // is acceptable behavior by the user. SDL_SetWindowPosition(platform.window, usableBounds.x, usableBounds.y); CORE.Window.position.x = usableBounds.x; @@ -1012,7 +1012,7 @@ void PollInputEvents(void) // Register previous mouse states for (int i = 0; i < MAX_MOUSE_BUTTONS; i++) CORE.Input.Mouse.previousButtonState[i] = CORE.Input.Mouse.currentButtonState[i]; - // Poll input events for current plaform + // Poll input events for current platform //----------------------------------------------------------------------------- /* // WARNING: Indexes into this array are obtained by using SDL_Scancode values, not SDL_Keycode values @@ -1318,7 +1318,7 @@ int InitPlatform(void) // Init OpenGL context platform.glContext = SDL_GL_CreateContext(platform.window); - // Check window and glContext have been initialized succesfully + // Check window and glContext have been initialized successfully if ((platform.window != NULL) && (platform.glContext != NULL)) { CORE.Window.ready = true; @@ -1362,7 +1362,7 @@ int InitPlatform(void) SDL_EventState(SDL_DROPFILE, SDL_ENABLE); //---------------------------------------------------------------------------- - // Initialize timming system + // Initialize timing system //---------------------------------------------------------------------------- // NOTE: No need to call InitTimer(), let SDL manage it internally CORE.Time.previous = GetTime(); // Get time as double diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index bdfc9e0f5..461588995 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -602,7 +602,7 @@ void PollInputEvents(void) if (!platform.eventKeyboardMode) ProcessKeyboard(); // NOTE: Mouse input events polling is done asynchronously in another pthread - EventThread() - // NOTE: Gamepad (Joystick) input events polling is done asynchonously in another pthread - GamepadThread() + // NOTE: Gamepad (Joystick) input events polling is done asynchronously in another pthread - GamepadThread() #endif // Handle the mouse/touch/gestures events: diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 5d4721c84..01e52af58 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -420,7 +420,7 @@ void PollInputEvents(void) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0; } - // TODO: Poll input events for current plaform + // TODO: Poll input events for current platform } @@ -561,13 +561,13 @@ int InitPlatform(void) // TODO: Initialize input events system // It could imply keyboard, mouse, gamepad, touch... - // Depending on the platform libraries/SDK it could use a callbacks mechanims + // Depending on the platform libraries/SDK it could use a callback mechanism // For system events and inputs evens polling on a per-frame basis, use PollInputEvents() //---------------------------------------------------------------------------- // ... //---------------------------------------------------------------------------- - // TODO: Initialize timming system + // TODO: Initialize timing system //---------------------------------------------------------------------------- InitTimer(); //---------------------------------------------------------------------------- diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index d8fa54305..4353f795c 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -664,7 +664,7 @@ void PollInputEvents(void) // TODO: This code does not seem to do anything?? //if (CORE.Window.eventWaiting) glfwWaitEvents(); // Wait for in input events before continue (drawing is paused) - //else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks) --> WARNING: Where is key input reseted? + //else glfwPollEvents(); // Poll input events: keyboard/mouse/window events (callbacks) --> WARNING: Where is key input reset? } //---------------------------------------------------------------------------------- @@ -937,7 +937,7 @@ int InitPlatform(void) emscripten_set_gamepaddisconnected_callback(NULL, 1, EmscriptenGamepadCallback); //---------------------------------------------------------------------------- - // Initialize timming system + // Initialize timing system //---------------------------------------------------------------------------- InitTimer(); //---------------------------------------------------------------------------- From e7a486fa81adac1833253c849ca73c5b3f7ef361 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Tue, 28 Nov 2023 19:43:45 +0000 Subject: [PATCH 05/23] Hide unneeded internal symbols when building raylib as an so or dylib (#3573) --- CMakeLists.txt | 7 ++++++- cmake/GlfwImport.cmake | 10 +++++----- src/CMakeLists.txt | 15 +++++++++------ src/Makefile | 6 ++++++ src/raylib.h | 13 +++++++++---- src/raymath.h | 4 +++- src/rlgl.h | 16 +++++++++------- 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 236aa9a64..9619768c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0) project(raylib) # Avoid excessive expansion of variables in conditionals. In particular, if -# "PLATFORM" is "DRM" than: +# "PLATFORM" is "DRM" then: # # if (${PLATFORM} MATCHES "DRM") # @@ -13,6 +13,11 @@ project(raylib) # See https://cmake.org/cmake/help/latest/policy/CMP0054.html cmake_policy(SET CMP0054 NEW) +# Makes a hidden visibility preset on a static lib respected +# This is used to hide glfw's symbols from the library exports when building an so/dylib +# See https://cmake.org/cmake/help/latest/policy/CMP0063.html +cmake_policy(SET CMP0063 NEW) + # Directory for easier includes # Anywhere you see include(...) you can check /cmake for that file set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) diff --git a/cmake/GlfwImport.cmake b/cmake/GlfwImport.cmake index d0c23ca52..bd7d56811 100644 --- a/cmake/GlfwImport.cmake +++ b/cmake/GlfwImport.cmake @@ -17,16 +17,16 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(GLFW_INSTALL OFF CACHE BOOL "" FORCE) set(GLFW_USE_WAYLAND ${USE_WAYLAND} CACHE BOOL "" FORCE) + set(GLFW_LIBRARY_TYPE "STATIC" CACHE STRING "" FORCE) - set(WAS_SHARED ${BUILD_SHARED_LIBS}) - set(BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE) add_subdirectory(external/glfw) - set(BUILD_SHARED_LIBS ${WAS_SHARED} CACHE BOOL " " FORCE) - unset(WAS_SHARED) + # Hide glfw's symbols when building a shared lib + if (BUILD_SHARED_LIBS) + set_property(TARGET glfw PROPERTY C_VISIBILITY_PRESET hidden) + endif() - list(APPEND raylib_sources $) include_directories(BEFORE SYSTEM external/glfw/include) elseif("${PLATFORM}" STREQUAL "DRM") MESSAGE(STATUS "No GLFW required on PLATFORM_DRM") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5092bdf47..4335bda5c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,12 +62,10 @@ if (NOT BUILD_SHARED_LIBS) add_library(raylib_static ALIAS raylib) else() MESSAGE(STATUS "Building raylib shared library") - if (WIN32) - target_compile_definitions(raylib - PRIVATE $ - INTERFACE $ - ) - endif () + target_compile_definitions(raylib + PRIVATE $ + INTERFACE $ + ) endif() if (${PLATFORM} MATCHES "Web") @@ -84,6 +82,11 @@ if (WITH_PIC OR BUILD_SHARED_LIBS) set_property(TARGET raylib PROPERTY POSITION_INDEPENDENT_CODE ON) endif () +if (BUILD_SHARED_LIBS) + # Hide raylib's symbols by default so RLAPI can expose them + set_property(TARGET raylib PROPERTY C_VISIBILITY_PRESET hidden) +endif () + target_link_libraries(raylib "${LIBS_PRIVATE}") # Sets some compile time definitions for the pre-processor diff --git a/src/Makefile b/src/Makefile index 3ccea903b..772e5809f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -389,7 +389,13 @@ ifeq ($(RAYLIB_LIBTYPE),SHARED) # BE CAREFUL: It seems that for gcc -fpic is not the same as -fPIC # MinGW32 just doesn't need -fPIC, it shows warnings CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED + + # hide all symbols by default, so RLAPI can expose them + ifeq ($(PLATFORM_OS),$(filter $(PLATFORM_OS), LINUX BSD OSX)) + CFLAGS += -fvisibility=hidden + endif endif + ifeq ($(PLATFORM),PLATFORM_DRM) # without EGL_NO_X11 eglplatform.h tears Xlib.h in which tears X.h in # which contains a conflicting type Font diff --git a/src/raylib.h b/src/raylib.h index 28f052c7f..2bbbef00a 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -86,17 +86,22 @@ #define RAYLIB_VERSION_PATCH 0 #define RAYLIB_VERSION "5.1-dev" -// Function specifiers in case library is build/used as a shared library (Windows) +// Function specifiers in case library is build/used as a shared library // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll +// NOTE: visibility("default") attribute makes symbols "visible" when compiled with -fvisibility=hidden #if defined(_WIN32) + #if defined(__TINYC__) + #define __declspec(x) __attribute__((x)) + #endif #if defined(BUILD_LIBTYPE_SHARED) - #if defined(__TINYC__) - #define __declspec(x) __attribute__((x)) - #endif #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) #elif defined(USE_LIBTYPE_SHARED) #define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll) #endif +#else + #if defined(BUILD_LIBTYPE_SHARED) + #define RLAPI __attribute__((visibility("default"))) // We are building as a Unix shared library (.so/.dylib) + #endif #endif #ifndef RLAPI diff --git a/src/raymath.h b/src/raymath.h index ff6017039..069c9464e 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -59,7 +59,9 @@ // Function specifiers definition #if defined(RAYMATH_IMPLEMENTATION) #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED) - #define RMAPI __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll). + #define RMAPI __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll) + #elif defined(BUILD_LIBTYPE_SHARED) + #define RMAPI __attribute__((visibility("default"))) // We are building raylib as a Unix shared library (.so/.dylib) #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED) #define RMAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll) #else diff --git a/src/rlgl.h b/src/rlgl.h index 27cfaa0d0..67429d060 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -109,16 +109,18 @@ #define RLGL_VERSION "4.5" -// Function specifiers in case library is build/used as a shared library (Windows) +// Function specifiers in case library is build/used as a shared library // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll -#if defined(_WIN32) - #if defined(BUILD_LIBTYPE_SHARED) - #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) - #elif defined(USE_LIBTYPE_SHARED) - #define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll) - #endif +// NOTE: visibility(default) attribute makes symbols "visible" when compiled with -fvisibility=hidden +#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED) + #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) +#elif defined(BUILD_LIBTYPE_SHARED) + #define RLAPI __attribute__((visibility("default"))) // We are building he library as a Unix shared library (.so/.dylib) +#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED) + #define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll) #endif + // Function specifiers definition #ifndef RLAPI #define RLAPI // Functions defined as 'extern' by default (implicit specifiers) From bd81bdc24a2e896d641706fd23bb379d19cb2426 Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Thu, 30 Nov 2023 06:09:57 -0300 Subject: [PATCH 06/23] Fix IsKeyPressedRepeat() for PLATFORM_DRM direct input (#3583) --- src/platforms/rcore_drm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index 461588995..a63790a63 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -1709,6 +1709,7 @@ static void PollKeyboardEvents(void) // Event interface: 'value' is the value the event carries. Either a relative change for EV_REL, // absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for release, 1 for keypress and 2 for autorepeat CORE.Input.Keyboard.currentKeyState[keycode] = (event.value >= 1)? 1 : 0; + CORE.Input.Keyboard.keyRepeatInFrame[keycode] = (event.value == 2)? 1 : 0; if (event.value >= 1) { CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode; // Register last key pressed From e84099bfd42669250a5df4b29f8ffebbd21fbc82 Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Thu, 30 Nov 2023 06:11:45 -0300 Subject: [PATCH 07/23] Fix CheckCollisionCircleRec() (#3584) --- src/rshapes.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rshapes.c b/src/rshapes.c index bababf8cf..4b3f2cfd0 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -1549,7 +1549,7 @@ void DrawSplineLinear(Vector2 *points, int pointCount, float thick, Color color) Vector2 delta = { 0 }; float length = 0.0f; float scale = 0.0f; - + for (int i = 0; i < pointCount - 1; i++) { delta = (Vector2){ points[i + 1].x - points[i].x, points[i + 1].y - points[i].y }; @@ -1568,7 +1568,7 @@ void DrawSplineLinear(Vector2 *points, int pointCount, float thick, Color color) DrawTriangleStrip(strip, 4, color); } #if defined(SUPPORT_SPLINE_SEGMENT_CAPS) - + #endif } @@ -1718,7 +1718,7 @@ void DrawSplineCatmullRom(Vector2 *points, int pointCount, float thick, Color co void DrawSplineBezierQuadratic(Vector2 *points, int pointCount, float thick, Color color) { if (pointCount < 3) return; - + for (int i = 0; i < pointCount - 2; i++) { DrawSplineSegmentBezierQuadratic(points[i], points[i + 1], points[i + 2], thick, color); @@ -1729,7 +1729,7 @@ void DrawSplineBezierQuadratic(Vector2 *points, int pointCount, float thick, Col void DrawSplineBezierCubic(Vector2 *points, int pointCount, float thick, Color color) { if (pointCount < 4) return; - + for (int i = 0; i < pointCount - 3; i++) { DrawSplineSegmentBezierCubic(points[i], points[i + 1], points[i + 2], points[i + 3], thick, color); @@ -1740,7 +1740,7 @@ void DrawSplineBezierCubic(Vector2 *points, int pointCount, float thick, Color c void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color) { // NOTE: For the linear spline we don't use subdivisions, just a single quad - + Vector2 delta = { p2.x - p1.x, p2.y - p1.y }; float length = sqrtf(delta.x*delta.x + delta.y*delta.y); @@ -1768,9 +1768,9 @@ void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, floa Vector2 currentPoint = { 0 }; Vector2 nextPoint = { 0 }; float t = 0.0f; - + Vector2 points[2*SPLINE_SEGMENT_DIVISIONS + 2] = { 0 }; - + float a[4] = { 0 }; float b[4] = { 0 }; @@ -1825,7 +1825,7 @@ void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 currentPoint = p1; Vector2 nextPoint = { 0 }; float t = 0.0f; - + Vector2 points[2*SPLINE_SEGMENT_DIVISIONS + 2] = { 0 }; for (int i = 0; i <= SPLINE_SEGMENT_DIVISIONS; i++) @@ -2132,11 +2132,11 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec) { bool collision = false; - int recCenterX = (int)(rec.x + rec.width/2.0f); - int recCenterY = (int)(rec.y + rec.height/2.0f); + float recCenterX = rec.x + rec.width/2.0f; + float recCenterY = rec.y + rec.height/2.0f; - float dx = fabsf(center.x - (float)recCenterX); - float dy = fabsf(center.y - (float)recCenterY); + float dx = fabsf(center.x - recCenterX); + float dy = fabsf(center.y - recCenterY); if (dx > (rec.width/2.0f + radius)) { return false; } if (dy > (rec.height/2.0f + radius)) { return false; } From 6b136fac679a2dad30cce1abda9613b499ee4d5c Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 30 Nov 2023 13:01:19 +0100 Subject: [PATCH 08/23] ADDED: `ExportMeshAsCode()` --- src/raylib.h | 3 +- src/rmodels.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/src/raylib.h b/src/raylib.h index 2bbbef00a..fd870c188 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1536,9 +1536,10 @@ RLAPI void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize RLAPI void UnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU RLAPI void DrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform RLAPI void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances); // Draw multiple mesh instances with material and different transforms -RLAPI bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success RLAPI BoundingBox GetMeshBoundingBox(Mesh mesh); // Compute mesh bounding box limits RLAPI void GenMeshTangents(Mesh *mesh); // Compute mesh tangents +RLAPI bool ExportMesh(Mesh mesh, const char *fileName); // Export mesh data to file, returns true on success +RLAPI bool ExportMeshAsCode(Mesh mesh, const char *fileName); // Export mesh as code file (.h) defining multiple arrays of vertex attributes // Mesh generation functions RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh diff --git a/src/rmodels.c b/src/rmodels.c index c191f0ac7..84c7d9cbe 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -1850,6 +1850,104 @@ bool ExportMesh(Mesh mesh, const char *fileName) return success; } +// Export mesh as code file (.h) defining multiple arrays of vertex attributes +bool ExportMeshAsCode(Mesh mesh, const char *fileName) +{ + bool success = false; + +#ifndef TEXT_BYTES_PER_LINE + #define TEXT_BYTES_PER_LINE 20 +#endif + + // NOTE: Text data buffer size is fixed to 64MB + char *txtData = (char *)RL_CALLOC(64*1024*1024, sizeof(char)); // 64 MB + + int byteCount = 0; + byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// MeshAsCode exporter v1.0 - Mesh vertex data exported as arrays //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n"); + byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "// Copyright (c) 2023 Ramon Santamaria (@raysan5) //\n"); + byteCount += sprintf(txtData + byteCount, "// //\n"); + byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n"); + + // Get file name from path and convert variable name to uppercase + char varFileName[256] = { 0 }; + strcpy(varFileName, GetFileNameWithoutExt(fileName)); + for (int i = 0; varFileName[i] != '\0'; i++) if ((varFileName[i] >= 'a') && (varFileName[i] <= 'z')) { varFileName[i] = varFileName[i] - 32; } + + // Add image information + byteCount += sprintf(txtData + byteCount, "// Mesh basic information\n"); + byteCount += sprintf(txtData + byteCount, "#define %s_VERTEX_COUNT %i\n", varFileName, mesh.vertexCount); + byteCount += sprintf(txtData + byteCount, "#define %s_TRIANGLE_COUNT %i\n\n", varFileName, mesh.triangleCount); + + // Define vertex attributes data as separate arrays + //----------------------------------------------------------------------------------------- + if (mesh.vertices != NULL) // Vertex position (XYZ - 3 components per vertex - float) + { + byteCount += sprintf(txtData + byteCount, "static float %s_VERTEX_DATA[%i] = { ", varFileName, mesh.vertexCount*3); + for (int i = 0; i < mesh.vertexCount*3 - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "%.3ff,\n" : "%.3ff, "), mesh.vertices[i]); + byteCount += sprintf(txtData + byteCount, "%.3ff };\n\n", mesh.vertices[mesh.vertexCount*3 - 1]); + } + + if (mesh.texcoords != NULL) // Vertex texture coordinates (UV - 2 components per vertex - float) + { + byteCount += sprintf(txtData + byteCount, "static float %s_TEXCOORD_DATA[%i] = { ", varFileName, mesh.vertexCount*2); + for (int i = 0; i < mesh.vertexCount*2 - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "%.3ff,\n" : "%.3ff, "), mesh.texcoords[i]); + byteCount += sprintf(txtData + byteCount, "%.3ff };\n\n", mesh.texcoords[mesh.vertexCount*2 - 1]); + } + + if (mesh.texcoords2 != NULL) // Vertex texture coordinates (UV - 2 components per vertex - float) + { + byteCount += sprintf(txtData + byteCount, "static float %s_TEXCOORD2_DATA[%i] = { ", varFileName, mesh.vertexCount*2); + for (int i = 0; i < mesh.vertexCount*2 - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "%.3ff,\n" : "%.3ff, "), mesh.texcoords2[i]); + byteCount += sprintf(txtData + byteCount, "%.3ff };\n\n", mesh.texcoords2[mesh.vertexCount*2 - 1]); + } + + if (mesh.normals != NULL) // Vertex normals (XYZ - 3 components per vertex - float) + { + byteCount += sprintf(txtData + byteCount, "static float %s_NORMAL_DATA[%i] = { ", varFileName, mesh.vertexCount*3); + for (int i = 0; i < mesh.vertexCount*3 - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "%.3ff,\n" : "%.3ff, "), mesh.normals[i]); + byteCount += sprintf(txtData + byteCount, "%.3ff };\n\n", mesh.normals[mesh.vertexCount*3 - 1]); + } + + if (mesh.tangents != NULL) // Vertex tangents (XYZW - 4 components per vertex - float) + { + byteCount += sprintf(txtData + byteCount, "static float %s_TANGENT_DATA[%i] = { ", varFileName, mesh.vertexCount*4); + for (int i = 0; i < mesh.vertexCount*4 - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "%.3ff,\n" : "%.3ff, "), mesh.tangents[i]); + byteCount += sprintf(txtData + byteCount, "%.3ff };\n\n", mesh.tangents[mesh.vertexCount*4 - 1]); + } + + if (mesh.colors != NULL) // Vertex colors (RGBA - 4 components per vertex - unsigned char) + { + byteCount += sprintf(txtData + byteCount, "static unsigned char %s_COLOR_DATA[%i] = { ", varFileName, mesh.vertexCount*4); + for (int i = 0; i < mesh.vertexCount*4 - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%x,\n" : "0x%x, "), mesh.colors[i]); + byteCount += sprintf(txtData + byteCount, "0x%x };\n\n", mesh.colors[mesh.vertexCount*4 - 1]); + } + + if (mesh.indices != NULL) // Vertex indices (3 index per triangle - unsigned short) + { + byteCount += sprintf(txtData + byteCount, "static unsigned short %s_INDEX_DATA[%i] = { ", varFileName, mesh.triangleCount*3); + for (int i = 0; i < mesh.triangleCount*3 - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "%i,\n" : "%i, "), mesh.indices[i]); + byteCount += sprintf(txtData + byteCount, "%i };\n", mesh.indices[mesh.triangleCount*3 - 1]); + } + //----------------------------------------------------------------------------------------- + + // NOTE: Text data size exported is determined by '\0' (NULL) character + success = SaveFileText(fileName, txtData); + + RL_FREE(txtData); + + //if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Image as code exported successfully", fileName); + //else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export image as code", fileName); + + return success; +} + + #if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL) // Process obj materials static void ProcessMaterialsOBJ(Material *materials, tinyobj_material_t *mats, int materialCount) From e9ddb15d9d05ac61739c52a604a7a5adb7efa4e9 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 30 Nov 2023 19:04:38 +0100 Subject: [PATCH 09/23] REVIEWED: rlgl function description and comments --- src/rlgl.h | 108 +++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/src/rlgl.h b/src/rlgl.h index 67429d060..2468f30bd 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -557,14 +557,14 @@ typedef enum { extern "C" { // Prevents name mangling of functions #endif -RLAPI void rlMatrixMode(int mode); // Choose the current matrix to be transformed -RLAPI void rlPushMatrix(void); // Push the current matrix to stack -RLAPI void rlPopMatrix(void); // Pop latest inserted matrix from stack -RLAPI void rlLoadIdentity(void); // Reset current matrix to identity matrix -RLAPI void rlTranslatef(float x, float y, float z); // Multiply the current matrix by a translation matrix -RLAPI void rlRotatef(float angle, float x, float y, float z); // Multiply the current matrix by a rotation matrix -RLAPI void rlScalef(float x, float y, float z); // Multiply the current matrix by a scaling matrix -RLAPI void rlMultMatrixf(const float *matf); // Multiply the current matrix by another matrix +RLAPI void rlMatrixMode(int mode); // Choose the current matrix to be transformed +RLAPI void rlPushMatrix(void); // Push the current matrix to stack +RLAPI void rlPopMatrix(void); // Pop latest inserted matrix from stack +RLAPI void rlLoadIdentity(void); // Reset current matrix to identity matrix +RLAPI void rlTranslatef(float x, float y, float z); // Multiply the current matrix by a translation matrix +RLAPI void rlRotatef(float angle, float x, float y, float z); // Multiply the current matrix by a rotation matrix +RLAPI void rlScalef(float x, float y, float z); // Multiply the current matrix by a scaling matrix +RLAPI void rlMultMatrixf(const float *matf); // Multiply the current matrix by another matrix RLAPI void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar); RLAPI void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar); RLAPI void rlViewport(int x, int y, int width, int height); // Set the viewport area @@ -572,15 +572,15 @@ RLAPI void rlViewport(int x, int y, int width, int height); // Set the viewport //------------------------------------------------------------------------------------ // Functions Declaration - Vertex level operations //------------------------------------------------------------------------------------ -RLAPI void rlBegin(int mode); // Initialize drawing mode (how to organize vertex) -RLAPI void rlEnd(void); // Finish vertex providing -RLAPI void rlVertex2i(int x, int y); // Define one vertex (position) - 2 int -RLAPI void rlVertex2f(float x, float y); // Define one vertex (position) - 2 float -RLAPI void rlVertex3f(float x, float y, float z); // Define one vertex (position) - 3 float -RLAPI void rlTexCoord2f(float x, float y); // Define one vertex (texture coordinate) - 2 float -RLAPI void rlNormal3f(float x, float y, float z); // Define one vertex (normal) - 3 float -RLAPI void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a); // Define one vertex (color) - 4 byte -RLAPI void rlColor3f(float x, float y, float z); // Define one vertex (color) - 3 float +RLAPI void rlBegin(int mode); // Initialize drawing mode (how to organize vertex) +RLAPI void rlEnd(void); // Finish vertex providing +RLAPI void rlVertex2i(int x, int y); // Define one vertex (position) - 2 int +RLAPI void rlVertex2f(float x, float y); // Define one vertex (position) - 2 float +RLAPI void rlVertex3f(float x, float y, float z); // Define one vertex (position) - 3 float +RLAPI void rlTexCoord2f(float x, float y); // Define one vertex (texture coordinate) - 2 float +RLAPI void rlNormal3f(float x, float y, float z); // Define one vertex (normal) - 3 float +RLAPI void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a); // Define one vertex (color) - 4 byte +RLAPI void rlColor3f(float x, float y, float z); // Define one vertex (color) - 3 float RLAPI void rlColor4f(float x, float y, float z, float w); // Define one vertex (color) - 4 float //------------------------------------------------------------------------------------ @@ -594,13 +594,13 @@ RLAPI bool rlEnableVertexArray(unsigned int vaoId); // Enable vertex array ( RLAPI void rlDisableVertexArray(void); // Disable vertex array (VAO, if supported) RLAPI void rlEnableVertexBuffer(unsigned int id); // Enable vertex buffer (VBO) RLAPI void rlDisableVertexBuffer(void); // Disable vertex buffer (VBO) -RLAPI void rlEnableVertexBufferElement(unsigned int id);// Enable vertex buffer element (VBO element) +RLAPI void rlEnableVertexBufferElement(unsigned int id); // Enable vertex buffer element (VBO element) RLAPI void rlDisableVertexBufferElement(void); // Disable vertex buffer element (VBO element) RLAPI void rlEnableVertexAttribute(unsigned int index); // Enable vertex attribute index -RLAPI void rlDisableVertexAttribute(unsigned int index);// Disable vertex attribute index +RLAPI void rlDisableVertexAttribute(unsigned int index); // Disable vertex attribute index #if defined(GRAPHICS_API_OPENGL_11) -RLAPI void rlEnableStatePointer(int vertexAttribType, void *buffer); // Enable attribute state pointer -RLAPI void rlDisableStatePointer(int vertexAttribType); // Disable attribute state pointer +RLAPI void rlEnableStatePointer(int vertexAttribType, void *buffer); // Enable attribute state pointer +RLAPI void rlDisableStatePointer(int vertexAttribType); // Disable attribute state pointer #endif // Textures state @@ -623,7 +623,7 @@ RLAPI void rlActiveDrawBuffers(int count); // Activate multiple dra RLAPI void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int bufferMask); // Blit active framebuffer to main framebuffer // General render state -RLAPI void rlEnableColorBlend(void); // Enable color blending +RLAPI void rlEnableColorBlend(void); // Enable color blending RLAPI void rlDisableColorBlend(void); // Disable color blending RLAPI void rlEnableDepthTest(void); // Enable depth test RLAPI void rlDisableDepthTest(void); // Disable depth test @@ -636,7 +636,7 @@ RLAPI void rlEnableScissorTest(void); // Enable scissor test RLAPI void rlDisableScissorTest(void); // Disable scissor test RLAPI void rlScissor(int x, int y, int width, int height); // Scissor test RLAPI void rlEnableWireMode(void); // Enable wire mode -RLAPI void rlEnablePointMode(void); // Enable point mode +RLAPI void rlEnablePointMode(void); // Enable point mode RLAPI void rlDisableWireMode(void); // Disable wire mode ( and point ) maybe rename RLAPI void rlSetLineWidth(float width); // Set the line drawing width RLAPI float rlGetLineWidth(void); // Get the line drawing width @@ -673,48 +673,48 @@ RLAPI int *rlGetShaderLocsDefault(void); // Get default shader lo // Render batch management // NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode // but this render batch API is exposed in case of custom batches are required -RLAPI rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements); // Load a render batch system -RLAPI void rlUnloadRenderBatch(rlRenderBatch batch); // Unload render batch system -RLAPI void rlDrawRenderBatch(rlRenderBatch *batch); // Draw render batch data (Update->Draw->Reset) -RLAPI void rlSetRenderBatchActive(rlRenderBatch *batch); // Set the active render batch for rlgl (NULL for default internal) -RLAPI void rlDrawRenderBatchActive(void); // Update and draw internal render batch -RLAPI bool rlCheckRenderBatchLimit(int vCount); // Check internal buffer overflow for a given number of vertex +RLAPI rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements); // Load a render batch system +RLAPI void rlUnloadRenderBatch(rlRenderBatch batch); // Unload render batch system +RLAPI void rlDrawRenderBatch(rlRenderBatch *batch); // Draw render batch data (Update->Draw->Reset) +RLAPI void rlSetRenderBatchActive(rlRenderBatch *batch); // Set the active render batch for rlgl (NULL for default internal) +RLAPI void rlDrawRenderBatchActive(void); // Update and draw internal render batch +RLAPI bool rlCheckRenderBatchLimit(int vCount); // Check internal buffer overflow for a given number of vertex RLAPI void rlSetTexture(unsigned int id); // Set current texture for render batch and check buffers limits //------------------------------------------------------------------------------------------------------------------------ // Vertex buffers management -RLAPI unsigned int rlLoadVertexArray(void); // Load vertex array (vao) if supported -RLAPI unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic); // Load a vertex buffer attribute -RLAPI unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic); // Load a new attributes element buffer -RLAPI void rlUpdateVertexBuffer(unsigned int bufferId, const void *data, int dataSize, int offset); // Update GPU buffer with new data -RLAPI void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset); // Update vertex buffer elements with new data -RLAPI void rlUnloadVertexArray(unsigned int vaoId); -RLAPI void rlUnloadVertexBuffer(unsigned int vboId); -RLAPI void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, const void *pointer); -RLAPI void rlSetVertexAttributeDivisor(unsigned int index, int divisor); -RLAPI void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType, int count); // Set vertex attribute default value -RLAPI void rlDrawVertexArray(int offset, int count); -RLAPI void rlDrawVertexArrayElements(int offset, int count, const void *buffer); -RLAPI void rlDrawVertexArrayInstanced(int offset, int count, int instances); -RLAPI void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances); +RLAPI unsigned int rlLoadVertexArray(void); // Load vertex array (vao) if supported +RLAPI unsigned int rlLoadVertexBuffer(const void *buffer, int size, bool dynamic); // Load a vertex buffer object +RLAPI unsigned int rlLoadVertexBufferElement(const void *buffer, int size, bool dynamic); // Load vertex buffer elements object +RLAPI void rlUpdateVertexBuffer(unsigned int bufferId, const void *data, int dataSize, int offset); // Update vertex buffer object data on GPU buffer +RLAPI void rlUpdateVertexBufferElements(unsigned int id, const void *data, int dataSize, int offset); // Update vertex buffer elements data on GPU buffer +RLAPI void rlUnloadVertexArray(unsigned int vaoId); // Unload vertex array (vao) +RLAPI void rlUnloadVertexBuffer(unsigned int vboId); // Unload vertex buffer object +RLAPI void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, const void *pointer); // Set vertex attribute data configuration +RLAPI void rlSetVertexAttributeDivisor(unsigned int index, int divisor); // Set vertex attribute data divisor +RLAPI void rlSetVertexAttributeDefault(int locIndex, const void *value, int attribType, int count); // Set vertex attribute default value, when attribute to provided +RLAPI void rlDrawVertexArray(int offset, int count); // Draw vertex array (currently active vao) +RLAPI void rlDrawVertexArrayElements(int offset, int count, const void *buffer); // Draw vertex array elements +RLAPI void rlDrawVertexArrayInstanced(int offset, int count, int instances); // Draw vertex array (currently active vao) with instancing +RLAPI void rlDrawVertexArrayElementsInstanced(int offset, int count, const void *buffer, int instances); // Draw vertex array elements with instancing // Textures management -RLAPI unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount); // Load texture in GPU -RLAPI unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo) -RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format); // Load texture cubemap -RLAPI void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data); // Update GPU texture with new data -RLAPI void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType); // Get OpenGL internal formats +RLAPI unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount); // Load texture data +RLAPI unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo) +RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format); // Load texture cubemap data +RLAPI void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data); // Update texture with new data on GPU +RLAPI void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned int *glFormat, unsigned int *glType); // Get OpenGL internal formats RLAPI const char *rlGetPixelFormatName(unsigned int format); // Get name string for pixel format RLAPI void rlUnloadTexture(unsigned int id); // Unload texture from GPU memory RLAPI void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps); // Generate mipmap data for selected texture -RLAPI void *rlReadTexturePixels(unsigned int id, int width, int height, int format); // Read texture pixel data +RLAPI void *rlReadTexturePixels(unsigned int id, int width, int height, int format); // Read texture pixel data RLAPI unsigned char *rlReadScreenPixels(int width, int height); // Read screen pixel data (color buffer) // Framebuffer management (fbo) RLAPI unsigned int rlLoadFramebuffer(int width, int height); // Load an empty framebuffer -RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer +RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); // Attach texture/renderbuffer to a framebuffer RLAPI bool rlFramebufferComplete(unsigned int id); // Verify framebuffer is complete RLAPI void rlUnloadFramebuffer(unsigned int id); // Delete framebuffer from GPU @@ -725,14 +725,14 @@ RLAPI unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fSha RLAPI void rlUnloadShaderProgram(unsigned int id); // Unload shader program RLAPI int rlGetLocationUniform(unsigned int shaderId, const char *uniformName); // Get shader location uniform RLAPI int rlGetLocationAttrib(unsigned int shaderId, const char *attribName); // Get shader location attribute -RLAPI void rlSetUniform(int locIndex, const void *value, int uniformType, int count); // Set shader value uniform +RLAPI void rlSetUniform(int locIndex, const void *value, int uniformType, int count); // Set shader value uniform RLAPI void rlSetUniformMatrix(int locIndex, Matrix mat); // Set shader value matrix RLAPI void rlSetUniformSampler(int locIndex, unsigned int textureId); // Set shader value sampler RLAPI void rlSetShader(unsigned int id, int *locs); // Set shader currently active (id and locations) // Compute shader management RLAPI unsigned int rlLoadComputeShaderProgram(unsigned int shaderId); // Load compute shader program -RLAPI void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ); // Dispatch compute shader (equivalent to *draw* for graphics pipeline) +RLAPI void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ); // Dispatch compute shader (equivalent to *draw* for graphics pipeline) // Shader buffer storage object management (ssbo) RLAPI unsigned int rlLoadShaderBuffer(unsigned int size, const void *data, int usageHint); // Load shader storage buffer object (SSBO) @@ -3794,6 +3794,10 @@ unsigned int rlLoadVertexArray(void) void rlSetVertexAttribute(unsigned int index, int compSize, int type, bool normalized, int stride, const void *pointer) { #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) + // NOTE: Data type could be: GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT + // Additional types (depends on OpenGL version or extensions): + // - GL_HALF_FLOAT, GL_FLOAT, GL_DOUBLE, GL_FIXED, + // - GL_INT_2_10_10_10_REV, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10F_11F_11F_REV glVertexAttribPointer(index, compSize, type, normalized, stride, pointer); #endif } From ef5069862d737919d98718095b0696c3bc74bac8 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Thu, 30 Nov 2023 19:07:50 +0000 Subject: [PATCH 10/23] Fix mistake in pr #3572 (#3587) --- src/rlgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rlgl.h b/src/rlgl.h index 2468f30bd..21aea6a05 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -776,7 +776,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad #if defined(RLGL_IMPLEMENTATION) // Expose OpenGL functions from glad in raylib -#if defined(BUILD_SHARED_LIBS) +#if defined(BUILD_LIBTYPE_SHARED) #define GLAD_API_CALL_EXPORT_BUILD #endif From 55e7d1aad13a1329d257ac948509a3a0ed2c20a9 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Thu, 30 Nov 2023 21:43:02 +0000 Subject: [PATCH 11/23] Expose OpenGL take 2 (#3588) For some reason, there are actually two macros needed to control this. Yes, I tried with only one, both are needed --- src/rlgl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rlgl.h b/src/rlgl.h index 21aea6a05..4b3184986 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -777,6 +777,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad // Expose OpenGL functions from glad in raylib #if defined(BUILD_LIBTYPE_SHARED) + #define GLAD_API_CALL_EXPORT #define GLAD_API_CALL_EXPORT_BUILD #endif From 0748dc2d1e8a73311ff47f815708e939f8953b20 Mon Sep 17 00:00:00 2001 From: ubkp <118854183+ubkp@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:55:48 -0300 Subject: [PATCH 12/23] Remove a duplicated loop for PLATFORM_DRM (#3590) --- src/platforms/rcore_drm.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index a63790a63..f51953a63 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -546,9 +546,6 @@ void PollInputEvents(void) CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0; - // Reset key repeats - for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0; - // Reset last gamepad button/axis registered state CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN //CORE.Input.Gamepad.axisCount = 0; From dfb0ca43c5b2602dc70cfa4e893e9e82c9bb3fe6 Mon Sep 17 00:00:00 2001 From: WIITD <52134513+WIITD@users.noreply.github.com> Date: Sun, 3 Dec 2023 19:51:47 +0100 Subject: [PATCH 13/23] Update raylib-freebasic binding (#3591) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 0e71d16e2..4cd22013d 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -24,7 +24,7 @@ Some people ported raylib to other languages in form of bindings or wrappers to | dlang_raylib | 4.0 | [D](https://dlang.org) | MPL-2.0 |https://github.com/rc-05/dlang_raylib | | rayex | 3.7 | [elixir](https://elixir-lang.org/) | Apache-2.0 | https://github.com/shiryel/rayex | | raylib-factor | **4.5** | [Factor](https://factorcode.org/) | BSD | https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor | -| raylib-freebasic | **4.5** | [FreeBASIC](https://www.freebasic.net/) | MIT | https://github.com/WIITD/raylib-freebasic | +| raylib-freebasic | **5.0** | [FreeBASIC](https://www.freebasic.net/) | MIT | https://github.com/WIITD/raylib-freebasic | | fortran-raylib | **4.5** | [Fortran](https://fortran-lang.org/) | ISC | https://github.com/interkosmos/fortran-raylib | | raylib for Pascal | **4.5** | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | Modified Zlib | https://github.com/tinyBigGAMES/raylib | | raylib-go | **5.0** | [Go](https://golang.org/) | Zlib | https://github.com/gen2brain/raylib-go | From 8ae804ff9a677c068486303510d1ebc4e8cd3a14 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Sun, 3 Dec 2023 18:53:11 +0000 Subject: [PATCH 14/23] Fix cmake-built libraylib.a to properly include GLFW's object files (#3598) I broke this in PR #3573 by accidentally removing too much The examples still compiled fine so I didn't notice - my guess is that cmake was still adding a separate link to glfw manually. --- cmake/GlfwImport.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/GlfwImport.cmake b/cmake/GlfwImport.cmake index bd7d56811..77c88e6c3 100644 --- a/cmake/GlfwImport.cmake +++ b/cmake/GlfwImport.cmake @@ -17,7 +17,7 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(GLFW_INSTALL OFF CACHE BOOL "" FORCE) set(GLFW_USE_WAYLAND ${USE_WAYLAND} CACHE BOOL "" FORCE) - set(GLFW_LIBRARY_TYPE "STATIC" CACHE STRING "" FORCE) + set(GLFW_LIBRARY_TYPE "OBJECT" CACHE STRING "" FORCE) add_subdirectory(external/glfw) @@ -27,6 +27,7 @@ if(NOT glfw3_FOUND AND NOT USE_EXTERNAL_GLFW STREQUAL "ON" AND "${PLATFORM}" MAT set_property(TARGET glfw PROPERTY C_VISIBILITY_PRESET hidden) endif() + list(APPEND raylib_sources $) include_directories(BEFORE SYSTEM external/glfw/include) elseif("${PLATFORM}" STREQUAL "DRM") MESSAGE(STATUS "No GLFW required on PLATFORM_DRM") From f1b0d15813098228369dd647ffc04a7dbd92c02a Mon Sep 17 00:00:00 2001 From: Marco Maia Date: Sun, 3 Dec 2023 15:53:52 -0300 Subject: [PATCH 15/23] Fix warning while using external GLFW older than version 3.4.0 (#3599) Co-authored-by: Marco Maia --- src/platforms/rcore_desktop.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/platforms/rcore_desktop.c b/src/platforms/rcore_desktop.c index 0aca73134..e31032911 100644 --- a/src/platforms/rcore_desktop.c +++ b/src/platforms/rcore_desktop.c @@ -88,11 +88,6 @@ //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- -// TODO: HACK: Added flag if not provided by GLFW when using external library -// Latest GLFW release (GLFW 3.3.8) does not implement this flag, it was added for 3.4.0-dev -#if !defined(GLFW_MOUSE_PASSTHROUGH) - #define GLFW_MOUSE_PASSTHROUGH 0x0002000D -#endif //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -396,11 +391,13 @@ void SetWindowState(unsigned int flags) } // State change: FLAG_WINDOW_MOUSE_PASSTHROUGH +#if defined (GLFW_MOUSE_PASSTHROUGH) if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) != (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)) { glfwSetWindowAttrib(platform.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE); CORE.Window.flags |= FLAG_WINDOW_MOUSE_PASSTHROUGH; } +#endif // State change: FLAG_MSAA_4X_HINT if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) != (flags & FLAG_MSAA_4X_HINT)) && ((flags & FLAG_MSAA_4X_HINT) > 0)) @@ -509,11 +506,13 @@ void ClearWindowState(unsigned int flags) } // State change: FLAG_WINDOW_MOUSE_PASSTHROUGH +#if defined (GLFW_MOUSE_PASSTHROUGH) if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)) { glfwSetWindowAttrib(platform.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); CORE.Window.flags &= ~FLAG_WINDOW_MOUSE_PASSTHROUGH; } +#endif // State change: FLAG_MSAA_4X_HINT if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) > 0) && ((flags & FLAG_MSAA_4X_HINT) > 0)) @@ -1316,8 +1315,10 @@ int InitPlatform(void) else glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE); // Mouse passthrough +#if defined (GLFW_MOUSE_PASSTHROUGH) if ((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE); else glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); +#endif if (CORE.Window.flags & FLAG_MSAA_4X_HINT) { From 4ae2af0bccc2792e0f380152b8638bfa384595c6 Mon Sep 17 00:00:00 2001 From: mr sihc <85245131+mr-sihc@users.noreply.github.com> Date: Sun, 3 Dec 2023 19:55:16 +0100 Subject: [PATCH 16/23] Fix Windows Hardcoding (#3600) Compiles on Linux & co. now --- src/platforms/rcore_desktop_sdl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index a274f25dc..7c27c611a 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -48,13 +48,13 @@ * **********************************************************************************************/ -#include "SDL.h" // SDL base library (window/rendered, input, timing... functionality) +#include "SDL2/SDL.h" // SDL base library (window/rendered, input, timing... functionality) #if defined(GRAPHICS_API_OPENGL_ES2) // It seems it does not need to be included to work //#include "SDL_opengles2.h" #else - #include "SDL_opengl.h" // SDL OpenGL functionality (if required, instead of internal renderer) + #include "SDL2/SDL_opengl.h" // SDL OpenGL functionality (if required, instead of internal renderer) #endif //---------------------------------------------------------------------------------- From 5aa84a34ea9e39528e830baea230f8efd9dc8883 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 3 Dec 2023 20:06:34 +0100 Subject: [PATCH 17/23] Revert "Fix warning while using external GLFW older than version 3.4.0 (#3599)" This reverts commit f1b0d15813098228369dd647ffc04a7dbd92c02a. --- src/platforms/rcore_desktop.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/platforms/rcore_desktop.c b/src/platforms/rcore_desktop.c index e31032911..0aca73134 100644 --- a/src/platforms/rcore_desktop.c +++ b/src/platforms/rcore_desktop.c @@ -88,6 +88,11 @@ //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- +// TODO: HACK: Added flag if not provided by GLFW when using external library +// Latest GLFW release (GLFW 3.3.8) does not implement this flag, it was added for 3.4.0-dev +#if !defined(GLFW_MOUSE_PASSTHROUGH) + #define GLFW_MOUSE_PASSTHROUGH 0x0002000D +#endif //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -391,13 +396,11 @@ void SetWindowState(unsigned int flags) } // State change: FLAG_WINDOW_MOUSE_PASSTHROUGH -#if defined (GLFW_MOUSE_PASSTHROUGH) if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) != (flags & FLAG_WINDOW_MOUSE_PASSTHROUGH)) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)) { glfwSetWindowAttrib(platform.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE); CORE.Window.flags |= FLAG_WINDOW_MOUSE_PASSTHROUGH; } -#endif // State change: FLAG_MSAA_4X_HINT if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) != (flags & FLAG_MSAA_4X_HINT)) && ((flags & FLAG_MSAA_4X_HINT) > 0)) @@ -506,13 +509,11 @@ void ClearWindowState(unsigned int flags) } // State change: FLAG_WINDOW_MOUSE_PASSTHROUGH -#if defined (GLFW_MOUSE_PASSTHROUGH) if (((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) && ((flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0)) { glfwSetWindowAttrib(platform.handle, GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); CORE.Window.flags &= ~FLAG_WINDOW_MOUSE_PASSTHROUGH; } -#endif // State change: FLAG_MSAA_4X_HINT if (((CORE.Window.flags & FLAG_MSAA_4X_HINT) > 0) && ((flags & FLAG_MSAA_4X_HINT) > 0)) @@ -1315,10 +1316,8 @@ int InitPlatform(void) else glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE); // Mouse passthrough -#if defined (GLFW_MOUSE_PASSTHROUGH) if ((CORE.Window.flags & FLAG_WINDOW_MOUSE_PASSTHROUGH) > 0) glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_TRUE); else glfwWindowHint(GLFW_MOUSE_PASSTHROUGH, GLFW_FALSE); -#endif if (CORE.Window.flags & FLAG_MSAA_4X_HINT) { From d0a783e362a7756f79af4d19bc0d4df78397e6fd Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 3 Dec 2023 20:08:48 +0100 Subject: [PATCH 18/23] Revert "Fix Windows Hardcoding (#3600)" This reverts commit 4ae2af0bccc2792e0f380152b8638bfa384595c6. --- src/platforms/rcore_desktop_sdl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 7c27c611a..a274f25dc 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -48,13 +48,13 @@ * **********************************************************************************************/ -#include "SDL2/SDL.h" // SDL base library (window/rendered, input, timing... functionality) +#include "SDL.h" // SDL base library (window/rendered, input, timing... functionality) #if defined(GRAPHICS_API_OPENGL_ES2) // It seems it does not need to be included to work //#include "SDL_opengles2.h" #else - #include "SDL2/SDL_opengl.h" // SDL OpenGL functionality (if required, instead of internal renderer) + #include "SDL_opengl.h" // SDL OpenGL functionality (if required, instead of internal renderer) #endif //---------------------------------------------------------------------------------- From 8a586249d776d41e4e4180022780a30d00105ff6 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 3 Dec 2023 20:16:19 +0100 Subject: [PATCH 19/23] Fix Wrong Makefile flag #3593 --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 772e5809f..ca978f777 100644 --- a/src/Makefile +++ b/src/Makefile @@ -380,7 +380,7 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) # -Werror=format-security CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes # Preprocessor macro definitions - CFLAGS += -D__ANDROID__ -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) -DMAL_NO_OSS + CFLAGS += -D__ANDROID__ -DPLATFORM_ANDROID -D__ANDROID_API__=$(ANDROID_API_VERSION) endif # Define required compilation flags for raylib SHARED lib From 26d61875ee95c27da6e02b5a013b3ef17ad87fcd Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 3 Dec 2023 20:16:23 +0100 Subject: [PATCH 20/23] Create raylib.icns --- logo/raylib.icns | Bin 0 -> 12242 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 logo/raylib.icns diff --git a/logo/raylib.icns b/logo/raylib.icns new file mode 100644 index 0000000000000000000000000000000000000000..5adad08cb88e692d188c7ef638473f5c98c51837 GIT binary patch literal 12242 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 D*pH{L literal 0 HcmV?d00001 From 84ae189953bffaf1cc24168e647fb100bf26a74d Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 3 Dec 2023 20:16:26 +0100 Subject: [PATCH 21/23] Create raylib_1024x1024.png --- logo/raylib_1024x1024.png | Bin 0 -> 4536 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 logo/raylib_1024x1024.png diff --git a/logo/raylib_1024x1024.png b/logo/raylib_1024x1024.png new file mode 100644 index 0000000000000000000000000000000000000000..b855a6bf64bc19ab0b04c2ce9d22e601bf17c5d6 GIT binary patch literal 4536 zcmeAS@N?(olHy`uVBq!ia0y~yU||4Z4kiW$h7a|7t}rkN)_b}*hE&{obJNl9uz`r{ zMX}0f+y76kJDY^e+6J={@>TLyb*kRGt4xe32(G2Mick%-icJs0BE zj9UhKXprhAtho@=t0>MMY;K}))&YkGso_LpH<6xod>9z87r9{XVUN;5=ZTS5PGXN3 z{J9)^$$*lDQIz18!Jf=WbrXKqVs9c0HaF2Y|AVt8so_LpH(`$$>`4NYo*WovfLr7Y z3?Lq!Vg<#Y1M7(&Q_`3i9_V}W)o)w1t?HTR_9Xv2!i{E(3_!rcYT0TG4DXh#>S6d_ zz)baW*dWrF@r`n)U|dLO*}jkG-v7BPx_`g+zV~_2Z@=x{c>Dj8t2;miIS6Ao9CsY! zmI0^L8Ea-TRJevp9t_*>_2@$4;rqPz|Ca6q*#W}TwI^YniW|d&O?R+%VDMXoJGFw- zr_VJXh635pt#^#o3kw*y3uzNM2TD~8o94d#vv^ewtNbH2s%MgfP0wHH8yqX>Vz?7G z>G1ruTFi%B_I_VF|2{7R14E7rRfDae*hH9N!y*+o28#nA Date: Sun, 3 Dec 2023 20:17:16 +0100 Subject: [PATCH 22/23] REVIEWED: `LoadFontData()`, load image only if glyph has been found in font --- src/rtext.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/rtext.c b/src/rtext.c index dd7c83f39..802b02b90 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -604,7 +604,6 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz // Fill fontChars in case not provided externally // NOTE: By default we fill glyphCount consecutively, starting at 32 (Space) - if (codepoints == NULL) { codepoints = (int *)RL_MALLOC(codepointCount*sizeof(int)); @@ -612,7 +611,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz genFontChars = true; } - chars = (GlyphInfo *)RL_MALLOC(codepointCount*sizeof(GlyphInfo)); + chars = (GlyphInfo *)RL_CALLOC(codepointCount, sizeof(GlyphInfo)); // NOTE: Using simple packaging, one char after another for (int i = 0; i < codepointCount; i++) @@ -630,16 +629,19 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz else if (ch != 32) chars[i].image.data = stbtt_GetCodepointSDF(&fontInfo, scaleFactor, ch, FONT_SDF_CHAR_PADDING, FONT_SDF_ON_EDGE_VALUE, FONT_SDF_PIXEL_DIST_SCALE, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY); else chars[i].image.data = NULL; - stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL); - chars[i].advanceX = (int)((float)chars[i].advanceX*scaleFactor); + if (chars[i].image.data != NULL) // Glyph data has been found in the font + { + stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL); + chars[i].advanceX = (int)((float)chars[i].advanceX*scaleFactor); - // Load characters images - chars[i].image.width = chw; - chars[i].image.height = chh; - chars[i].image.mipmaps = 1; - chars[i].image.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE; + // Load characters images + chars[i].image.width = chw; + chars[i].image.height = chh; + chars[i].image.mipmaps = 1; + chars[i].image.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE; - chars[i].offsetY += (int)((float)ascent*scaleFactor); + chars[i].offsetY += (int)((float)ascent*scaleFactor); + } // NOTE: We create an empty image for space character, it could be further required for atlas packing if (ch == 32) From 731b210f51cb273161bb7a8ba9cced11e0c4b9d2 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 4 Dec 2023 17:32:55 +0100 Subject: [PATCH 23/23] REVIEWED: WARNING: `LoadFontData()` avoid fallback glyphs This is a redesign on font loading, missing glyphs are skipped instead of falling back to font `.notdef` special character (usually "tofu" character). It is changed because not all fonts support a fallback glyph. One improvement could be allowing users to define a custom fallback character, for example `?` glyph. --- src/rtext.c | 102 ++++++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/src/rtext.c b/src/rtext.c index 802b02b90..1ab45277a 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -625,57 +625,67 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz // stbtt_GetCodepointBitmapBox() -- how big the bitmap must be // stbtt_MakeCodepointBitmap() -- renders into bitmap you provide - if (type != FONT_SDF) chars[i].image.data = stbtt_GetCodepointBitmap(&fontInfo, scaleFactor, scaleFactor, ch, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY); - else if (ch != 32) chars[i].image.data = stbtt_GetCodepointSDF(&fontInfo, scaleFactor, ch, FONT_SDF_CHAR_PADDING, FONT_SDF_ON_EDGE_VALUE, FONT_SDF_PIXEL_DIST_SCALE, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY); - else chars[i].image.data = NULL; + // Check if a glyph is available in the font + // WARNING: if (index == 0), glyph not found, it could fallback to default .notdef glyph (if defined in font) + int index = stbtt_FindGlyphIndex(&fontInfo, ch); - if (chars[i].image.data != NULL) // Glyph data has been found in the font + if (index > 0) { - stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL); - chars[i].advanceX = (int)((float)chars[i].advanceX*scaleFactor); - - // Load characters images - chars[i].image.width = chw; - chars[i].image.height = chh; - chars[i].image.mipmaps = 1; - chars[i].image.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE; - - chars[i].offsetY += (int)((float)ascent*scaleFactor); - } - - // NOTE: We create an empty image for space character, it could be further required for atlas packing - if (ch == 32) - { - Image imSpace = { - .data = RL_CALLOC(chars[i].advanceX*fontSize, 2), - .width = chars[i].advanceX, - .height = fontSize, - .mipmaps = 1, - .format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE - }; - - chars[i].image = imSpace; - } - - if (type == FONT_BITMAP) - { - // Aliased bitmap (black & white) font generation, avoiding anti-aliasing - // NOTE: For optimum results, bitmap font should be generated at base pixel size - for (int p = 0; p < chw*chh; p++) + switch (type) { - if (((unsigned char *)chars[i].image.data)[p] < FONT_BITMAP_ALPHA_THRESHOLD) ((unsigned char *)chars[i].image.data)[p] = 0; - else ((unsigned char *)chars[i].image.data)[p] = 255; + case FONT_DEFAULT: + case FONT_BITMAP: chars[i].image.data = stbtt_GetCodepointBitmap(&fontInfo, scaleFactor, scaleFactor, ch, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY); break; + case FONT_SDF: if (ch != 32) chars[i].image.data = stbtt_GetCodepointSDF(&fontInfo, scaleFactor, ch, FONT_SDF_CHAR_PADDING, FONT_SDF_ON_EDGE_VALUE, FONT_SDF_PIXEL_DIST_SCALE, &chw, &chh, &chars[i].offsetX, &chars[i].offsetY); break; + default: break; + } + + if (chars[i].image.data != NULL) // Glyph data has been found in the font + { + stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL); + chars[i].advanceX = (int)((float)chars[i].advanceX*scaleFactor); + + // Load characters images + chars[i].image.width = chw; + chars[i].image.height = chh; + chars[i].image.mipmaps = 1; + chars[i].image.format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE; + + chars[i].offsetY += (int)((float)ascent*scaleFactor); + } + + // NOTE: We create an empty image for space character, + // it could be further required for atlas packing + if (ch == 32) + { + stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL); + chars[i].advanceX = (int)((float)chars[i].advanceX*scaleFactor); + + Image imSpace = { + .data = RL_CALLOC(chars[i].advanceX*fontSize, 2), + .width = chars[i].advanceX, + .height = fontSize, + .mipmaps = 1, + .format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE + }; + + chars[i].image = imSpace; + } + + if (type == FONT_BITMAP) + { + // Aliased bitmap (black & white) font generation, avoiding anti-aliasing + // NOTE: For optimum results, bitmap font should be generated at base pixel size + for (int p = 0; p < chw*chh; p++) + { + if (((unsigned char *)chars[i].image.data)[p] < FONT_BITMAP_ALPHA_THRESHOLD) ((unsigned char *)chars[i].image.data)[p] = 0; + else ((unsigned char *)chars[i].image.data)[p] = 255; + } } } - - // Get bounding box for character (maybe offset to account for chars that dip above or below the line) - /* - int chX1, chY1, chX2, chY2; - stbtt_GetCodepointBitmapBox(&fontInfo, ch, scaleFactor, scaleFactor, &chX1, &chY1, &chX2, &chY2); - - TRACELOGD("FONT: Character box measures: %i, %i, %i, %i", chX1, chY1, chX2 - chX1, chY2 - chY1); - TRACELOGD("FONT: Character offsetY: %i", (int)((float)ascent*scaleFactor) + chY1); - */ + else + { + // TODO: Use some fallback glyph for codepoints not found in the font + } } } else TRACELOG(LOG_WARNING, "FONT: Failed to process TTF font data");