From 44c6cd2d37504a54c37ca9890889d8c34ba3f332 Mon Sep 17 00:00:00 2001 From: InventorXtreme <43659737+InventorXtreme@users.noreply.github.com> Date: Thu, 11 Jul 2024 03:59:26 -0400 Subject: [PATCH 1/6] [build.zig] GLFW Platform Detection Support (#4150) * Zig Both Linux Desktop Platform Support * Formating and Default Fix Made formating fit within raylib standards and changed the default option to support both X11 and wayland on Linux. * caught one hiding tab --- src/build.zig | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/build.zig b/src/build.zig index 3b462de617fe..2da5cbd04d37 100644 --- a/src/build.zig +++ b/src/build.zig @@ -117,31 +117,29 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib" }); raylib.addIncludePath(.{ .cwd_relative = "/usr/include" }); + if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) { - switch (options.linux_display_backend) { - .X11 => { raylib.defineCMacro("_GLFW_X11", null); raylib.linkSystemLibrary("X11"); - }, - .Wayland => { - raylib.defineCMacro("_GLFW_WAYLAND", null); - raylib.linkSystemLibrary("wayland-client"); - raylib.linkSystemLibrary("wayland-cursor"); - raylib.linkSystemLibrary("wayland-egl"); - raylib.linkSystemLibrary("xkbcommon"); - raylib.addIncludePath(b.path("src")); - waylandGenerate(b, raylib, "wayland.xml", "wayland-client-protocol"); - waylandGenerate(b, raylib, "xdg-shell.xml", "xdg-shell-client-protocol"); - waylandGenerate(b, raylib, "xdg-decoration-unstable-v1.xml", "xdg-decoration-unstable-v1-client-protocol"); - waylandGenerate(b, raylib, "viewporter.xml", "viewporter-client-protocol"); - waylandGenerate(b, raylib, "relative-pointer-unstable-v1.xml", "relative-pointer-unstable-v1-client-protocol"); - waylandGenerate(b, raylib, "pointer-constraints-unstable-v1.xml", "pointer-constraints-unstable-v1-client-protocol"); - waylandGenerate(b, raylib, "fractional-scale-v1.xml", "fractional-scale-v1-client-protocol"); - waylandGenerate(b, raylib, "xdg-activation-v1.xml", "xdg-activation-v1-client-protocol"); - waylandGenerate(b, raylib, "idle-inhibit-unstable-v1.xml", "idle-inhibit-unstable-v1-client-protocol"); - }, } + if (options.linux_display_backend == .Wayland or options.linux_display_backend == .Both) { + raylib.defineCMacro("_GLFW_WAYLAND", null); + raylib.linkSystemLibrary("wayland-client"); + raylib.linkSystemLibrary("wayland-cursor"); + raylib.linkSystemLibrary("wayland-egl"); + raylib.linkSystemLibrary("xkbcommon"); + raylib.addIncludePath(b.path("src")); + waylandGenerate(b, raylib, "wayland.xml", "wayland-client-protocol"); + waylandGenerate(b, raylib, "xdg-shell.xml", "xdg-shell-client-protocol"); + waylandGenerate(b, raylib, "xdg-decoration-unstable-v1.xml", "xdg-decoration-unstable-v1-client-protocol"); + waylandGenerate(b, raylib, "viewporter.xml", "viewporter-client-protocol"); + waylandGenerate(b, raylib, "relative-pointer-unstable-v1.xml", "relative-pointer-unstable-v1-client-protocol"); + waylandGenerate(b, raylib, "pointer-constraints-unstable-v1.xml", "pointer-constraints-unstable-v1-client-protocol"); + waylandGenerate(b, raylib, "fractional-scale-v1.xml", "fractional-scale-v1-client-protocol"); + waylandGenerate(b, raylib, "xdg-activation-v1.xml", "xdg-activation-v1-client-protocol"); + waylandGenerate(b, raylib, "idle-inhibit-unstable-v1.xml", "idle-inhibit-unstable-v1-client-protocol"); + } raylib.defineCMacro("PLATFORM_DESKTOP", null); } else { if (options.opengl_version == .auto) { @@ -253,7 +251,7 @@ pub const Options = struct { raygui: bool = false, platform_drm: bool = false, shared: bool = false, - linux_display_backend: LinuxDisplayBackend = .X11, + linux_display_backend: LinuxDisplayBackend = .Both, opengl_version: OpenglVersion = .auto, raygui_dependency_name: []const u8 = "raygui", @@ -284,6 +282,7 @@ pub const OpenglVersion = enum { pub const LinuxDisplayBackend = enum { X11, Wayland, + Both, }; pub fn build(b: *std.Build) !void { From 8d5374a443509036063a350d1649408e009425e7 Mon Sep 17 00:00:00 2001 From: Kai Kitagawa-Jones Date: Thu, 11 Jul 2024 21:31:13 +0200 Subject: [PATCH 2/6] Replace `glGetInteger64v` with `glGetBufferParameteri64v` (#4154) --- src/rlgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rlgl.h b/src/rlgl.h index 5b921ab9ca22..ccb53a624919 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -4401,7 +4401,7 @@ unsigned int rlGetShaderBufferSize(unsigned int id) #if defined(GRAPHICS_API_OPENGL_43) glBindBuffer(GL_SHADER_STORAGE_BUFFER, id); - glGetInteger64v(GL_SHADER_STORAGE_BUFFER_SIZE, &size); + glGetBufferParameteri64v(GL_SHADER_STORAGE_BUFFER, GL_BUFFER_SIZE, &size); #endif return (size > 0)? (unsigned int)size : 0; From 5ede47618bd9f9a440af648da1b4817e51644994 Mon Sep 17 00:00:00 2001 From: jkaup <29462864+jkaup@users.noreply.github.com> Date: Sun, 14 Jul 2024 00:10:28 +0300 Subject: [PATCH 3/6] Fix crash when switching playback device (#4102) Co-authored-by: jj --- src/external/miniaudio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/external/miniaudio.h b/src/external/miniaudio.h index 47332e11a1a3..787c626ad18c 100644 --- a/src/external/miniaudio.h +++ b/src/external/miniaudio.h @@ -21473,7 +21473,9 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device MA_ASSERT(pContext != NULL); MA_ASSERT(ppMMDevice != NULL); + ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE); hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); + ma_CoUninitialize(pContext); if (FAILED(hr)) { ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.\n"); return ma_result_from_HRESULT(hr); From 576bee5cce1254791561b57f2137e2a3b611d26a Mon Sep 17 00:00:00 2001 From: MrScautHD <65916181+MrScautHD@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:00:00 +0200 Subject: [PATCH 4/6] Adding GetKeyName(int key) (WIP) (#4161) --- src/platforms/rcore_android.c | 7 +++++++ src/platforms/rcore_desktop_glfw.c | 6 ++++++ src/platforms/rcore_desktop_rgfw.c | 7 +++++++ src/platforms/rcore_desktop_sdl.c | 6 ++++++ src/platforms/rcore_drm.c | 7 +++++++ src/platforms/rcore_template.c | 7 +++++++ src/platforms/rcore_web.c | 7 +++++++ 7 files changed, 47 insertions(+) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 8fc51d0e1f9f..68ae979ee64b 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -632,6 +632,13 @@ void SetMouseCursor(int cursor) TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform"); } +// Get physical key name. +const char *GetKeyName(int key) +{ + TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform"); + return ""; +} + // Register all input events void PollInputEvents(void) { diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 56a4e2619ccc..947a80335205 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1075,6 +1075,12 @@ void SetMouseCursor(int cursor) } } +// Get physical key name. +const char *GetKeyName(int key) +{ + return glfwGetKeyName(key, glfwGetKeyScancode(key)); +} + // Register all input events void PollInputEvents(void) { diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 83430f511a83..cfc091172606 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -756,6 +756,13 @@ void SetMouseCursor(int cursor) RGFW_window_setMouseStandard(platform.window, cursor); } +// Get physical key name. +const char *GetKeyName(int key) +{ + TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform"); + return ""; +} + static KeyboardKey ConvertScancodeToKey(u32 keycode); // TODO: Review function to avoid duplicate with RSGL diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 3d6293597bc3..794f9e6a088f 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -966,6 +966,12 @@ void SetMouseCursor(int cursor) CORE.Input.Mouse.cursor = cursor; } +// Get physical key name. +const char *GetKeyName(int key) +{ + return SDL_GetKeyName(key); +} + static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event) { CORE.Input.Touch.pointCount = SDL_GetNumTouchFingers(event.touchId); diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index f888d0e4735f..291fd93c7446 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -628,6 +628,13 @@ void SetMouseCursor(int cursor) TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform"); } +// Get physical key name. +const char *GetKeyName(int key) +{ + TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform"); + return ""; +} + // Register all input events void PollInputEvents(void) { diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 7a48c465e558..938f4ed7d3e3 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -384,6 +384,13 @@ void SetMouseCursor(int cursor) TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform"); } +// Get physical key name. +const char *GetKeyName(int key) +{ + TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform"); + return ""; +} + // Register all input events void PollInputEvents(void) { diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 47b8d42d6abe..937e15acd491 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -884,6 +884,13 @@ void SetMouseCursor(int cursor) } } +// Get physical key name. +const char *GetKeyName(int key) +{ + TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform"); + return ""; +} + // Register all input events void PollInputEvents(void) { From 0c03cbff90acf8afe3976688aaa8239e4b5a637f Mon Sep 17 00:00:00 2001 From: red thing Date: Tue, 16 Jul 2024 05:00:30 -0700 Subject: [PATCH 5/6] Update BINDINGS.md: dray binding supports raylib 5.0 (#4163) --- BINDINGS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BINDINGS.md b/BINDINGS.md index 22b740588dd5..1196acc4e5ab 100644 --- a/BINDINGS.md +++ b/BINDINGS.md @@ -21,7 +21,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers | [ray-cyber](https://github.com/fubark/ray-cyber) | **5.0** | [Cyber](https://cyberscript.dev) | MIT | | [dart-raylib](https://gitlab.com/wolfenrain/dart-raylib) | 4.0 | [Dart](https://dart.dev) | MIT | | [bindbc-raylib3](https://github.com/o3o/bindbc-raylib3) | **5.0** | [D](https://dlang.org) | BSL-1.0 | -| [dray](https://github.com/redthing1/dray) | 4.2 | [D](https://dlang.org) | Apache-2.0 | +| [dray](https://github.com/redthing1/dray) | **5.0** | [D](https://dlang.org) | Apache-2.0 | | [raylib-d](https://github.com/schveiguy/raylib-d) | **5.0** | [D](https://dlang.org) | Zlib | | [rayex](https://github.com/shiryel/rayex) | 3.7 | [elixir](https://elixir-lang.org) | Apache-2.0 | | [raylib-factor](https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor) | 4.5 | [Factor](https://factorcode.org) | BSD | From 24726a4bc2f2c265cfc78b7c56f9a9c2143df4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1zaro=20Albuquerque?= <33807434+lzralbu@users.noreply.github.com> Date: Tue, 16 Jul 2024 08:16:41 -0400 Subject: [PATCH 6/6] Removes the redundant USE_AUDIO flag (#4158) --- cmake/CompileDefinitions.cmake | 1 - src/CMakeLists.txt | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmake/CompileDefinitions.cmake b/cmake/CompileDefinitions.cmake index 0acbe2fa5b96..cefafdeb7253 100644 --- a/cmake/CompileDefinitions.cmake +++ b/cmake/CompileDefinitions.cmake @@ -11,7 +11,6 @@ endfunction() if(${CUSTOMIZE_BUILD}) target_compile_definitions("raylib" PRIVATE EXTERNAL_CONFIG_FLAGS) - define_if("raylib" USE_AUDIO) foreach(FLAG IN LISTS CONFIG_HEADER_FLAGS) string(REGEX MATCH "([^=]+)=(.+)" _ ${FLAG}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8f4d0e26e681..dd940b36c371 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,6 +29,7 @@ set(raylib_public_headers # Sources to be compiled set(raylib_sources + raudio.c rcore.c rmodels.c rshapes.c @@ -47,14 +48,12 @@ endif () # Produces a variable LIBS_PRIVATE that will be used later include(LibraryConfigurations) -if (USE_AUDIO) +if (SUPPORT_MODULE_RAUDIO) MESSAGE(STATUS "Audio Backend: miniaudio") - list(APPEND raylib_sources raudio.c) else () - MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)") + MESSAGE(STATUS "Audio Backend: None (-DCUSTOMIZE_BUILD=ON -DSUPPORT_MODULE_RAUDIO=OFF)") endif () - add_library(raylib ${raylib_sources} ${raylib_public_headers}) if (NOT BUILD_SHARED_LIBS)