Merge branch 'raysan5:master' into master
This commit is contained in:
commit
b8fe0c47fa
20 changed files with 150 additions and 132 deletions
|
@ -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));
|
||||
}
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ int main(void)
|
|||
|
||||
int framesCounter = 0;
|
||||
|
||||
//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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue