瀏覽代碼

Merge branch 'raysan5:master' into master

pull/4796/head
Jon Daniel 4 天之前
committed by GitHub
父節點
當前提交
b8fe0c47fa
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: B5690EEEBB952194
共有 20 個檔案被更改,包括 150 行新增132 行删除
  1. +122
    -1
      build.zig
  2. +1
    -0
      build.zig.zon
  3. +0
    -110
      examples/build.zig
  4. +4
    -1
      examples/core/core_custom_frame_control.c
  5. +7
    -4
      examples/core/core_window_flags.c
  6. +1
    -1
      parser/output/raylib_api.json
  7. +1
    -1
      parser/output/raylib_api.lua
  8. +1
    -1
      parser/output/raylib_api.txt
  9. +1
    -1
      parser/output/raylib_api.xml
  10. +1
    -1
      projects/Notepad++/raylib_npp_parser/raylib_npp.xml
  11. +1
    -1
      projects/Notepad++/raylib_npp_parser/raylib_to_parse.h
  12. +1
    -1
      src/platforms/rcore_android.c
  13. +1
    -1
      src/platforms/rcore_desktop_glfw.c
  14. +1
    -1
      src/platforms/rcore_desktop_rgfw.c
  15. +2
    -2
      src/platforms/rcore_desktop_sdl.c
  16. +1
    -1
      src/platforms/rcore_drm.c
  17. +1
    -1
      src/platforms/rcore_template.c
  18. +1
    -1
      src/platforms/rcore_web.c
  19. +1
    -1
      src/raylib.h
  20. +1
    -1
      src/rlgl.h

+ 122
- 1
build.zig 查看文件

@ -179,7 +179,11 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
raylib.addIncludePath(b.path("src/platforms"));
switch (target.result.os.tag) {
.windows => {
try c_source_files.append("src/rglfw.c");
switch (options.platform) {
.glfw => try c_source_files.append("src/rglfw.c"),
.rgfw, .sdl, .drm => {},
}
raylib.linkSystemLibrary("winmm");
raylib.linkSystemLibrary("gdi32");
raylib.linkSystemLibrary("opengl32");
@ -406,6 +410,16 @@ pub fn build(b: *std.Build) !void {
lib.installHeader(b.path("src/rlgl.h"), "rlgl.h");
b.installArtifact(lib);
const examples = b.step("examples", "Build/Install all examples");
examples.dependOn(try addExamples("audio", b, target, optimize, lib));
examples.dependOn(try addExamples("core", b, target, optimize, lib));
examples.dependOn(try addExamples("models", b, target, optimize, lib));
examples.dependOn(try addExamples("others", b, target, optimize, lib));
examples.dependOn(try addExamples("shaders", b, target, optimize, lib));
examples.dependOn(try addExamples("shapes", b, target, optimize, lib));
examples.dependOn(try addExamples("text", b, target, optimize, lib));
examples.dependOn(try addExamples("textures", b, target, optimize, lib));
}
fn waylandGenerate(
@ -430,3 +444,110 @@ fn waylandGenerate(
raylib.step.dependOn(&client_step.step);
raylib.step.dependOn(&private_step.step);
}
fn addExamples(
comptime module: []const u8,
b: *std.Build,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
raylib: *std.Build.Step.Compile,
) !*std.Build.Step {
if (target.result.os.tag == .emscripten) {
@panic("Emscripten building via Zig unsupported");
}
const all = b.step(module, "All " ++ module ++ " examples");
const module_subpath = b.pathJoin(&.{ "examples", module });
var dir = try std.fs.cwd().openDir(b.pathFromRoot(module_subpath), .{ .iterate = true });
defer if (comptime builtin.zig_version.minor >= 12) dir.close();
var iter = dir.iterate();
while (try iter.next()) |entry| {
if (entry.kind != .file) continue;
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
const name = entry.name[0..extension_idx];
const path = b.pathJoin(&.{ module_subpath, entry.name });
// zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue;
const exe = b.addExecutable(.{
.name = name,
.target = target,
.optimize = optimize,
});
exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe.linkLibC();
// special examples that test using these external dependencies directly
// alongside raylib
if (std.mem.eql(u8, name, "rlgl_standalone")) {
exe.addIncludePath(b.path("src"));
exe.addIncludePath(b.path("src/external/glfw/include"));
if (!hasCSource(raylib.root_module, "rglfw.c")) {
exe.addCSourceFile(.{ .file = b.path("src/rglfw.c"), .flags = &.{} });
}
}
if (std.mem.eql(u8, name, "raylib_opengl_interop")) {
exe.addIncludePath(b.path("src/external"));
}
exe.linkLibrary(raylib);
switch (target.result.os.tag) {
.windows => {
exe.linkSystemLibrary("winmm");
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("opengl32");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
.linux => {
exe.linkSystemLibrary("GL");
exe.linkSystemLibrary("rt");
exe.linkSystemLibrary("dl");
exe.linkSystemLibrary("m");
exe.linkSystemLibrary("X11");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
.macos => {
exe.linkFramework("Foundation");
exe.linkFramework("Cocoa");
exe.linkFramework("OpenGL");
exe.linkFramework("CoreAudio");
exe.linkFramework("CoreVideo");
exe.linkFramework("IOKit");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
else => {
@panic("Unsupported OS");
},
}
const install_cmd = b.addInstallArtifact(exe, .{});
const run_cmd = b.addRunArtifact(exe);
run_cmd.cwd = b.path(module_subpath);
run_cmd.step.dependOn(&install_cmd.step);
const run_step = b.step(name, name);
run_step.dependOn(&run_cmd.step);
all.dependOn(&install_cmd.step);
}
return all;
}
fn hasCSource(module: *std.Build.Module, name: []const u8) bool {
for (module.link_objects.items) |o| switch (o) {
.c_source_file => |c| if (switch (c.file) {
.src_path => |s| std.ascii.endsWithIgnoreCase(s.sub_path, name),
.generated, .cwd_relative, .dependency => false,
}) return true,
.c_source_files => |s| for (s.files) |c| if (std.ascii.endsWithIgnoreCase(c, name)) return true,
else => {},
};
return false;
}

+ 1
- 0
build.zig.zon 查看文件

@ -22,5 +22,6 @@
"build.zig",
"build.zig.zon",
"src",
"examples",
},
}

+ 0
- 110
examples/build.zig 查看文件

@ -1,110 +0,0 @@
const std = @import("std");
const builtin = @import("builtin");
// This has been tested to work with zig 0.12.0
fn add_module(comptime module: []const u8, b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step {
if (target.result.os.tag == .emscripten) {
@panic("Emscripten building via Zig unsupported");
}
const all = b.step(module, "All " ++ module ++ " examples");
var dir = try std.fs.cwd().openDir(module, .{ .iterate = true });
defer if (comptime builtin.zig_version.minor >= 12) dir.close();
var iter = dir.iterate();
while (try iter.next()) |entry| {
if (entry.kind != .file) continue;
const extension_idx = std.mem.lastIndexOf(u8, entry.name, ".c") orelse continue;
const name = entry.name[0..extension_idx];
const path = try std.fs.path.join(b.allocator, &.{ module, entry.name });
// zig's mingw headers do not include pthread.h
if (std.mem.eql(u8, "core_loading_thread", name) and target.result.os.tag == .windows) continue;
const exe = b.addExecutable(.{
.name = name,
.target = target,
.optimize = optimize,
});
exe.addCSourceFile(.{ .file = b.path(path), .flags = &.{} });
exe.linkLibC();
exe.addObjectFile(switch (target.result.os.tag) {
.windows => b.path("../zig-out/lib/raylib.lib"),
.linux => b.path("../zig-out/lib/libraylib.a"),
.macos => b.path("../zig-out/lib/libraylib.a"),
.emscripten => b.path("../zig-out/lib/libraylib.a"),
else => @panic("Unsupported OS"),
});
exe.addIncludePath(b.path("../src"));
exe.addIncludePath(b.path("../src/external"));
exe.addIncludePath(b.path("../src/external/glfw/include"));
switch (target.result.os.tag) {
.windows => {
exe.linkSystemLibrary("winmm");
exe.linkSystemLibrary("gdi32");
exe.linkSystemLibrary("opengl32");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
.linux => {
exe.linkSystemLibrary("GL");
exe.linkSystemLibrary("rt");
exe.linkSystemLibrary("dl");
exe.linkSystemLibrary("m");
exe.linkSystemLibrary("X11");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
.macos => {
exe.linkFramework("Foundation");
exe.linkFramework("Cocoa");
exe.linkFramework("OpenGL");
exe.linkFramework("CoreAudio");
exe.linkFramework("CoreVideo");
exe.linkFramework("IOKit");
exe.root_module.addCMacro("PLATFORM_DESKTOP", "");
},
else => {
@panic("Unsupported OS");
},
}
const install_cmd = b.addInstallArtifact(exe, .{});
const run_cmd = b.addRunArtifact(exe);
run_cmd.cwd = b.path(module);
run_cmd.step.dependOn(&install_cmd.step);
const run_step = b.step(name, name);
run_step.dependOn(&run_cmd.step);
all.dependOn(&install_cmd.step);
}
return all;
}
pub fn build(b: *std.Build) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
const all = b.getInstallStep();
all.dependOn(try add_module("audio", b, target, optimize));
all.dependOn(try add_module("core", b, target, optimize));
all.dependOn(try add_module("models", b, target, optimize));
all.dependOn(try add_module("others", b, target, optimize));
all.dependOn(try add_module("shaders", b, target, optimize));
all.dependOn(try add_module("shapes", b, target, optimize));
all.dependOn(try add_module("text", b, target, optimize));
all.dependOn(try add_module("textures", b, target, optimize));
}

+ 4
- 1
examples/core/core_custom_frame_control.c 查看文件

@ -95,7 +95,10 @@ int main(void)
DrawText("PRESS SPACE to PAUSE MOVEMENT", 10, GetScreenHeight() - 60, 20, GRAY);
DrawText("PRESS UP | DOWN to CHANGE TARGET FPS", 10, GetScreenHeight() - 30, 20, GRAY);
DrawText(TextFormat("TARGET FPS: %i", targetFPS), GetScreenWidth() - 220, 10, 20, LIME);
DrawText(TextFormat("CURRENT FPS: %i", (int)(1.0f/deltaTime)), GetScreenWidth() - 220, 40, 20, GREEN);
if (deltaTime != 0)
{
DrawText(TextFormat("CURRENT FPS: %i", (int)(1.0f/deltaTime)), GetScreenWidth() - 220, 40, 20, GREEN);
}
EndDrawing();

+ 7
- 4
examples/core/core_window_flags.c 查看文件

@ -52,7 +52,7 @@ int main(void)
int framesCounter = 0;
o">//SetTargetFPS(60); // Set our game to run at 60 frames-per-second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//----------------------------------------------------------
// Main game loop
@ -97,7 +97,10 @@ int main(void)
if (IsWindowState(FLAG_WINDOW_MINIMIZED))
{
framesCounter++;
if (framesCounter >= 240) RestoreWindow(); // Restore window after 3 seconds
if (framesCounter >= 240) {
RestoreWindow(); // Restore window after 3 seconds
framesCounter = 0;
}
}
if (IsKeyPressed(KEY_M))
@ -163,9 +166,9 @@ int main(void)
if (IsWindowState(FLAG_WINDOW_UNDECORATED)) DrawText("[D] FLAG_WINDOW_UNDECORATED: on", 10, 120, 10, LIME);
else DrawText("[D] FLAG_WINDOW_UNDECORATED: off", 10, 120, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_HIDDEN)) DrawText("[H] FLAG_WINDOW_HIDDEN: on", 10, 140, 10, LIME);
else DrawText("[H] FLAG_WINDOW_HIDDEN: off", 10, 140, 10, MAROON);
else DrawText("[H] FLAG_WINDOW_HIDDEN: off (hides for 3 seconds)", 10, 140, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_MINIMIZED)) DrawText("[N] FLAG_WINDOW_MINIMIZED: on", 10, 160, 10, LIME);
else DrawText("[N] FLAG_WINDOW_MINIMIZED: off", 10, 160, 10, MAROON);
else DrawText("[N] FLAG_WINDOW_MINIMIZED: off (restores after 3 seconds)", 10, 160, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_MAXIMIZED)) DrawText("[M] FLAG_WINDOW_MAXIMIZED: on", 10, 180, 10, LIME);
else DrawText("[M] FLAG_WINDOW_MAXIMIZED: off", 10, 180, 10, MAROON);
if (IsWindowState(FLAG_WINDOW_UNFOCUSED)) DrawText("[G] FLAG_WINDOW_UNFOCUSED: on", 10, 200, 10, LIME);

+ 1
- 1
parser/output/raylib_api.json 查看文件

@ -3280,7 +3280,7 @@
},
{
"name": "RestoreWindow",
"description": "Set window state: not minimized/maximized",
"description": "Restore window from being minimized/maximized",
"returnType": "void"
},
{

+ 1
- 1
parser/output/raylib_api.lua 查看文件

@ -3223,7 +3223,7 @@ return {
},
{
name = "RestoreWindow",
description = "Set window state: not minimized/maximized",
description = "Restore window from being minimized/maximized",
returnType = "void"
},
{

+ 1
- 1
parser/output/raylib_api.txt 查看文件

@ -1085,7 +1085,7 @@ Function 017: MinimizeWindow() (0 input parameters)
Function 018: RestoreWindow() (0 input parameters)
Name: RestoreWindow
Return type: void
Description: Set window state: not minimized/maximized
Description: Restore window from being minimized/maximized
No input parameters
Function 019: SetWindowIcon() (1 input parameters)
Name: SetWindowIcon

+ 1
- 1
parser/output/raylib_api.xml 查看文件

@ -720,7 +720,7 @@
</Function>
<Function name="MinimizeWindow" retType="void" paramCount="0" desc="Set window state: minimized, if resizable">
</Function>
<Function name="RestoreWindow" retType="void" paramCount="0" desc="Set window state: not minimized/maximized">
<Function name="RestoreWindow" retType="void" paramCount="0" desc="Restore window from being minimized/maximized">
</Function>
<Function name="SetWindowIcon" retType="void" paramCount="1" desc="Set icon for window (single image, RGBA 32bit)">
<Param type="Image" name="image" desc="" />

+ 1
- 1
projects/Notepad++/raylib_npp_parser/raylib_npp.xml 查看文件

@ -65,7 +65,7 @@
<Overload retVal="void" descr="Set window state: minimized, if resizable"></Overload>
</KeyWord>
<KeyWord name="RestoreWindow" func="yes">
<Overload retVal="void" descr="Set window state: not minimized/maximized"></Overload>
<Overload retVal="void" descr="Restore window from being minimized/maximized"></Overload>
</KeyWord>
<KeyWord name="SetWindowIcon" func="yes">
<Overload retVal="void" descr="Set icon for window (single image, RGBA 32bit)">

+ 1
- 1
projects/Notepad++/raylib_npp_parser/raylib_to_parse.h 查看文件

@ -20,7 +20,7 @@ RLAPI void ToggleFullscreen(void); // Toggle wind
RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed, resizes window to match monitor resolution
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized
RLAPI void RestoreWindow(void); // Restore window from being minimized/maximized
RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit)
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit)
RLAPI void SetWindowTitle(const char *title); // Set title for window

+ 1
- 1
src/platforms/rcore_android.c 查看文件

@ -337,7 +337,7 @@ void MinimizeWindow(void)
TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform");
}
// Set window state: not minimized/maximized
// Restore window from being minimized/maximized
void RestoreWindow(void)
{
TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform");

+ 1
- 1
src/platforms/rcore_desktop_glfw.c 查看文件

@ -292,7 +292,7 @@ void MinimizeWindow(void)
glfwIconifyWindow(platform.handle);
}
// Set window state: not minimized/maximized
// Restore window from being minimized/maximized
void RestoreWindow(void)
{
if (glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE)

+ 1
- 1
src/platforms/rcore_desktop_rgfw.c 查看文件

@ -339,7 +339,7 @@ void MinimizeWindow(void)
RGFW_window_minimize(platform.window);
}
// Set window state: not minimized/maximized
// Restore window from being minimized/maximized
void RestoreWindow(void)
{
if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window);

+ 2
- 2
src/platforms/rcore_desktop_sdl.c 查看文件

@ -508,7 +508,7 @@ void MinimizeWindow(void)
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED;
}
// Set window state: not minimized/maximized
// Restore window from being minimized/maximized
void RestoreWindow(void)
{
SDL_RestoreWindow(platform.window);
@ -1670,7 +1670,7 @@ void PollInputEvents(void)
{
int jid = event.jdevice.which; // Joystick device index
if (o">!CORE.Input.Gamepad.ready[jid] && (jid < MAX_GAMEPADS))
if (CORE.Input.Gamepad.ready[jid] && (jid < MAX_GAMEPADS))
{
platform.gamepad[jid] = SDL_GameControllerOpen(jid);
platform.gamepadId[jid] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(platform.gamepad[jid]));

+ 1
- 1
src/platforms/rcore_drm.c 查看文件

@ -277,7 +277,7 @@ void MinimizeWindow(void)
TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform");
}
// Set window state: not minimized/maximized
// Restore window from being minimized/maximized
void RestoreWindow(void)
{
TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform");

+ 1
- 1
src/platforms/rcore_template.c 查看文件

@ -114,7 +114,7 @@ void MinimizeWindow(void)
TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform");
}
// Set window state: not minimized/maximized
// Restore window from being minimized/maximized
void RestoreWindow(void)
{
TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform");

+ 1
- 1
src/platforms/rcore_web.c 查看文件

@ -350,7 +350,7 @@ void MinimizeWindow(void)
TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform");
}
// Set window state: not minimized/maximized
// Restore window from being minimized/maximized
void RestoreWindow(void)
{
if ((glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE) && (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED))

+ 1
- 1
src/raylib.h 查看文件

@ -987,7 +987,7 @@ RLAPI void ToggleFullscreen(void); // Toggle wind
RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed, resizes window to match monitor resolution
RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable
RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable
RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized
RLAPI void RestoreWindow(void); // Restore window from being minimized/maximized
RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit)
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit)
RLAPI void SetWindowTitle(const char *title); // Set title for window

+ 1
- 1
src/rlgl.h 查看文件

@ -3684,7 +3684,7 @@ unsigned char *rlReadScreenPixels(int width, int height)
// Flip image vertically!
// NOTE: Alpha value has already been applied to RGB in framebuffer, we don't need it!
for (int y = height - 1; y >= height / 2; y--)
for (int y = height - 1; y >= height/2; y--)
{
for (int x = 0; x < (width*4); x += 4)
{

Loading…
取消
儲存