From 055fd752c273f246515375d79fca511eef8ecf1b Mon Sep 17 00:00:00 2001 From: Danil <61111955+localwhale20@users.noreply.github.com> Date: Thu, 20 Jul 2023 11:56:35 +0300 Subject: [PATCH 1/4] Fixed GetMonitorName description (#3184) (#3189) --- src/raylib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raylib.h b/src/raylib.h index c20a69d2b..e99d674e2 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -974,7 +974,7 @@ RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specifi RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor -RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor +RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor RLAPI void SetClipboardText(const char *text); // Set clipboard text content RLAPI const char *GetClipboardText(void); // Get clipboard text content RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling From 5635e4214cb31b0c83e2d65f32af1cc3d40ffdf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Gonz=C3=A1lez=20Palomo?= Date: Thu, 20 Jul 2023 13:41:35 +0200 Subject: [PATCH 2/4] Add note about sample format to AttachAudioStreamProcessor() (#3188) --- src/raylib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raylib.h b/src/raylib.h index e99d674e2..108ab0245 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1588,7 +1588,7 @@ RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data -RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream +RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives the samples as s RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline, receives the samples as s From 1310617a922c12256259eca69da0d746f5d10b71 Mon Sep 17 00:00:00 2001 From: smalltimewizard <83366732+smalltimewizard@users.noreply.github.com> Date: Thu, 20 Jul 2023 07:50:56 -0400 Subject: [PATCH 3/4] Optimization of ImageDrawRectangleRec() (#3185) A significant performance increase can be had by copying the first row to all other rows. --- src/rtextures.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/rtextures.c b/src/rtextures.c index bc53e1cec..ca341bc81 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -3135,26 +3135,28 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color) if (rec.height < 0) rec.height = 0; int sy = (int)rec.y; - int ey = sy + (int)rec.height; - int sx = (int)rec.x; int bytesPerPixel = GetPixelDataSize(1, 1, dst->format); - for (int y = sy; y < ey; y++) + // Fill in the first pixel of the first row based on image format + ImageDrawPixel(dst, sx, sy, color); + + int bytesOffset = ((sy*dst->width) + sx)*bytesPerPixel; + unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset; + + // Repeat the first pixel data throughout the row + for (int x = 1; x < (int)rec.width; x++) { - // Fill in the first pixel of the row based on image format - ImageDrawPixel(dst, sx, y, color); - - int bytesOffset = ((y*dst->width) + sx)*bytesPerPixel; - unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset; - - // Repeat the first pixel data throughout the row - for (int x = 1; x < (int)rec.width; x++) - { - memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel); - } + memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel); } + + // Repeat the first row data for all other rows + int bytesPerRow = bytesPerPixel * (int)rec.width; + for (int y = 1; y < (int)rec.height; y++) + { + memcpy(pSrcPixel + (y*dst->width)*bytesPerPixel, pSrcPixel, bytesPerRow); + } } // Draw rectangle lines within an image From ad2338b994785c887528c91a843d6720cac2c2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20V=C3=A1clav=20Flasar?= <109527915+jakubvf@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:08:35 +0200 Subject: [PATCH 4/4] build.zig: Support for building with PLAFORM_DRM (#3191) - Adds an option -Dplatform_drm when using zig build - When building for linux, checks whether -Dplatform_drm is present and configures the build accordingly. --- src/build.zig | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/build.zig b/src/build.zig index 8485322d5..64480a4f1 100644 --- a/src/build.zig +++ b/src/build.zig @@ -16,7 +16,10 @@ pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.built }); raylib.linkLibC(); - raylib.addIncludePath(srcdir ++ "/external/glfw/include"); + // No GLFW required on PLATFORM_DRM + if (!options.platform_drm) { + raylib.addIncludePath(srcdir ++ "/external/glfw/include"); + } raylib.addCSourceFiles(&.{ srcdir ++ "/raudio.c", @@ -49,15 +52,32 @@ pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.built raylib.defineCMacro("PLATFORM_DESKTOP", null); }, .linux => { - raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags); - raylib.linkSystemLibrary("GL"); - raylib.linkSystemLibrary("rt"); - raylib.linkSystemLibrary("dl"); - raylib.linkSystemLibrary("m"); - raylib.linkSystemLibrary("X11"); - raylib.addIncludePath("/usr/include"); + if (!options.platform_drm) { + raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags); + raylib.linkSystemLibrary("GL"); + raylib.linkSystemLibrary("rt"); + raylib.linkSystemLibrary("dl"); + raylib.linkSystemLibrary("m"); + raylib.linkSystemLibrary("X11"); + raylib.addIncludePath("/usr/include"); - raylib.defineCMacro("PLATFORM_DESKTOP", null); + raylib.defineCMacro("PLATFORM_DESKTOP", null); + } else { + raylib.linkSystemLibrary("GLESv2"); + raylib.linkSystemLibrary("EGL"); + raylib.linkSystemLibrary("drm"); + raylib.linkSystemLibrary("gbm"); + raylib.linkSystemLibrary("pthread"); + raylib.linkSystemLibrary("rt"); + raylib.linkSystemLibrary("m"); + raylib.linkSystemLibrary("dl"); + raylib.addIncludePath("/usr/include/libdrm"); + + raylib.defineCMacro("PLATFORM_DRM", null); + raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null); + raylib.defineCMacro("EGL_NO_X11", null); + raylib.defineCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "2048"); + } }, .freebsd, .openbsd, .netbsd, .dragonfly => { raylib.addCSourceFiles(&.{srcdir ++ "/rglfw.c"}, raylib_flags); @@ -115,8 +135,9 @@ pub fn addRaylib(b: *std.Build, target: std.zig.CrossTarget, optimize: std.built return raylib; } -const Options = struct { +pub const Options = struct { raygui: bool = false, + platform_drm: bool = false, }; pub fn build(b: *std.Build) void { @@ -131,9 +152,11 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const raygui = b.option(bool, "raygui", "Compile with raygui support"); + const platform_drm = b.option(bool, "platform_drm", "Compile raylib in native mode (no X11)"); const lib = addRaylib(b, target, optimize, .{ .raygui = raygui orelse false, + .platform_drm = platform_drm orelse false, }); lib.installHeader("src/raylib.h", "raylib.h");