From f26bfa0c8efcf81559c2ba225e79778b1542d60f Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Wed, 15 May 2024 22:42:52 -0700 Subject: [PATCH 1/5] [RAYMATH] Revert Extern 'C' in raymath (#3985) * Update raylib_api.* by CI * Remove Extern C for raymath, it breaks some cases in mingw-w64 and does not fix any warning issues. --------- Co-authored-by: github-actions[bot] --- src/raymath.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index 7a2f09296..d036721a2 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -78,10 +78,6 @@ #endif -#if defined(__cplusplus) -extern "C" { // Prevents name mangling of functions -#endif - //---------------------------------------------------------------------------------- // Defines and Macros //---------------------------------------------------------------------------------- @@ -2528,8 +2524,5 @@ RMAPI int QuaternionEquals(Quaternion p, Quaternion q) return result; } -#if defined(__cplusplus) -} -#endif #endif // RAYMATH_H From 1d52985943d102b321c631bc4d24cca8ad0f651e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cemal=20G=C3=B6n=C3=BClta=C5=9F?= <45357531+cemalgnlts@users.noreply.github.com> Date: Thu, 16 May 2024 13:01:27 +0300 Subject: [PATCH 2/5] [rcore_web] Relative mouse mode issues. (#3940) * [rcore_web] Relative mouse mode issues. * Review formatting. --- .gitignore | 3 +++ src/platforms/rcore_web.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 6ff0e2346..eeb1ed09d 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,9 @@ packages/ *.so.* *.dll +# Emscripten +emsdk + # Ignore wasm data in examples/ examples/**/*.wasm examples/**/*.data diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 9328b8c9b..afe8adfb1 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -100,6 +100,8 @@ static const char cursorLUT[11][12] = { "not-allowed" // 10 MOUSE_CURSOR_NOT_ALLOWED }; +Vector2 lockedMousePos = { 0 }; + //---------------------------------------------------------------------------------- // Module Internal Functions Declaration //---------------------------------------------------------------------------------- @@ -131,6 +133,7 @@ static EM_BOOL EmscriptenWindowResizedCallback(int eventType, const EmscriptenUi static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *event, void *userData); // Emscripten input callback events +static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); static EM_BOOL EmscriptenMouseCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); static EM_BOOL EmscriptenPointerlockCallback(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent, void *userData); static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData); @@ -862,6 +865,8 @@ void SetMousePosition(int x, int y) CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y }; CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; + if (CORE.Input.Mouse.cursorHidden) lockedMousePos = CORE.Input.Mouse.currentPosition; + // NOTE: emscripten not implemented glfwSetCursorPos(platform.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y); } @@ -1270,6 +1275,9 @@ int InitPlatform(void) emscripten_set_click_callback("#canvas", NULL, 1, EmscriptenMouseCallback); emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenPointerlockCallback); + // Following the mouse delta when the mouse is locked + emscripten_set_mousemove_callback("#canvas", NULL, 1, EmscriptenMouseMoveCallback); + // Support touch events emscripten_set_touchstart_callback("#canvas", NULL, 1, EmscriptenTouchCallback); emscripten_set_touchend_callback("#canvas", NULL, 1, EmscriptenTouchCallback); @@ -1477,9 +1485,13 @@ static void MouseButtonCallback(GLFWwindow *window, int button, int action, int // GLFW3 Cursor Position Callback, runs on mouse move static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) { - CORE.Input.Mouse.currentPosition.x = (float)x; - CORE.Input.Mouse.currentPosition.y = (float)y; - CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; + // If the pointer is not locked, follow the position + if (!CORE.Input.Mouse.cursorHidden) + { + CORE.Input.Mouse.currentPosition.x = (float)x; + CORE.Input.Mouse.currentPosition.y = (float)y; + CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; + } #if defined(SUPPORT_GESTURES_SYSTEM) && defined(SUPPORT_MOUSE_GESTURES) // Process mouse events as touches to be able to use mouse-gestures @@ -1505,6 +1517,18 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) #endif } +static EM_BOOL EmscriptenMouseMoveCallback(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +{ + // To emulate the GLFW_RAW_MOUSE_MOTION property. + if (CORE.Input.Mouse.cursorHidden) + { + CORE.Input.Mouse.previousPosition.x = lockedMousePos.x - mouseEvent->movementX; + CORE.Input.Mouse.previousPosition.y = lockedMousePos.y - mouseEvent->movementY; + } + + return 1; // The event was consumed by the callback handler +} + // GLFW3 Scrolling Callback, runs on mouse wheel static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset) { @@ -1598,6 +1622,12 @@ static EM_BOOL EmscriptenPointerlockCallback(int eventType, const EmscriptenPoin { CORE.Input.Mouse.cursorHidden = EM_ASM_INT( { if (document.pointerLockElement) return 1; }, 0); + if (CORE.Input.Mouse.cursorHidden) + { + lockedMousePos = CORE.Input.Mouse.currentPosition; + CORE.Input.Mouse.previousPosition = lockedMousePos; + } + return 1; // The event was consumed by the callback handler } From 3d70d6179c4809d8b7e92215358394e3584bca79 Mon Sep 17 00:00:00 2001 From: FishingHacks Date: Thu, 16 May 2024 19:47:39 +0200 Subject: [PATCH 3/5] [raudio] Removed drwav_uninit in LoadMusicStream to fix a crash (#3986) --- src/raudio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/raudio.c b/src/raudio.c index 9d7c39a5b..8f4bf7a51 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -1348,7 +1348,6 @@ Music LoadMusicStream(const char *fileName) } else { - drwav_uninit(ctxWav); RL_FREE(ctxWav); } } From 00ac9b6c533e964ae2d5c5726e5d6c1f00964d0f Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 18 May 2024 07:40:59 +0200 Subject: [PATCH 4/5] Update config.h --- src/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.h b/src/config.h index 1fe21454f..3c92de72d 100644 --- a/src/config.h +++ b/src/config.h @@ -189,7 +189,7 @@ #define SUPPORT_DEFAULT_FONT 1 // Selected desired font fileformats to be supported for loading #define SUPPORT_FILEFORMAT_TTF 1 -//#define SUPPORT_FILEFORMAT_FNT 1 +#define SUPPORT_FILEFORMAT_FNT 1 //#define SUPPORT_FILEFORMAT_BDF 1 // Support text management functions From 9d67f4734b59244b5b10d45ce7c8eed76323c3b5 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 18 May 2024 07:41:37 +0200 Subject: [PATCH 5/5] REVIEWED: LoadBMFont(), issue on not glyph data initialized --- src/rtext.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rtext.c b/src/rtext.c index b5ba17e3a..1ddb62509 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -2240,7 +2240,11 @@ static Font LoadBMFont(const char *fileName) // Fill character image data from full font data font.glyphs[i].image = ImageFromImage(fullFont, font.recs[i]); } - else TRACELOG(LOG_WARNING, "FONT: [%s] Some characters data not correctly provided", fileName); + else + { + font.glyphs[i].image = GenImageColor(font.recs[i].width, font.recs[i].height, BLACK); + TRACELOG(LOG_WARNING, "FONT: [%s] Some characters data not correctly provided", fileName); + } } UnloadImage(fullFont);