Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/raysan5/raylib
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Nov 14, 2024
2 parents f76a5e2 + 377248b commit 2841eab
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 15 deletions.
23 changes: 9 additions & 14 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,18 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
.flags = raylib_flags_arr.items,
});

if (options.raygui) {
const raygui_dep = b.dependency(options.raygui_dependency_name, .{});
return raylib;
}

var gen_step = b.addWriteFiles();
raylib.step.dependOn(&gen_step.step);
pub fn addRaygui(b: *std.Build, raylib: *std.Build.Step.Compile, raygui_dep: *std.Build.Dependency) void {
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");
}
const raygui_c_path = gen_step.add("raygui.c", "#define RAYGUI_IMPLEMENTATION\n#include \"raygui.h\"\n");
raylib.addCSourceFile(.{ .file = raygui_c_path });
raylib.addIncludePath(raygui_dep.path("src"));

return raylib;
raylib.installHeader(raygui_dep.path("src/raygui.h"), "raygui.h");
}

pub const Options = struct {
Expand All @@ -319,23 +318,19 @@ pub const Options = struct {
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,
Expand Down
56 changes: 55 additions & 1 deletion examples/Makefile.Web
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# --preload-file resources # specify a resources folder for data compilation
# --source-map-base # allow debugging in browser with source map
LDFLAGS += -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall

# Build using asyncify
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
LDFLAGS += -sASYNCIFY
Expand Down Expand Up @@ -383,6 +383,7 @@ CORE = \
core/core_automation_events \
core/core_basic_screen_manager \
core/core_basic_window \
core/core_basic_window_web \
core/core_custom_frame_control \
core/core_custom_logging \
core/core_drop_files \
Expand Down Expand Up @@ -587,6 +588,9 @@ core/core_automation_events : core/core_automation_events.c
core/core_basic_window: core/core_basic_window.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

core/core_basic_window_web: core/core_basic_window_web.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

core/core_basic_screen_manager: core/core_basic_screen_manager.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

Expand Down Expand Up @@ -625,6 +629,9 @@ core/core_input_mouse_wheel: core/core_input_mouse_wheel.c
core/core_input_multitouch: core/core_input_multitouch.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

core/core_input_virtual_controls: core/core_input_virtual_controls.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

# NOTE: To use multi-threading raylib must be compiled with multi-theading support (-s USE_PTHREADS=1)
# WARNING: For security reasons multi-threading is not supported on browsers, it requires cross-origin isolation (Oct.2021)
# WARNING: It requires raylib to be compiled using -pthread, so atomic operations and thread-local data (if any)
Expand Down Expand Up @@ -747,6 +754,10 @@ textures/textures_gif_player: textures/textures_gif_player.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/scarfy_run.gif@resources/scarfy_run.gif

textures/textures_image_channel: textures/textures_image_channel.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/fudesumi.png@resources/fudesumi.png

textures/textures_image_drawing: textures/textures_image_drawing.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file textures/resources/custom_jupiter_crash.png@resources/custom_jupiter_crash.png \
Expand Down Expand Up @@ -907,6 +918,13 @@ models/models_billboard: models/models_billboard.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/billboard.png@resources/billboard.png

models/models_bone_socket: models/models_bone_socket.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file models/resources/models/gltf/greenman.glb@resources/models/gltf/greenman.glb \
--preload-file models/resources/models/gltf/greenman_hat.glb@resources/models/gltf/greenman_hat.glb \
--preload-file models/resources/models/gltf/greenman_sword.glb@resources/models/gltf/greenman_sword.glb \
--preload-file models/resources/models/gltf/greenman_shield.glb@resources/models/gltf/greenman_shield.glb

models/models_box_collisions: models/models_box_collisions.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

Expand Down Expand Up @@ -961,6 +979,9 @@ models/models_mesh_picking: models/models_mesh_picking.c
models/models_orthographic_projection: models/models_orthographic_projection.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

models/models_point_rendering: models/models_point_rendering.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

models/models_rlgl_solar_system: models/models_rlgl_solar_system.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

Expand Down Expand Up @@ -988,6 +1009,24 @@ shaders/shaders_basic_lighting: shaders/shaders_basic_lighting.c
--preload-file shaders/resources/shaders/glsl100/lighting.fs@resources/shaders/glsl100/lighting.fs \
--preload-file shaders/resources/shaders/glsl100/lighting.vs@resources/shaders/glsl100/lighting.vs

shaders/shaders_basic_pbr: shaders/shaders_basic_pbr.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/pbr.vs@resources/shaders/glsl100/pbr.vs \
--preload-file shaders/resources/shaders/glsl120/pbr.vs@resources/shaders/glsl120/pbr.vs \
--preload-file shaders/resources/shaders/glsl330/pbr.vs@resources/shaders/glsl330/pbr.vs \
--preload-file shaders/resources/shaders/glsl100/pbr.fs@resources/shaders/glsl100/pbr.fs \
--preload-file shaders/resources/shaders/glsl120/pbr.fs@resources/shaders/glsl120/pbr.fs \
--preload-file shaders/resources/shaders/glsl330/pbr.fs@resources/shaders/glsl330/pbr.fs \
--preload-file shaders/resources/models/old_car_new.glb@resources/models/old_car_new.glb \
--preload-file shaders/resources/old_car_d.png@resources/old_car_d.png \
--preload-file shaders/resources/old_car_mra.png@resources/old_car_mra.png \
--preload-file shaders/resources/old_car_n.png@resources/old_car_n.png \
--preload-file shaders/resources/old_car_e.png@resources/old_car_e.png \
--preload-file shaders/resources/models/plane.glb@resources/models/plane.glb \
--preload-file shaders/resources/road_a.png@resources/road_a.png \
--preload-file shaders/resources/road_mra.png@resources/road_mra.png \
--preload-file shaders/resources/road_n.png@resources/road_n.png

shaders/shaders_custom_uniform: shaders/shaders_custom_uniform.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 \
--preload-file shaders/resources/models/barracks.obj@resources/models/barracks.obj \
Expand Down Expand Up @@ -1061,6 +1100,14 @@ shaders/shaders_raymarching: shaders/shaders_raymarching.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/raymarching.fs@resources/shaders/glsl100/raymarching.fs

shaders/shaders_shadowmap: shaders/shaders_shadowmap.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl120/shadowmap.vs@resources/shaders/glsl120/shadowmap.vs \
--preload-file shaders/resources/shaders/glsl330/shadowmap.vs@resources/shaders/glsl330/shadowmap.vs \
--preload-file shaders/resources/shaders/glsl120/shadowmap.fs@resources/shaders/glsl120/shadowmap.fs \
--preload-file shaders/resources/shaders/glsl330/shadowmap.fs@resources/shaders/glsl330/shadowmap.fs \
--preload-file shaders/resources/models/robot.glb@resources/models/robot.glb

shaders/shaders_shapes_textures: shaders/shaders_shapes_textures.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/fudesumi.png@resources/fudesumi.png \
Expand Down Expand Up @@ -1101,6 +1148,13 @@ shaders/shaders_write_depth: shaders/shaders_write_depth.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/write_depth.fs@resources/shaders/glsl100/write_depth.fs

shaders/shaders_vertex_displacement: shaders/shaders_vertex_displacement.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
--preload-file shaders/resources/shaders/glsl100/vertex_displacement.vs@resources/shaders/glsl100/vertex_displacement.vs \
--preload-file shaders/resources/shaders/glsl330/vertex_displacement.vs@resources/shaders/glsl330/vertex_displacement.vs \
--preload-file shaders/resources/shaders/glsl100/vertex_displacement.fs@resources/shaders/glsl100/vertex_displacement.fs \
--preload-file shaders/resources/shaders/glsl330/vertex_displacement.fs@resources/shaders/glsl330/vertex_displacement.fs


# Compile AUDIO examples
audio/audio_mixed_processor: audio/audio_mixed_processor.c
Expand Down

0 comments on commit 2841eab

Please sign in to comment.