Merge branch 'master' of https://github.com/raysan5/raylib into pure
This commit is contained in:
commit
fc96f333a4
39 changed files with 1906 additions and 5838 deletions
|
|
@ -31,7 +31,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
|||
| [raylib-go](https://github.com/gen2brain/raylib-go) | **5.0** | [Go](https://golang.org) | Zlib |
|
||||
| [raylib-guile](https://github.com/petelliott/raylib-guile) | **auto** | [Guile](https://www.gnu.org/software/guile) | Zlib |
|
||||
| [gforth-raylib](https://github.com/ArnautDaniel/gforth-raylib) | 3.5 | [Gforth](https://gforth.org) | **???** |
|
||||
| [h-raylib](https://github.com/Anut-py/h-raylib) | **5.1-dev** | [Haskell](https://haskell.org) | Apache-2.0 |
|
||||
| [h-raylib](https://github.com/Anut-py/h-raylib) | **5.5-dev** | [Haskell](https://haskell.org) | Apache-2.0 |
|
||||
| [raylib-hx](https://github.com/foreignsasquatch/raylib-hx) | 4.2 | [Haxe](https://haxe.org) | Zlib |
|
||||
| [hb-raylib](https://github.com/MarcosLeonardoMendezGerencir/hb-raylib) | 3.5 | [Harbour](https://harbour.github.io) | MIT |
|
||||
| [jaylib](https://github.com/janet-lang/jaylib) | **5.0** | [Janet](https://janet-lang.org) | MIT |
|
||||
|
|
|
|||
437
build.zig
437
build.zig
|
|
@ -1,11 +1,434 @@
|
|||
const std = @import("std");
|
||||
const raylib = @import("src/build.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
// This has been tested to work with zig 0.12.0
|
||||
pub fn build(b: *std.Build) !void {
|
||||
try raylib.build(b);
|
||||
/// Minimum supported version of Zig
|
||||
const min_ver = "0.12.0";
|
||||
|
||||
comptime {
|
||||
const order = std.SemanticVersion.order;
|
||||
const parse = std.SemanticVersion.parse;
|
||||
if (order(builtin.zig_version, parse(min_ver) catch unreachable) == .lt)
|
||||
@compileError("Raylib requires zig version " ++ min_ver);
|
||||
}
|
||||
|
||||
// expose helper functions to user's build.zig
|
||||
pub const addRaylib = raylib.addRaylib;
|
||||
pub const addRaygui = raylib.addRaygui;
|
||||
// NOTE(freakmangd): I don't like using a global here, but it prevents having to
|
||||
// get the flags a second time when adding raygui
|
||||
var raylib_flags_arr: std.ArrayListUnmanaged([]const u8) = .{};
|
||||
|
||||
// This has been tested with zig version 0.12.0
|
||||
pub fn addRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
|
||||
const raylib_dep = b.dependencyFromBuildZig(@This(), .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.raudio = options.raudio,
|
||||
.rmodels = options.rmodels,
|
||||
.rshapes = options.rshapes,
|
||||
.rtext = options.rtext,
|
||||
.rtextures = options.rtextures,
|
||||
.platform = options.platform,
|
||||
.shared = options.shared,
|
||||
.linux_display_backend = options.linux_display_backend,
|
||||
.opengl_version = options.opengl_version,
|
||||
.config = options.config,
|
||||
});
|
||||
const raylib = raylib_dep.artifact("raylib");
|
||||
|
||||
if (options.raygui) {
|
||||
const raygui_dep = b.dependency(options.raygui_dependency_name, .{});
|
||||
addRaygui(b, raylib, raygui_dep);
|
||||
}
|
||||
|
||||
return raylib;
|
||||
}
|
||||
|
||||
fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void {
|
||||
raylib.defineCMacro("PLATFORM_DESKTOP", null);
|
||||
|
||||
switch (platform) {
|
||||
.glfw => raylib.defineCMacro("PLATFORM_DESKTOP_GLFW", null),
|
||||
.rgfw => raylib.defineCMacro("PLATFORM_DESKTOP_RGFW", null),
|
||||
.sdl => raylib.defineCMacro("PLATFORM_DESKTOP_SDL", null),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
/// A list of all flags from `src/config.h` that one may override
|
||||
const config_h_flags = outer: {
|
||||
// Set this value higher if compile errors happen as `src/config.h` gets larger
|
||||
@setEvalBranchQuota(1 << 20);
|
||||
|
||||
const config_h = @embedFile("src/config.h");
|
||||
var flags: [std.mem.count(u8, config_h, "\n") + 1][]const u8 = undefined;
|
||||
|
||||
var i = 0;
|
||||
var lines = std.mem.tokenizeScalar(u8, config_h, '\n');
|
||||
while (lines.next()) |line| {
|
||||
if (!std.mem.containsAtLeast(u8, line, 1, "SUPPORT")) continue;
|
||||
if (std.mem.startsWith(u8, line, "//")) continue;
|
||||
if (std.mem.startsWith(u8, line, "#if")) continue;
|
||||
|
||||
var flag = std.mem.trimLeft(u8, line, " \t"); // Trim whitespace
|
||||
flag = flag["#define ".len - 1 ..]; // Remove #define
|
||||
flag = std.mem.trimLeft(u8, flag, " \t"); // Trim whitespace
|
||||
flag = flag[0 .. std.mem.indexOf(u8, flag, " ") orelse continue]; // Flag is only one word, so capture till space
|
||||
flag = "-D" ++ flag; // Prepend with -D
|
||||
|
||||
flags[i] = flag;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Uncomment this to check what flags normally get passed
|
||||
//@compileLog(flags[0..i].*);
|
||||
break :outer flags[0..i].*;
|
||||
};
|
||||
|
||||
fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
|
||||
raylib_flags_arr.clearRetainingCapacity();
|
||||
|
||||
const shared_flags = &[_][]const u8{
|
||||
"-fPIC",
|
||||
"-DBUILD_LIBTYPE_SHARED",
|
||||
};
|
||||
try raylib_flags_arr.appendSlice(b.allocator, &[_][]const u8{
|
||||
"-std=gnu99",
|
||||
"-D_GNU_SOURCE",
|
||||
"-DGL_SILENCE_DEPRECATION=199309L",
|
||||
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674
|
||||
});
|
||||
if (options.config.len > 0) {
|
||||
// Sets a flag indiciating the use of a custom `config.h`
|
||||
try raylib_flags_arr.append(b.allocator, "-DEXTERNAL_CONFIG_FLAGS");
|
||||
|
||||
// Splits a space-separated list of config flags into multiple flags
|
||||
//
|
||||
// Note: This means certain flags like `-x c++` won't be processed properly.
|
||||
// `-xc++` or similar should be used when possible
|
||||
var config_iter = std.mem.tokenizeScalar(u8, options.config, ' ');
|
||||
|
||||
// Apply config flags supplied by the user
|
||||
while (config_iter.next()) |config_flag|
|
||||
try raylib_flags_arr.append(b.allocator, config_flag);
|
||||
|
||||
// Apply all relevant configs from `src/config.h` *except* the user-specified ones
|
||||
//
|
||||
// Note: Currently using a suboptimal `O(m*n)` time algorithm where:
|
||||
// `m` corresponds roughly to the number of lines in `src/config.h`
|
||||
// `n` corresponds to the number of user-specified flags
|
||||
outer: for (config_h_flags) |flag| {
|
||||
// If a user already specified the flag, skip it
|
||||
while (config_iter.next()) |config_flag| {
|
||||
// For a user-specified flag to match, it must share the same prefix and have the
|
||||
// same length or be followed by an equals sign
|
||||
if (!std.mem.startsWith(u8, config_flag, flag)) continue;
|
||||
if (config_flag.len == flag.len or config_flag[flag.len] == '=') continue :outer;
|
||||
}
|
||||
|
||||
// Otherwise, append default value from config.h to compile flags
|
||||
try raylib_flags_arr.append(b.allocator, flag);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.shared) {
|
||||
try raylib_flags_arr.appendSlice(b.allocator, shared_flags);
|
||||
}
|
||||
|
||||
const raylib = if (options.shared)
|
||||
b.addSharedLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
})
|
||||
else
|
||||
b.addStaticLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
raylib.linkLibC();
|
||||
|
||||
// No GLFW required on PLATFORM_DRM
|
||||
if (options.platform != .drm) {
|
||||
raylib.addIncludePath(b.path("src/external/glfw/include"));
|
||||
}
|
||||
|
||||
var c_source_files = try std.ArrayList([]const u8).initCapacity(b.allocator, 2);
|
||||
c_source_files.appendSliceAssumeCapacity(&.{ "src/rcore.c", "src/utils.c" });
|
||||
|
||||
if (options.raudio) {
|
||||
try c_source_files.append("src/raudio.c");
|
||||
}
|
||||
if (options.rmodels) {
|
||||
try c_source_files.append("src/rmodels.c");
|
||||
}
|
||||
if (options.rshapes) {
|
||||
try c_source_files.append("src/rshapes.c");
|
||||
}
|
||||
if (options.rtext) {
|
||||
try c_source_files.append("src/rtext.c");
|
||||
}
|
||||
if (options.rtextures) {
|
||||
try c_source_files.append("src/rtextures.c");
|
||||
}
|
||||
|
||||
if (options.opengl_version != .auto) {
|
||||
raylib.defineCMacro(options.opengl_version.toCMacroStr(), null);
|
||||
}
|
||||
|
||||
switch (target.result.os.tag) {
|
||||
.windows => {
|
||||
try c_source_files.append("src/rglfw.c");
|
||||
raylib.linkSystemLibrary("winmm");
|
||||
raylib.linkSystemLibrary("gdi32");
|
||||
raylib.linkSystemLibrary("opengl32");
|
||||
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
},
|
||||
.linux => {
|
||||
if (options.platform != .drm) {
|
||||
try c_source_files.append("src/rglfw.c");
|
||||
raylib.linkSystemLibrary("GL");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
raylib.linkSystemLibrary("dl");
|
||||
raylib.linkSystemLibrary("m");
|
||||
|
||||
raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
|
||||
raylib.addIncludePath(.{ .cwd_relative = "/usr/include" });
|
||||
if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) {
|
||||
raylib.defineCMacro("_GLFW_X11", null);
|
||||
raylib.linkSystemLibrary("X11");
|
||||
}
|
||||
|
||||
if (options.linux_display_backend == .Wayland or options.linux_display_backend == .Both) {
|
||||
_ = b.findProgram(&.{"wayland-scanner"}, &.{}) catch {
|
||||
std.log.err(
|
||||
\\ `wayland-scanner` may not be installed on the system.
|
||||
\\ You can switch to X11 in your `build.zig` by changing `Options.linux_display_backend`
|
||||
, .{});
|
||||
@panic("`wayland-scanner` not found");
|
||||
};
|
||||
raylib.defineCMacro("_GLFW_WAYLAND", null);
|
||||
raylib.linkSystemLibrary("wayland-client");
|
||||
raylib.linkSystemLibrary("wayland-cursor");
|
||||
raylib.linkSystemLibrary("wayland-egl");
|
||||
raylib.linkSystemLibrary("xkbcommon");
|
||||
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");
|
||||
}
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
} else {
|
||||
if (options.opengl_version == .auto) {
|
||||
raylib.linkSystemLibrary("GLESv2");
|
||||
raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
|
||||
}
|
||||
|
||||
raylib.linkSystemLibrary("EGL");
|
||||
raylib.linkSystemLibrary("drm");
|
||||
raylib.linkSystemLibrary("gbm");
|
||||
raylib.linkSystemLibrary("pthread");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
raylib.linkSystemLibrary("m");
|
||||
raylib.linkSystemLibrary("dl");
|
||||
raylib.addIncludePath(.{ .cwd_relative = "/usr/include/libdrm" });
|
||||
|
||||
raylib.defineCMacro("PLATFORM_DRM", null);
|
||||
raylib.defineCMacro("EGL_NO_X11", null);
|
||||
raylib.defineCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "2048");
|
||||
}
|
||||
},
|
||||
.freebsd, .openbsd, .netbsd, .dragonfly => {
|
||||
try c_source_files.append("rglfw.c");
|
||||
raylib.linkSystemLibrary("GL");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
raylib.linkSystemLibrary("dl");
|
||||
raylib.linkSystemLibrary("m");
|
||||
raylib.linkSystemLibrary("X11");
|
||||
raylib.linkSystemLibrary("Xrandr");
|
||||
raylib.linkSystemLibrary("Xinerama");
|
||||
raylib.linkSystemLibrary("Xi");
|
||||
raylib.linkSystemLibrary("Xxf86vm");
|
||||
raylib.linkSystemLibrary("Xcursor");
|
||||
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
},
|
||||
.macos => {
|
||||
// On macos rglfw.c include Objective-C files.
|
||||
try raylib_flags_arr.append(b.allocator, "-ObjC");
|
||||
raylib.root_module.addCSourceFile(.{
|
||||
.file = b.path("src/rglfw.c"),
|
||||
.flags = raylib_flags_arr.items,
|
||||
});
|
||||
_ = raylib_flags_arr.pop();
|
||||
raylib.linkFramework("Foundation");
|
||||
raylib.linkFramework("CoreServices");
|
||||
raylib.linkFramework("CoreGraphics");
|
||||
raylib.linkFramework("AppKit");
|
||||
raylib.linkFramework("IOKit");
|
||||
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
},
|
||||
.emscripten => {
|
||||
raylib.defineCMacro("PLATFORM_WEB", null);
|
||||
if (options.opengl_version == .auto) {
|
||||
raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
|
||||
}
|
||||
|
||||
if (b.sysroot == null) {
|
||||
@panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"'");
|
||||
}
|
||||
|
||||
const cache_include = b.pathJoin(&.{ b.sysroot.?, "cache", "sysroot", "include" });
|
||||
|
||||
var dir = std.fs.openDirAbsolute(cache_include, std.fs.Dir.OpenDirOptions{ .access_sub_paths = true, .no_follow = true }) catch @panic("No emscripten cache. Generate it!");
|
||||
dir.close();
|
||||
raylib.addIncludePath(.{ .cwd_relative = cache_include });
|
||||
},
|
||||
else => {
|
||||
@panic("Unsupported OS");
|
||||
},
|
||||
}
|
||||
|
||||
raylib.root_module.addCSourceFiles(.{
|
||||
.files = c_source_files.items,
|
||||
.flags = raylib_flags_arr.items,
|
||||
});
|
||||
|
||||
return raylib;
|
||||
}
|
||||
|
||||
/// This function does not need to be called if you passed .raygui = true to addRaylib
|
||||
pub fn addRaygui(b: *std.Build, raylib: *std.Build.Step.Compile, raygui_dep: *std.Build.Dependency) void {
|
||||
if (raylib_flags_arr.items.len == 0) {
|
||||
@panic(
|
||||
\\argument 2 `raylib` in `addRaygui` must come from b.dependency("raylib", ...).artifact("raylib")
|
||||
);
|
||||
}
|
||||
|
||||
var gen_step = b.addWriteFiles();
|
||||
raylib.step.dependOn(&gen_step.step);
|
||||
|
||||
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
|
||||
raylib.addCSourceFile(.{ .file = raygui_c_path, .flags = raylib_flags_arr.items });
|
||||
raylib.addIncludePath(raygui_dep.path("src"));
|
||||
|
||||
raylib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
|
||||
}
|
||||
|
||||
pub const Options = struct {
|
||||
raudio: bool = true,
|
||||
rmodels: bool = true,
|
||||
rshapes: bool = true,
|
||||
rtext: bool = true,
|
||||
rtextures: bool = true,
|
||||
raygui: bool = false,
|
||||
platform: PlatformBackend = .glfw,
|
||||
shared: bool = false,
|
||||
linux_display_backend: LinuxDisplayBackend = .Both,
|
||||
opengl_version: OpenglVersion = .auto,
|
||||
/// config should be a list of space-separated cflags, eg, "-DSUPPORT_CUSTOM_FRAME_CONTROL"
|
||||
config: []const u8 = &.{},
|
||||
|
||||
raygui_dependency_name: []const u8 = "raygui",
|
||||
|
||||
const defaults = Options{};
|
||||
|
||||
fn getOptions(b: *std.Build) Options {
|
||||
return .{
|
||||
.platform = b.option(PlatformBackend, "platform", "Choose the platform backedn for desktop target") orelse defaults.platform,
|
||||
.raudio = b.option(bool, "raudio", "Compile with audio support") orelse defaults.raudio,
|
||||
.raygui = b.option(bool, "raygui", "Compile with raygui support") orelse defaults.raygui,
|
||||
.rmodels = b.option(bool, "rmodels", "Compile with models support") orelse defaults.rmodels,
|
||||
.rtext = b.option(bool, "rtext", "Compile with text support") orelse defaults.rtext,
|
||||
.rtextures = b.option(bool, "rtextures", "Compile with textures support") orelse defaults.rtextures,
|
||||
.rshapes = b.option(bool, "rshapes", "Compile with shapes support") orelse defaults.rshapes,
|
||||
.shared = b.option(bool, "shared", "Compile as shared library") orelse defaults.shared,
|
||||
.linux_display_backend = b.option(LinuxDisplayBackend, "linux_display_backend", "Linux display backend to use") orelse defaults.linux_display_backend,
|
||||
.opengl_version = b.option(OpenglVersion, "opengl_version", "OpenGL version to use") orelse defaults.opengl_version,
|
||||
.config = b.option([]const u8, "config", "Compile with custom define macros overriding config.h") orelse &.{},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const OpenglVersion = enum {
|
||||
auto,
|
||||
gl_1_1,
|
||||
gl_2_1,
|
||||
gl_3_3,
|
||||
gl_4_3,
|
||||
gles_2,
|
||||
gles_3,
|
||||
|
||||
pub fn toCMacroStr(self: @This()) []const u8 {
|
||||
switch (self) {
|
||||
.auto => @panic("OpenglVersion.auto cannot be turned into a C macro string"),
|
||||
.gl_1_1 => return "GRAPHICS_API_OPENGL_11",
|
||||
.gl_2_1 => return "GRAPHICS_API_OPENGL_21",
|
||||
.gl_3_3 => return "GRAPHICS_API_OPENGL_33",
|
||||
.gl_4_3 => return "GRAPHICS_API_OPENGL_43",
|
||||
.gles_2 => return "GRAPHICS_API_OPENGL_ES2",
|
||||
.gles_3 => return "GRAPHICS_API_OPENGL_ES3",
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const LinuxDisplayBackend = enum {
|
||||
X11,
|
||||
Wayland,
|
||||
Both,
|
||||
};
|
||||
|
||||
pub const PlatformBackend = enum {
|
||||
glfw,
|
||||
rgfw,
|
||||
sdl,
|
||||
drm,
|
||||
};
|
||||
|
||||
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 lib = try compileRaylib(b, target, optimize, Options.getOptions(b));
|
||||
|
||||
lib.installHeader(b.path("src/raylib.h"), "raylib.h");
|
||||
lib.installHeader(b.path("src/raymath.h"), "raymath.h");
|
||||
lib.installHeader(b.path("src/rlgl.h"), "rlgl.h");
|
||||
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
fn waylandGenerate(
|
||||
b: *std.Build,
|
||||
raylib: *std.Build.Step.Compile,
|
||||
comptime protocol: []const u8,
|
||||
comptime basename: []const u8,
|
||||
) void {
|
||||
const waylandDir = "src/external/glfw/deps/wayland";
|
||||
const protocolDir = b.pathJoin(&.{ waylandDir, protocol });
|
||||
const clientHeader = basename ++ ".h";
|
||||
const privateCode = basename ++ "-code.h";
|
||||
|
||||
const client_step = b.addSystemCommand(&.{ "wayland-scanner", "client-header" });
|
||||
client_step.addFileArg(b.path(protocolDir));
|
||||
raylib.addIncludePath(client_step.addOutputFileArg(clientHeader).dirname());
|
||||
|
||||
const private_step = b.addSystemCommand(&.{ "wayland-scanner", "private-code" });
|
||||
private_step.addFileArg(b.path(protocolDir));
|
||||
raylib.addIncludePath(private_step.addOutputFileArg(privateCode).dirname());
|
||||
|
||||
raylib.step.dependOn(&client_step.step);
|
||||
raylib.step.dependOn(&private_step.step);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -549,7 +549,6 @@ TEXTURES = \
|
|||
textures/textures_sprite_button \
|
||||
textures/textures_sprite_explosion \
|
||||
textures/textures_srcrec_dstrec \
|
||||
textures/textures_svg_loading \
|
||||
textures/textures_textured_curve \
|
||||
textures/textures_to_image
|
||||
|
||||
|
|
|
|||
|
|
@ -415,7 +415,6 @@ TEXTURES = \
|
|||
textures/textures_sprite_button \
|
||||
textures/textures_sprite_explosion \
|
||||
textures/textures_srcrec_dstrec \
|
||||
textures/textures_svg_loading \
|
||||
textures/textures_textured_curve \
|
||||
textures/textures_to_image
|
||||
|
||||
|
|
@ -776,10 +775,6 @@ textures/textures_srcrec_dstrec: textures/textures_srcrec_dstrec.c
|
|||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file textures/resources/scarfy.png@resources/scarfy.png
|
||||
|
||||
textures/textures_svg_loading: textures/textures_svg_loading.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file textures/resources/test.svg
|
||||
|
||||
textures/textures_textured_curve: textures/textures_textured_curve.c
|
||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||
--preload-file textures/resources/road.png@resources/road.png
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ int main(void)
|
|||
// Update model animation
|
||||
ModelAnimation anim = modelAnimations[animIndex];
|
||||
animCurrentFrame = (animCurrentFrame + 1)%anim.frameCount;
|
||||
UpdateModelAnimationBoneMatrices(characterModel, anim, animCurrentFrame);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 5.6 KiB |
|
|
@ -1,72 +0,0 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [textures] example - SVG loading and texture creation
|
||||
*
|
||||
* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
|
||||
*
|
||||
* Example originally created with raylib 4.2, last time updated with raylib 4.2
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2022 Dennis Meinen (@bixxy#4258 on Discord)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [textures] example - svg loading");
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
|
||||
Image image = LoadImageSvg("resources/test.svg", 400, 350); // Loaded in CPU memory (RAM)
|
||||
Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM)
|
||||
UnloadImage(image); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE);
|
||||
|
||||
//Red border to illustrate how the SVG is centered within the specified dimensions
|
||||
DrawRectangleLines((screenWidth / 2 - texture.width / 2) - 1, (screenHeight / 2 - texture.height / 2) - 1, texture.width + 2, texture.height + 2, RED);
|
||||
|
||||
DrawText("this IS a texture loaded from an SVG file!", 300, 410, 10, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadTexture(texture); // Texture unloading
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
|
|
@ -3763,8 +3763,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsShaderReady",
|
||||
"description": "Check if a shader is ready",
|
||||
"name": "IsShaderValid",
|
||||
"description": "Check if a shader is valid (loaded on GPU)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -4691,6 +4691,51 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ComputeCRC32",
|
||||
"description": "Compute CRC32 hash code",
|
||||
"returnType": "unsigned int",
|
||||
"params": [
|
||||
{
|
||||
"type": "unsigned char *",
|
||||
"name": "data"
|
||||
},
|
||||
{
|
||||
"type": "int",
|
||||
"name": "dataSize"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ComputeMD5",
|
||||
"description": "Compute MD5 hash code, returns static int[4] (16 bytes)",
|
||||
"returnType": "unsigned int *",
|
||||
"params": [
|
||||
{
|
||||
"type": "unsigned char *",
|
||||
"name": "data"
|
||||
},
|
||||
{
|
||||
"type": "int",
|
||||
"name": "dataSize"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ComputeSHA1",
|
||||
"description": "Compute SHA1 hash code, returns static int[5] (20 bytes)",
|
||||
"returnType": "unsigned int *",
|
||||
"params": [
|
||||
{
|
||||
"type": "unsigned char *",
|
||||
"name": "data"
|
||||
},
|
||||
{
|
||||
"type": "int",
|
||||
"name": "dataSize"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LoadAutomationEventList",
|
||||
"description": "Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS",
|
||||
|
|
@ -5186,7 +5231,7 @@
|
|||
},
|
||||
{
|
||||
"name": "GetGestureHoldDuration",
|
||||
"description": "Get gesture hold time in milliseconds",
|
||||
"description": "Get gesture hold time in seconds",
|
||||
"returnType": "float"
|
||||
},
|
||||
{
|
||||
|
|
@ -6815,25 +6860,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LoadImageSvg",
|
||||
"description": "Load image from SVG file data or string with specified size",
|
||||
"returnType": "Image",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileNameOrString"
|
||||
},
|
||||
{
|
||||
"type": "int",
|
||||
"name": "width"
|
||||
},
|
||||
{
|
||||
"type": "int",
|
||||
"name": "height"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LoadImageAnim",
|
||||
"description": "Load image sequence from file (frames appended to image.data)",
|
||||
|
|
@ -6908,8 +6934,8 @@
|
|||
"returnType": "Image"
|
||||
},
|
||||
{
|
||||
"name": "IsImageReady",
|
||||
"description": "Check if an image is ready",
|
||||
"name": "IsImageValid",
|
||||
"description": "Check if an image is valid (data and parameters)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -8372,8 +8398,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsTextureReady",
|
||||
"description": "Check if a texture is ready",
|
||||
"name": "IsTextureValid",
|
||||
"description": "Check if a texture is valid (loaded in GPU)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -8394,8 +8420,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsRenderTextureReady",
|
||||
"description": "Check if a render texture is ready",
|
||||
"name": "IsRenderTextureValid",
|
||||
"description": "Check if a render texture is valid (loaded in GPU)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -8989,8 +9015,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsFontReady",
|
||||
"description": "Check if a font is ready",
|
||||
"name": "IsFontValid",
|
||||
"description": "Check if a font is valid (font data loaded, WARNING: GPU texture not checked)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -10281,8 +10307,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsModelReady",
|
||||
"description": "Check if a model is ready",
|
||||
"name": "IsModelValid",
|
||||
"description": "Check if a model is valid (loaded in GPU, VAO/VBOs)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -10968,8 +10994,8 @@
|
|||
"returnType": "Material"
|
||||
},
|
||||
{
|
||||
"name": "IsMaterialReady",
|
||||
"description": "Check if a material is ready",
|
||||
"name": "IsMaterialValid",
|
||||
"description": "Check if a material is valid (shader assigned, map textures loaded in GPU)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -11343,8 +11369,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsWaveReady",
|
||||
"description": "Checks if wave data is ready",
|
||||
"name": "IsWaveValid",
|
||||
"description": "Checks if wave data is valid (data loaded and parameters)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -11387,8 +11413,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsSoundReady",
|
||||
"description": "Checks if a sound is ready",
|
||||
"name": "IsSoundValid",
|
||||
"description": "Checks if a sound is valid (data loaded and buffers initialized)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -11685,8 +11711,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsMusicReady",
|
||||
"description": "Checks if a music stream is ready",
|
||||
"name": "IsMusicValid",
|
||||
"description": "Checks if a music stream is valid (context and buffers initialized)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
@ -11874,8 +11900,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "IsAudioStreamReady",
|
||||
"description": "Checks if an audio stream is ready",
|
||||
"name": "IsAudioStreamValid",
|
||||
"description": "Checks if an audio stream is valid (buffers initialized)",
|
||||
"returnType": "bool",
|
||||
"params": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3589,8 +3589,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsShaderReady",
|
||||
description = "Check if a shader is ready",
|
||||
name = "IsShaderValid",
|
||||
description = "Check if a shader is valid (loaded on GPU)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Shader", name = "shader"}
|
||||
|
|
@ -4190,6 +4190,33 @@ return {
|
|||
{type = "int *", name = "outputSize"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "ComputeCRC32",
|
||||
description = "Compute CRC32 hash code",
|
||||
returnType = "unsigned int",
|
||||
params = {
|
||||
{type = "unsigned char *", name = "data"},
|
||||
{type = "int", name = "dataSize"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "ComputeMD5",
|
||||
description = "Compute MD5 hash code, returns static int[4] (16 bytes)",
|
||||
returnType = "unsigned int *",
|
||||
params = {
|
||||
{type = "unsigned char *", name = "data"},
|
||||
{type = "int", name = "dataSize"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "ComputeSHA1",
|
||||
description = "Compute SHA1 hash code, returns static int[5] (20 bytes)",
|
||||
returnType = "unsigned int *",
|
||||
params = {
|
||||
{type = "unsigned char *", name = "data"},
|
||||
{type = "int", name = "dataSize"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "LoadAutomationEventList",
|
||||
description = "Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS",
|
||||
|
|
@ -4550,7 +4577,7 @@ return {
|
|||
},
|
||||
{
|
||||
name = "GetGestureHoldDuration",
|
||||
description = "Get gesture hold time in milliseconds",
|
||||
description = "Get gesture hold time in seconds",
|
||||
returnType = "float"
|
||||
},
|
||||
{
|
||||
|
|
@ -5339,16 +5366,6 @@ return {
|
|||
{type = "int", name = "headerSize"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "LoadImageSvg",
|
||||
description = "Load image from SVG file data or string with specified size",
|
||||
returnType = "Image",
|
||||
params = {
|
||||
{type = "const char *", name = "fileNameOrString"},
|
||||
{type = "int", name = "width"},
|
||||
{type = "int", name = "height"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "LoadImageAnim",
|
||||
description = "Load image sequence from file (frames appended to image.data)",
|
||||
|
|
@ -5393,8 +5410,8 @@ return {
|
|||
returnType = "Image"
|
||||
},
|
||||
{
|
||||
name = "IsImageReady",
|
||||
description = "Check if an image is ready",
|
||||
name = "IsImageValid",
|
||||
description = "Check if an image is valid (data and parameters)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Image", name = "image"}
|
||||
|
|
@ -6158,8 +6175,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsTextureReady",
|
||||
description = "Check if a texture is ready",
|
||||
name = "IsTextureValid",
|
||||
description = "Check if a texture is valid (loaded in GPU)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Texture2D", name = "texture"}
|
||||
|
|
@ -6174,8 +6191,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsRenderTextureReady",
|
||||
description = "Check if a render texture is ready",
|
||||
name = "IsRenderTextureValid",
|
||||
description = "Check if a render texture is valid (loaded in GPU)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "RenderTexture2D", name = "target"}
|
||||
|
|
@ -6505,8 +6522,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsFontReady",
|
||||
description = "Check if a font is ready",
|
||||
name = "IsFontValid",
|
||||
description = "Check if a font is valid (font data loaded, WARNING: GPU texture not checked)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Font", name = "font"}
|
||||
|
|
@ -7185,8 +7202,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsModelReady",
|
||||
description = "Check if a model is ready",
|
||||
name = "IsModelValid",
|
||||
description = "Check if a model is valid (loaded in GPU, VAO/VBOs)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Model", name = "model"}
|
||||
|
|
@ -7539,8 +7556,8 @@ return {
|
|||
returnType = "Material"
|
||||
},
|
||||
{
|
||||
name = "IsMaterialReady",
|
||||
description = "Check if a material is ready",
|
||||
name = "IsMaterialValid",
|
||||
description = "Check if a material is valid (shader assigned, map textures loaded in GPU)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Material", name = "material"}
|
||||
|
|
@ -7758,8 +7775,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsWaveReady",
|
||||
description = "Checks if wave data is ready",
|
||||
name = "IsWaveValid",
|
||||
description = "Checks if wave data is valid (data loaded and parameters)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Wave", name = "wave"}
|
||||
|
|
@ -7790,8 +7807,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsSoundReady",
|
||||
description = "Checks if a sound is ready",
|
||||
name = "IsSoundValid",
|
||||
description = "Checks if a sound is valid (data loaded and buffers initialized)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Sound", name = "sound"}
|
||||
|
|
@ -7980,8 +7997,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsMusicReady",
|
||||
description = "Checks if a music stream is ready",
|
||||
name = "IsMusicValid",
|
||||
description = "Checks if a music stream is valid (context and buffers initialized)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "Music", name = "music"}
|
||||
|
|
@ -8106,8 +8123,8 @@ return {
|
|||
}
|
||||
},
|
||||
{
|
||||
name = "IsAudioStreamReady",
|
||||
description = "Checks if an audio stream is ready",
|
||||
name = "IsAudioStreamValid",
|
||||
description = "Checks if an audio stream is valid (buffers initialized)",
|
||||
returnType = "bool",
|
||||
params = {
|
||||
{type = "AudioStream", name = "stream"}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -675,7 +675,7 @@
|
|||
<Param type="unsigned int" name="frames" desc="" />
|
||||
</Callback>
|
||||
</Callbacks>
|
||||
<Functions count="578">
|
||||
<Functions count="580">
|
||||
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
|
||||
<Param type="int" name="width" desc="" />
|
||||
<Param type="int" name="height" desc="" />
|
||||
|
|
@ -871,7 +871,7 @@
|
|||
<Param type="const char *" name="vsCode" desc="" />
|
||||
<Param type="const char *" name="fsCode" desc="" />
|
||||
</Function>
|
||||
<Function name="IsShaderReady" retType="bool" paramCount="1" desc="Check if a shader is ready">
|
||||
<Function name="IsShaderValid" retType="bool" paramCount="1" desc="Check if a shader is valid (loaded on GPU)">
|
||||
<Param type="Shader" name="shader" desc="" />
|
||||
</Function>
|
||||
<Function name="GetShaderLocation" retType="int" paramCount="2" desc="Get shader uniform location">
|
||||
|
|
@ -1126,6 +1126,18 @@
|
|||
<Param type="const unsigned char *" name="data" desc="" />
|
||||
<Param type="int *" name="outputSize" desc="" />
|
||||
</Function>
|
||||
<Function name="ComputeCRC32" retType="unsigned int" paramCount="2" desc="Compute CRC32 hash code">
|
||||
<Param type="unsigned char *" name="data" desc="" />
|
||||
<Param type="int" name="dataSize" desc="" />
|
||||
</Function>
|
||||
<Function name="ComputeMD5" retType="unsigned int *" paramCount="2" desc="Compute MD5 hash code, returns static int[4] (16 bytes)">
|
||||
<Param type="unsigned char *" name="data" desc="" />
|
||||
<Param type="int" name="dataSize" desc="" />
|
||||
</Function>
|
||||
<Function name="ComputeSHA1" retType="unsigned int *" paramCount="2" desc="Compute SHA1 hash code, returns static int[5] (20 bytes)">
|
||||
<Param type="unsigned char *" name="data" desc="" />
|
||||
<Param type="int" name="dataSize" desc="" />
|
||||
</Function>
|
||||
<Function name="LoadAutomationEventList" retType="AutomationEventList" paramCount="1" desc="Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
|
|
@ -1269,7 +1281,7 @@
|
|||
</Function>
|
||||
<Function name="GetGestureDetected" retType="int" paramCount="0" desc="Get latest detected gesture">
|
||||
</Function>
|
||||
<Function name="GetGestureHoldDuration" retType="float" paramCount="0" desc="Get gesture hold time in milliseconds">
|
||||
<Function name="GetGestureHoldDuration" retType="float" paramCount="0" desc="Get gesture hold time in seconds">
|
||||
</Function>
|
||||
<Function name="GetGestureDragVector" retType="Vector2" paramCount="0" desc="Get gesture drag vector">
|
||||
</Function>
|
||||
|
|
@ -1699,11 +1711,6 @@
|
|||
<Param type="int" name="format" desc="" />
|
||||
<Param type="int" name="headerSize" desc="" />
|
||||
</Function>
|
||||
<Function name="LoadImageSvg" retType="Image" paramCount="3" desc="Load image from SVG file data or string with specified size">
|
||||
<Param type="const char *" name="fileNameOrString" desc="" />
|
||||
<Param type="int" name="width" desc="" />
|
||||
<Param type="int" name="height" desc="" />
|
||||
</Function>
|
||||
<Function name="LoadImageAnim" retType="Image" paramCount="2" desc="Load image sequence from file (frames appended to image.data)">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
<Param type="int *" name="frames" desc="" />
|
||||
|
|
@ -1724,7 +1731,7 @@
|
|||
</Function>
|
||||
<Function name="LoadImageFromScreen" retType="Image" paramCount="0" desc="Load image from screen buffer and (screenshot)">
|
||||
</Function>
|
||||
<Function name="IsImageReady" retType="bool" paramCount="1" desc="Check if an image is ready">
|
||||
<Function name="IsImageValid" retType="bool" paramCount="1" desc="Check if an image is valid (data and parameters)">
|
||||
<Param type="Image" name="image" desc="" />
|
||||
</Function>
|
||||
<Function name="UnloadImage" retType="void" paramCount="1" desc="Unload image from CPU memory (RAM)">
|
||||
|
|
@ -2109,13 +2116,13 @@
|
|||
<Param type="int" name="width" desc="" />
|
||||
<Param type="int" name="height" desc="" />
|
||||
</Function>
|
||||
<Function name="IsTextureReady" retType="bool" paramCount="1" desc="Check if a texture is ready">
|
||||
<Function name="IsTextureValid" retType="bool" paramCount="1" desc="Check if a texture is valid (loaded in GPU)">
|
||||
<Param type="Texture2D" name="texture" desc="" />
|
||||
</Function>
|
||||
<Function name="UnloadTexture" retType="void" paramCount="1" desc="Unload texture from GPU memory (VRAM)">
|
||||
<Param type="Texture2D" name="texture" desc="" />
|
||||
</Function>
|
||||
<Function name="IsRenderTextureReady" retType="bool" paramCount="1" desc="Check if a render texture is ready">
|
||||
<Function name="IsRenderTextureValid" retType="bool" paramCount="1" desc="Check if a render texture is valid (loaded in GPU)">
|
||||
<Param type="RenderTexture2D" name="target" desc="" />
|
||||
</Function>
|
||||
<Function name="UnloadRenderTexture" retType="void" paramCount="1" desc="Unload render texture from GPU memory (VRAM)">
|
||||
|
|
@ -2273,7 +2280,7 @@
|
|||
<Param type="int *" name="codepoints" desc="" />
|
||||
<Param type="int" name="codepointCount" desc="" />
|
||||
</Function>
|
||||
<Function name="IsFontReady" retType="bool" paramCount="1" desc="Check if a font is ready">
|
||||
<Function name="IsFontValid" retType="bool" paramCount="1" desc="Check if a font is valid (font data loaded, WARNING: GPU texture not checked)">
|
||||
<Param type="Font" name="font" desc="" />
|
||||
</Function>
|
||||
<Function name="LoadFontData" retType="GlyphInfo *" paramCount="6" desc="Load font data for further use">
|
||||
|
|
@ -2613,7 +2620,7 @@
|
|||
<Function name="LoadModelFromMesh" retType="Model" paramCount="1" desc="Load model from generated mesh (default material)">
|
||||
<Param type="Mesh" name="mesh" desc="" />
|
||||
</Function>
|
||||
<Function name="IsModelReady" retType="bool" paramCount="1" desc="Check if a model is ready">
|
||||
<Function name="IsModelValid" retType="bool" paramCount="1" desc="Check if a model is valid (loaded in GPU, VAO/VBOs)">
|
||||
<Param type="Model" name="model" desc="" />
|
||||
</Function>
|
||||
<Function name="UnloadModel" retType="void" paramCount="1" desc="Unload model (including meshes) from memory (RAM and/or VRAM)">
|
||||
|
|
@ -2794,7 +2801,7 @@
|
|||
</Function>
|
||||
<Function name="LoadMaterialDefault" retType="Material" paramCount="0" desc="Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)">
|
||||
</Function>
|
||||
<Function name="IsMaterialReady" retType="bool" paramCount="1" desc="Check if a material is ready">
|
||||
<Function name="IsMaterialValid" retType="bool" paramCount="1" desc="Check if a material is valid (shader assigned, map textures loaded in GPU)">
|
||||
<Param type="Material" name="material" desc="" />
|
||||
</Function>
|
||||
<Function name="UnloadMaterial" retType="void" paramCount="1" desc="Unload material from GPU memory (VRAM)">
|
||||
|
|
@ -2896,7 +2903,7 @@
|
|||
<Param type="const unsigned char *" name="fileData" desc="" />
|
||||
<Param type="int" name="dataSize" desc="" />
|
||||
</Function>
|
||||
<Function name="IsWaveReady" retType="bool" paramCount="1" desc="Checks if wave data is ready">
|
||||
<Function name="IsWaveValid" retType="bool" paramCount="1" desc="Checks if wave data is valid (data loaded and parameters)">
|
||||
<Param type="Wave" name="wave" desc="" />
|
||||
</Function>
|
||||
<Function name="LoadSound" retType="Sound" paramCount="1" desc="Load sound from file">
|
||||
|
|
@ -2908,7 +2915,7 @@
|
|||
<Function name="LoadSoundAlias" retType="Sound" paramCount="1" desc="Create a new sound that shares the same sample data as the source sound, does not own the sound data">
|
||||
<Param type="Sound" name="source" desc="" />
|
||||
</Function>
|
||||
<Function name="IsSoundReady" retType="bool" paramCount="1" desc="Checks if a sound is ready">
|
||||
<Function name="IsSoundValid" retType="bool" paramCount="1" desc="Checks if a sound is valid (data loaded and buffers initialized)">
|
||||
<Param type="Sound" name="sound" desc="" />
|
||||
</Function>
|
||||
<Function name="UpdateSound" retType="void" paramCount="3" desc="Update sound buffer with new data">
|
||||
|
|
@ -2988,7 +2995,7 @@
|
|||
<Param type="const unsigned char *" name="data" desc="" />
|
||||
<Param type="int" name="dataSize" desc="" />
|
||||
</Function>
|
||||
<Function name="IsMusicReady" retType="bool" paramCount="1" desc="Checks if a music stream is ready">
|
||||
<Function name="IsMusicValid" retType="bool" paramCount="1" desc="Checks if a music stream is valid (context and buffers initialized)">
|
||||
<Param type="Music" name="music" desc="" />
|
||||
</Function>
|
||||
<Function name="UnloadMusicStream" retType="void" paramCount="1" desc="Unload music stream">
|
||||
|
|
@ -3039,7 +3046,7 @@
|
|||
<Param type="unsigned int" name="sampleSize" desc="" />
|
||||
<Param type="unsigned int" name="channels" desc="" />
|
||||
</Function>
|
||||
<Function name="IsAudioStreamReady" retType="bool" paramCount="1" desc="Checks if an audio stream is ready">
|
||||
<Function name="IsAudioStreamValid" retType="bool" paramCount="1" desc="Checks if an audio stream is valid (buffers initialized)">
|
||||
<Param type="AudioStream" name="stream" desc="" />
|
||||
</Function>
|
||||
<Function name="UnloadAudioStream" retType="void" paramCount="1" desc="Unload audio stream and free memory">
|
||||
|
|
|
|||
|
|
@ -293,8 +293,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_texture_outline", "
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_texture_tiling", "examples\shaders_texture_tiling.vcxproj", "{EFA150D4-F93B-4D7D-A69C-9E8B4663BECD}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_svg_loading", "examples\textures_svg_loading.vcxproj", "{D8026C60-CCBC-45DF-9085-BF21569EB414}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_splines_drawing", "examples\shapes_splines_drawing.vcxproj", "{DF25E545-00FF-4E64-844C-7DF98991F901}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_top_down_lights", "examples\shapes_top_down_lights.vcxproj", "{703BE7BA-5B99-4F70-806D-3A259F6A991E}"
|
||||
|
|
|
|||
|
|
@ -352,9 +352,9 @@ SRC_DIR = src
|
|||
OBJ_DIR = obj
|
||||
|
||||
# Define all object files from source files
|
||||
SRC = $(call rwildcard, *.c, *.h)
|
||||
SRC = $(call rwildcard, ./, *.c, *.h)
|
||||
#OBJS = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
|
||||
OBJS ?= main.c
|
||||
OBJS = $(patsubst %.c,%.o,$(filter %.c,$(SRC)))
|
||||
|
||||
# For Android platform we call a custom Makefile.Android
|
||||
ifeq ($(PLATFORM),PLATFORM_ANDROID)
|
||||
|
|
|
|||
|
|
@ -109,8 +109,9 @@ RAYLIB_MODULE_RAYGUI_PATH ?= $(RAYLIB_SRC_PATH)/../../raygui/src
|
|||
# Use external GLFW library instead of rglfw module
|
||||
USE_EXTERNAL_GLFW ?= FALSE
|
||||
|
||||
# Enable support for both Wayland and X11 by default on Linux when using GLFW
|
||||
GLFW_LINUX_ENABLE_WAYLAND ?= TRUE
|
||||
# Enable support for X11 by default on Linux when using GLFW
|
||||
# NOTE: Wayland is disabled by default, only enable if you are sure
|
||||
GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
|
||||
GLFW_LINUX_ENABLE_X11 ?= TRUE
|
||||
|
||||
# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
|
||||
|
|
|
|||
397
src/build.zig
397
src/build.zig
|
|
@ -1,397 +0,0 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
comptime {
|
||||
if (builtin.zig_version.minor < 12) @compileError("Raylib requires zig version 0.12.0");
|
||||
}
|
||||
|
||||
// NOTE(freakmangd): I don't like using a global here, but it prevents having to
|
||||
// get the flags a second time when adding raygui
|
||||
var raylib_flags_arr: std.ArrayListUnmanaged([]const u8) = .{};
|
||||
|
||||
/// we're not inside the actual build script recognized by the
|
||||
/// zig build system; use this type where one would otherwise
|
||||
/// use `@This()` when inside the actual entrypoint file.
|
||||
const BuildScript = @import("../build.zig");
|
||||
|
||||
// This has been tested with zig version 0.12.0
|
||||
pub fn addRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
|
||||
const raylib_dep = b.dependencyFromBuildZig(BuildScript, .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.raudio = options.raudio,
|
||||
.rmodels = options.rmodels,
|
||||
.rshapes = options.rshapes,
|
||||
.rtext = options.rtext,
|
||||
.rtextures = options.rtextures,
|
||||
.platform_drm = options.platform_drm,
|
||||
.shared = options.shared,
|
||||
.linux_display_backend = options.linux_display_backend,
|
||||
.opengl_version = options.opengl_version,
|
||||
.config = options.config,
|
||||
});
|
||||
const raylib = raylib_dep.artifact("raylib");
|
||||
|
||||
if (options.raygui) {
|
||||
const raygui_dep = b.dependency(options.raygui_dependency_name, .{});
|
||||
addRaygui(b, raylib, raygui_dep);
|
||||
}
|
||||
|
||||
return raylib;
|
||||
}
|
||||
|
||||
fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend) void {
|
||||
raylib.defineCMacro("PLATFORM_DESKTOP", null);
|
||||
|
||||
switch (platform) {
|
||||
.glfw => raylib.defineCMacro("PLATFORM_DESKTOP_GLFW", null),
|
||||
.rgfw => raylib.defineCMacro("PLATFORM_DESKTOP_RGFW", null),
|
||||
.sdl => raylib.defineCMacro("PLATFORM_DESKTOP_SDL", null),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
|
||||
raylib_flags_arr.clearRetainingCapacity();
|
||||
|
||||
const shared_flags = &[_][]const u8{
|
||||
"-fPIC",
|
||||
"-DBUILD_LIBTYPE_SHARED",
|
||||
};
|
||||
try raylib_flags_arr.appendSlice(b.allocator, &[_][]const u8{
|
||||
"-std=gnu99",
|
||||
"-D_GNU_SOURCE",
|
||||
"-DGL_SILENCE_DEPRECATION=199309L",
|
||||
"-fno-sanitize=undefined", // https://github.com/raysan5/raylib/issues/3674
|
||||
});
|
||||
if (options.config) |config| {
|
||||
const file = try std.fs.path.join(b.allocator, &.{ std.fs.path.dirname(@src().file) orelse ".", "config.h" });
|
||||
defer b.allocator.free(file);
|
||||
const content = try std.fs.cwd().readFileAlloc(b.allocator, file, std.math.maxInt(usize));
|
||||
defer b.allocator.free(content);
|
||||
|
||||
var lines = std.mem.splitScalar(u8, content, '\n');
|
||||
while (lines.next()) |line| {
|
||||
if (!std.mem.containsAtLeast(u8, line, 1, "SUPPORT")) continue;
|
||||
if (std.mem.startsWith(u8, line, "//")) continue;
|
||||
if (std.mem.startsWith(u8, line, "#if")) continue;
|
||||
|
||||
var flag = std.mem.trimLeft(u8, line, " \t"); // Trim whitespace
|
||||
flag = flag["#define ".len - 1 ..]; // Remove #define
|
||||
flag = std.mem.trimLeft(u8, flag, " \t"); // Trim whitespace
|
||||
flag = flag[0 .. std.mem.indexOf(u8, flag, " ") orelse continue]; // Flag is only one word, so capture till space
|
||||
flag = try std.fmt.allocPrint(b.allocator, "-D{s}", .{flag}); // Prepend with -D
|
||||
|
||||
// If user specifies the flag skip it
|
||||
if (std.mem.containsAtLeast(u8, config, 1, flag)) continue;
|
||||
|
||||
// Append default value from config.h to compile flags
|
||||
try raylib_flags_arr.append(b.allocator, flag);
|
||||
}
|
||||
|
||||
// Append config flags supplied by user to compile flags
|
||||
try raylib_flags_arr.append(b.allocator, config);
|
||||
|
||||
try raylib_flags_arr.append(b.allocator, "-DEXTERNAL_CONFIG_FLAGS");
|
||||
}
|
||||
|
||||
if (options.shared) {
|
||||
try raylib_flags_arr.appendSlice(b.allocator, shared_flags);
|
||||
}
|
||||
|
||||
const raylib = if (options.shared)
|
||||
b.addSharedLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
})
|
||||
else
|
||||
b.addStaticLibrary(.{
|
||||
.name = "raylib",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
raylib.linkLibC();
|
||||
|
||||
// No GLFW required on PLATFORM_DRM
|
||||
if (options.platform != .drm) {
|
||||
raylib.addIncludePath(b.path("src/external/glfw/include"));
|
||||
}
|
||||
|
||||
var c_source_files = try std.ArrayList([]const u8).initCapacity(b.allocator, 2);
|
||||
c_source_files.appendSliceAssumeCapacity(&.{ "rcore.c", "utils.c" });
|
||||
|
||||
if (options.raudio) {
|
||||
try c_source_files.append("raudio.c");
|
||||
}
|
||||
if (options.rmodels) {
|
||||
try c_source_files.append("rmodels.c");
|
||||
}
|
||||
if (options.rshapes) {
|
||||
try c_source_files.append("rshapes.c");
|
||||
}
|
||||
if (options.rtext) {
|
||||
try c_source_files.append("rtext.c");
|
||||
}
|
||||
if (options.rtextures) {
|
||||
try c_source_files.append("rtextures.c");
|
||||
}
|
||||
|
||||
if (options.opengl_version != .auto) {
|
||||
raylib.defineCMacro(options.opengl_version.toCMacroStr(), null);
|
||||
}
|
||||
|
||||
switch (target.result.os.tag) {
|
||||
.windows => {
|
||||
try c_source_files.append("rglfw.c");
|
||||
raylib.linkSystemLibrary("winmm");
|
||||
raylib.linkSystemLibrary("gdi32");
|
||||
raylib.linkSystemLibrary("opengl32");
|
||||
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
},
|
||||
.linux => {
|
||||
if (options.platform != .drm) {
|
||||
try c_source_files.append("rglfw.c");
|
||||
raylib.linkSystemLibrary("GL");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
raylib.linkSystemLibrary("dl");
|
||||
raylib.linkSystemLibrary("m");
|
||||
|
||||
raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
|
||||
raylib.addIncludePath(.{ .cwd_relative = "/usr/include" });
|
||||
if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) {
|
||||
raylib.defineCMacro("_GLFW_X11", null);
|
||||
raylib.linkSystemLibrary("X11");
|
||||
}
|
||||
|
||||
if (options.linux_display_backend == .Wayland or options.linux_display_backend == .Both) {
|
||||
_ = b.findProgram(&.{"wayland-scanner"}, &.{}) catch {
|
||||
std.log.err(
|
||||
\\ Wayland may not be installed on the system.
|
||||
\\ You can switch to X11 in your `build.zig` by changing `Options.linux_display_backend`
|
||||
, .{});
|
||||
@panic("No 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");
|
||||
}
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
} else {
|
||||
if (options.opengl_version == .auto) {
|
||||
raylib.linkSystemLibrary("GLESv2");
|
||||
raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
|
||||
}
|
||||
|
||||
raylib.linkSystemLibrary("EGL");
|
||||
raylib.linkSystemLibrary("drm");
|
||||
raylib.linkSystemLibrary("gbm");
|
||||
raylib.linkSystemLibrary("pthread");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
raylib.linkSystemLibrary("m");
|
||||
raylib.linkSystemLibrary("dl");
|
||||
raylib.addIncludePath(.{ .cwd_relative = "/usr/include/libdrm" });
|
||||
|
||||
raylib.defineCMacro("PLATFORM_DRM", null);
|
||||
raylib.defineCMacro("EGL_NO_X11", null);
|
||||
raylib.defineCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "2048");
|
||||
}
|
||||
},
|
||||
.freebsd, .openbsd, .netbsd, .dragonfly => {
|
||||
try c_source_files.append("rglfw.c");
|
||||
raylib.linkSystemLibrary("GL");
|
||||
raylib.linkSystemLibrary("rt");
|
||||
raylib.linkSystemLibrary("dl");
|
||||
raylib.linkSystemLibrary("m");
|
||||
raylib.linkSystemLibrary("X11");
|
||||
raylib.linkSystemLibrary("Xrandr");
|
||||
raylib.linkSystemLibrary("Xinerama");
|
||||
raylib.linkSystemLibrary("Xi");
|
||||
raylib.linkSystemLibrary("Xxf86vm");
|
||||
raylib.linkSystemLibrary("Xcursor");
|
||||
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
},
|
||||
.macos => {
|
||||
// On macos rglfw.c include Objective-C files.
|
||||
try raylib_flags_arr.append(b.allocator, "-ObjC");
|
||||
raylib.root_module.addCSourceFile(.{
|
||||
.file = b.path("src/rglfw.c"),
|
||||
.flags = raylib_flags_arr.items,
|
||||
});
|
||||
_ = raylib_flags_arr.pop();
|
||||
raylib.linkFramework("Foundation");
|
||||
raylib.linkFramework("CoreServices");
|
||||
raylib.linkFramework("CoreGraphics");
|
||||
raylib.linkFramework("AppKit");
|
||||
raylib.linkFramework("IOKit");
|
||||
|
||||
setDesktopPlatform(raylib, options.platform);
|
||||
},
|
||||
.emscripten => {
|
||||
raylib.defineCMacro("PLATFORM_WEB", null);
|
||||
if (options.opengl_version == .auto) {
|
||||
raylib.defineCMacro("GRAPHICS_API_OPENGL_ES2", null);
|
||||
}
|
||||
|
||||
if (b.sysroot == null) {
|
||||
@panic("Pass '--sysroot \"$EMSDK/upstream/emscripten\"'");
|
||||
}
|
||||
|
||||
const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory");
|
||||
defer b.allocator.free(cache_include);
|
||||
|
||||
var dir = std.fs.openDirAbsolute(cache_include, std.fs.Dir.OpenDirOptions{ .access_sub_paths = true, .no_follow = true }) catch @panic("No emscripten cache. Generate it!");
|
||||
dir.close();
|
||||
raylib.addIncludePath(.{ .cwd_relative = cache_include });
|
||||
},
|
||||
else => {
|
||||
@panic("Unsupported OS");
|
||||
},
|
||||
}
|
||||
|
||||
raylib.addIncludePath(b.path("src"));
|
||||
raylib.root_module.addCSourceFiles(.{
|
||||
.root = b.path("src"),
|
||||
.files = c_source_files.items,
|
||||
.flags = raylib_flags_arr.items,
|
||||
});
|
||||
|
||||
return raylib;
|
||||
}
|
||||
|
||||
/// This function does not need to be called if you passed .raygui = true to addRaylib
|
||||
pub fn addRaygui(b: *std.Build, raylib: *std.Build.Step.Compile, raygui_dep: *std.Build.Dependency) void {
|
||||
if (raylib_flags_arr.items.len == 0) {
|
||||
@panic(
|
||||
\\argument 2 `raylib` in `addRaygui` must come from b.dependency("raylib", ...).artifact("raylib")
|
||||
);
|
||||
}
|
||||
|
||||
var gen_step = b.addWriteFiles();
|
||||
raylib.step.dependOn(&gen_step.step);
|
||||
|
||||
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
|
||||
raylib.addCSourceFile(.{ .file = raygui_c_path, .flags = raylib_flags_arr.items });
|
||||
raylib.addIncludePath(raygui_dep.path("src"));
|
||||
|
||||
raylib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
|
||||
}
|
||||
|
||||
pub const Options = struct {
|
||||
raudio: bool = true,
|
||||
rmodels: bool = true,
|
||||
rshapes: bool = true,
|
||||
rtext: bool = true,
|
||||
rtextures: bool = true,
|
||||
raygui: bool = false,
|
||||
platform: PlatformBackend = .glfw,
|
||||
shared: bool = false,
|
||||
linux_display_backend: LinuxDisplayBackend = .Both,
|
||||
opengl_version: OpenglVersion = .auto,
|
||||
/// config should be a list of cflags, eg, "-DSUPPORT_CUSTOM_FRAME_CONTROL"
|
||||
config: ?[]const u8 = null,
|
||||
|
||||
raygui_dependency_name: []const u8 = "raygui",
|
||||
};
|
||||
|
||||
pub const OpenglVersion = enum {
|
||||
auto,
|
||||
gl_1_1,
|
||||
gl_2_1,
|
||||
gl_3_3,
|
||||
gl_4_3,
|
||||
gles_2,
|
||||
gles_3,
|
||||
|
||||
pub fn toCMacroStr(self: @This()) []const u8 {
|
||||
switch (self) {
|
||||
.auto => @panic("OpenglVersion.auto cannot be turned into a C macro string"),
|
||||
.gl_1_1 => return "GRAPHICS_API_OPENGL_11",
|
||||
.gl_2_1 => return "GRAPHICS_API_OPENGL_21",
|
||||
.gl_3_3 => return "GRAPHICS_API_OPENGL_33",
|
||||
.gl_4_3 => return "GRAPHICS_API_OPENGL_43",
|
||||
.gles_2 => return "GRAPHICS_API_OPENGL_ES2",
|
||||
.gles_3 => return "GRAPHICS_API_OPENGL_ES3",
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const LinuxDisplayBackend = enum {
|
||||
X11,
|
||||
Wayland,
|
||||
Both,
|
||||
};
|
||||
|
||||
pub const PlatformBackend = enum {
|
||||
glfw,
|
||||
rgfw,
|
||||
sdl,
|
||||
drm,
|
||||
};
|
||||
|
||||
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 defaults = Options{};
|
||||
const options = Options{
|
||||
.platform = b.option(PlatformBackend, "platform", "Choose the platform backedn for desktop target") orelse defaults.platform,
|
||||
.raudio = b.option(bool, "raudio", "Compile with audio support") orelse defaults.raudio,
|
||||
.rmodels = b.option(bool, "rmodels", "Compile with models support") orelse defaults.rmodels,
|
||||
.rtext = b.option(bool, "rtext", "Compile with text support") orelse defaults.rtext,
|
||||
.rtextures = b.option(bool, "rtextures", "Compile with textures support") orelse defaults.rtextures,
|
||||
.rshapes = b.option(bool, "rshapes", "Compile with shapes support") orelse defaults.rshapes,
|
||||
.shared = b.option(bool, "shared", "Compile as shared library") orelse defaults.shared,
|
||||
.linux_display_backend = b.option(LinuxDisplayBackend, "linux_display_backend", "Linux display backend to use") orelse defaults.linux_display_backend,
|
||||
.opengl_version = b.option(OpenglVersion, "opengl_version", "OpenGL version to use") orelse defaults.opengl_version,
|
||||
.config = b.option([]const u8, "config", "Compile with custom define macros overriding config.h") orelse null,
|
||||
};
|
||||
|
||||
const lib = try compileRaylib(b, target, optimize, options);
|
||||
|
||||
lib.installHeader(b.path("src/raylib.h"), "raylib.h");
|
||||
lib.installHeader(b.path("src/raymath.h"), "raymath.h");
|
||||
lib.installHeader(b.path("src/rlgl.h"), "rlgl.h");
|
||||
|
||||
b.installArtifact(lib);
|
||||
}
|
||||
|
||||
const waylandDir = "src/external/glfw/deps/wayland";
|
||||
|
||||
fn waylandGenerate(b: *std.Build, raylib: *std.Build.Step.Compile, comptime protocol: []const u8, comptime basename: []const u8) void {
|
||||
const protocolDir = waylandDir ++ "/" ++ protocol;
|
||||
const clientHeader = basename ++ ".h";
|
||||
const privateCode = basename ++ "-code.h";
|
||||
|
||||
const client_step = b.addSystemCommand(&.{ "wayland-scanner", "client-header" });
|
||||
client_step.addFileArg(b.path(protocolDir));
|
||||
raylib.addIncludePath(client_step.addOutputFileArg(clientHeader).dirname());
|
||||
|
||||
const private_step = b.addSystemCommand(&.{ "wayland-scanner", "private-code" });
|
||||
private_step.addFileArg(b.path(protocolDir));
|
||||
raylib.addIncludePath(private_step.addOutputFileArg(privateCode).dirname());
|
||||
|
||||
raylib.step.dependOn(&client_step.step);
|
||||
raylib.step.dependOn(&private_step.step);
|
||||
}
|
||||
|
|
@ -180,7 +180,6 @@
|
|||
//#define SUPPORT_FILEFORMAT_ASTC 1
|
||||
//#define SUPPORT_FILEFORMAT_PKM 1
|
||||
//#define SUPPORT_FILEFORMAT_PVR 1
|
||||
//#define SUPPORT_FILEFORMAT_SVG 1
|
||||
|
||||
// Support image export functionality (.png, .bmp, .tga, .jpg, .qoi)
|
||||
#define SUPPORT_IMAGE_EXPORT 1
|
||||
|
|
|
|||
3053
src/external/nanosvg.h
vendored
3053
src/external/nanosvg.h
vendored
File diff suppressed because it is too large
Load diff
1458
src/external/nanosvgrast.h
vendored
1458
src/external/nanosvgrast.h
vendored
File diff suppressed because it is too large
Load diff
13
src/external/rl_gputex.h
vendored
13
src/external/rl_gputex.h
vendored
|
|
@ -185,6 +185,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
if (header->ddspf.flags == 0x40) // No alpha channel
|
||||
{
|
||||
int data_size = image_pixel_size*sizeof(unsigned short);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
|
@ -196,6 +197,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
if (header->ddspf.a_bit_mask == 0x8000) // 1bit alpha
|
||||
{
|
||||
int data_size = image_pixel_size*sizeof(unsigned short);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
|
@ -215,6 +217,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
else if (header->ddspf.a_bit_mask == 0xf000) // 4bit alpha
|
||||
{
|
||||
int data_size = image_pixel_size*sizeof(unsigned short);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
|
@ -236,6 +239,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
else if ((header->ddspf.flags == 0x40) && (header->ddspf.rgb_bit_count == 24)) // DDS_RGB, no compressed
|
||||
{
|
||||
int data_size = image_pixel_size*3*sizeof(unsigned char);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
|
@ -245,6 +249,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
else if ((header->ddspf.flags == 0x41) && (header->ddspf.rgb_bit_count == 32)) // DDS_RGBA, no compressed
|
||||
{
|
||||
int data_size = image_pixel_size*4*sizeof(unsigned char);
|
||||
if (header->mipmap_count > 1) data_size = data_size + data_size / 3;
|
||||
image_data = RL_MALLOC(data_size);
|
||||
|
||||
memcpy(image_data, file_data_ptr, data_size);
|
||||
|
|
@ -265,9 +270,11 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_
|
|||
}
|
||||
else if (((header->ddspf.flags == 0x04) || (header->ddspf.flags == 0x05)) && (header->ddspf.fourcc > 0)) // Compressed
|
||||
{
|
||||
// NOTE: This forces only 1 mipmap to be loaded which is not really correct but it works
|
||||
int data_size = (header->pitch_or_linear_size < file_size - 0x80) ? header->pitch_or_linear_size : file_size - 0x80;
|
||||
*mips = 1;
|
||||
int data_size = 0;
|
||||
|
||||
// Calculate data size, including all mipmaps
|
||||
if (header->mipmap_count > 1) data_size = header->pitch_or_linear_size + header->pitch_or_linear_size / 3;
|
||||
else data_size = header->pitch_or_linear_size;
|
||||
|
||||
image_data = RL_MALLOC(data_size*sizeof(unsigned char));
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue