Compare commits
2 Commits
old-attemp
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 308075678b | |||
| bd3a49dc5a |
86
build.zig
86
build.zig
@@ -27,7 +27,6 @@ pub fn build(b: *std.Build) void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
// This comes from the libomt build scripts
|
// This comes from the libomt build scripts
|
||||||
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/";
|
const omt_out_path = "3rd/libomt/bin/Release/net8.0/linux-x64/publish/";
|
||||||
|
|
||||||
@@ -74,7 +73,6 @@ pub fn build(b: *std.Build) void {
|
|||||||
build_omt_step.dependOn(&install_omt_so.step);
|
build_omt_step.dependOn(&install_omt_so.step);
|
||||||
build_omt_step.dependOn(&install_vmx_so.step);
|
build_omt_step.dependOn(&install_vmx_so.step);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// The output lib and header directories
|
// The output lib and header directories
|
||||||
const lib_output_path: std.Build.LazyPath = .{
|
const lib_output_path: std.Build.LazyPath = .{
|
||||||
@@ -85,27 +83,86 @@ pub fn build(b: *std.Build) void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Zig omt module
|
// Zig omt module
|
||||||
const omt_module = b.addModule("omt", .{
|
const omt_mod = b.addModule("omt", .{
|
||||||
.root_source_file = b.path("src/omt.zig"),
|
.root_source_file = b.path("src/omt.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
omt_module.linkSystemLibrary("omt", .{});
|
omt_mod.linkSystemLibrary("omt", .{});
|
||||||
omt_module.addLibraryPath(lib_output_path);
|
omt_mod.addLibraryPath(lib_output_path);
|
||||||
omt_module.addIncludePath(include_output_path);
|
omt_mod.addIncludePath(include_output_path);
|
||||||
|
|
||||||
|
const sdl3 = b.dependency("sdl3", .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
|
||||||
|
// Lib options.
|
||||||
|
// .callbacks = false,
|
||||||
|
// .ext_image = false,
|
||||||
|
// .ext_net = false,
|
||||||
|
// .ext_ttf = false,
|
||||||
|
// .log_message_stack_size = 1024,
|
||||||
|
// .main = false,
|
||||||
|
// .renderer_debug_text_stack_size = 1024,
|
||||||
|
|
||||||
|
// Options passed directly to https://github.com/castholm/SDL (SDL3 C Bindings):
|
||||||
|
// .c_sdl_preferred_linkage = .static,
|
||||||
|
// .c_sdl_strip = false,
|
||||||
|
// .c_sdl_sanitize_c = .off,
|
||||||
|
// .c_sdl_lto = .none,
|
||||||
|
// .c_sdl_emscripten_pthreads = false,
|
||||||
|
// .c_sdl_install_build_config_h = false,
|
||||||
|
|
||||||
|
// Options if `ext_image` is enabled:
|
||||||
|
// .image_enable_bmp = true,
|
||||||
|
// .image_enable_gif = true,
|
||||||
|
// .image_enable_jpg = true,
|
||||||
|
// .image_enable_lbm = true,
|
||||||
|
// .image_enable_pcx = true,
|
||||||
|
// .image_enable_png = true,
|
||||||
|
// .image_enable_pnm = true,
|
||||||
|
// .image_enable_qoi = true,
|
||||||
|
// .image_enable_svg = true,
|
||||||
|
// .image_enable_tga = true,
|
||||||
|
// .image_enable_xcf = true,
|
||||||
|
// .image_enable_xpm = true,
|
||||||
|
// .image_enable_xv = true,
|
||||||
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
// Define executables
|
// Main executable
|
||||||
const sender_exe = b.addExecutable(.{
|
const omtoy_exe = b.addExecutable(.{
|
||||||
.name = "omtoy-sender",
|
.name = "omtoy",
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/sender.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
sender_exe.root_module.addImport("omt", omt_module);
|
|
||||||
|
omtoy_exe.root_module.addImport("sdl3", sdl3.module("sdl3"));
|
||||||
|
b.installArtifact(omtoy_exe);
|
||||||
|
|
||||||
|
// Run step for main executable
|
||||||
|
const run_step = b.step("run", "Run omtoy");
|
||||||
|
const run_cmd = b.addRunArtifact(omtoy_exe);
|
||||||
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
run_cmd.step.dependOn(b.getInstallStep());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Util executables
|
||||||
|
{
|
||||||
|
// Define executables
|
||||||
|
const sender_exe = b.addExecutable(.{
|
||||||
|
.name = "sender",
|
||||||
|
.root_module = b.createModule(.{
|
||||||
|
.root_source_file = b.path("utils/sender.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
sender_exe.root_module.addImport("omt", omt_mod);
|
||||||
|
|
||||||
sender_exe.root_module.addLibraryPath(lib_output_path);
|
sender_exe.root_module.addLibraryPath(lib_output_path);
|
||||||
sender_exe.root_module.addIncludePath(include_output_path);
|
sender_exe.root_module.addIncludePath(include_output_path);
|
||||||
@@ -128,14 +185,14 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
{
|
{
|
||||||
const receiver_exe = b.addExecutable(.{
|
const receiver_exe = b.addExecutable(.{
|
||||||
.name = "omtoy-receiver",
|
.name = "receiver",
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/receiver.zig"),
|
.root_source_file = b.path("utils/receiver.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
receiver_exe.root_module.addImport("omt", omt_module);
|
receiver_exe.root_module.addImport("omt", omt_mod);
|
||||||
|
|
||||||
receiver_exe.root_module.addLibraryPath(lib_output_path);
|
receiver_exe.root_module.addLibraryPath(lib_output_path);
|
||||||
receiver_exe.root_module.addIncludePath(include_output_path);
|
receiver_exe.root_module.addIncludePath(include_output_path);
|
||||||
@@ -154,7 +211,6 @@ pub fn build(b: *std.Build) void {
|
|||||||
run_receiver_cmd.addArgs(args);
|
run_receiver_cmd.addArgs(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: write tests and stuff
|
// TODO: write tests and stuff
|
||||||
// const exe_tests = b.addTest(.{
|
// const exe_tests = b.addTest(.{
|
||||||
// .root_module = sender_exe.root_module,
|
// .root_module = sender_exe.root_module,
|
||||||
|
|||||||
@@ -32,44 +32,11 @@
|
|||||||
// Once all dependencies are fetched, `zig build` no longer requires
|
// Once all dependencies are fetched, `zig build` no longer requires
|
||||||
// internet connectivity.
|
// internet connectivity.
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
|
.sdl3 = .{
|
||||||
//.example = .{
|
.url = "git+https://github.com/Gota7/zig-sdl3?ref=v0.1.5#014b7bcb2899f3ed9c945c4abfcfe1b25d75bfeb",
|
||||||
// // When updating this field to a new URL, be sure to delete the corresponding
|
.hash = "sdl3-0.1.5-NmT1QxARJgAH1Wp0cMBJDAc9vD7weufTkIwVa5rehA2q",
|
||||||
// // `hash`, otherwise you are communicating that you expect to find the old hash at
|
},
|
||||||
// // the new URL. If the contents of a URL change this will result in a hash mismatch
|
|
||||||
// // which will prevent zig from using it.
|
|
||||||
// .url = "https://example.com/foo.tar.gz",
|
|
||||||
//
|
|
||||||
// // This is computed from the file contents of the directory of files that is
|
|
||||||
// // obtained after fetching `url` and applying the inclusion rules given by
|
|
||||||
// // `paths`.
|
|
||||||
// //
|
|
||||||
// // This field is the source of truth; packages do not come from a `url`; they
|
|
||||||
// // come from a `hash`. `url` is just one of many possible mirrors for how to
|
|
||||||
// // obtain a package matching this `hash`.
|
|
||||||
// //
|
|
||||||
// // Uses the [multihash](https://multiformats.io/multihash/) format.
|
|
||||||
// .hash = "...",
|
|
||||||
//
|
|
||||||
// // When this is provided, the package is found in a directory relative to the
|
|
||||||
// // build root. In this case the package's hash is irrelevant and therefore not
|
|
||||||
// // computed. This field and `url` are mutually exclusive.
|
|
||||||
// .path = "foo",
|
|
||||||
//
|
|
||||||
// // When this is set to `true`, a package is declared to be lazily
|
|
||||||
// // fetched. This makes the dependency only get fetched if it is
|
|
||||||
// // actually used.
|
|
||||||
// .lazy = false,
|
|
||||||
//},
|
|
||||||
},
|
},
|
||||||
// Specifies the set of files and directories that are included in this package.
|
|
||||||
// Only files and directories listed here are included in the `hash` that
|
|
||||||
// is computed for this package. Only files listed here will remain on disk
|
|
||||||
// when using the zig package manager. As a rule of thumb, one should list
|
|
||||||
// files required for compilation plus any license(s).
|
|
||||||
// Paths are relative to the build root. Use the empty string (`""`) to refer to
|
|
||||||
// the build root itself.
|
|
||||||
// A directory listed here means that all files within, recursively, are included.
|
|
||||||
.paths = .{
|
.paths = .{
|
||||||
"build.zig",
|
"build.zig",
|
||||||
"build.zig.zon",
|
"build.zig.zon",
|
||||||
|
|||||||
45
src/main.zig
Normal file
45
src/main.zig
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
const sdl3 = @import("sdl3");
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
const fps = 60;
|
||||||
|
const screen_width = 640;
|
||||||
|
const screen_height = 480;
|
||||||
|
|
||||||
|
pub fn main() !void {
|
||||||
|
std.log.info("Starting omtoy...", .{});
|
||||||
|
|
||||||
|
defer sdl3.shutdown();
|
||||||
|
|
||||||
|
// Initialize SDL with subsystems you need here.
|
||||||
|
const init_flags = sdl3.InitFlags{ .video = true };
|
||||||
|
try sdl3.init(init_flags);
|
||||||
|
defer sdl3.quit(init_flags);
|
||||||
|
|
||||||
|
// Initial window setup.
|
||||||
|
const window = try sdl3.video.Window.init("Hello SDL3", screen_width, screen_height, .{});
|
||||||
|
defer window.deinit();
|
||||||
|
|
||||||
|
// Useful for limiting the FPS and getting the delta time.
|
||||||
|
var fps_capper = sdl3.extras.FramerateCapper(f32){ .mode = .{ .limited = fps } };
|
||||||
|
|
||||||
|
var quit = false;
|
||||||
|
while (!quit) {
|
||||||
|
|
||||||
|
// Delay to limit the FPS, returned delta time not needed.
|
||||||
|
const dt = fps_capper.delay();
|
||||||
|
_ = dt;
|
||||||
|
|
||||||
|
// Update logic.
|
||||||
|
const surface = try window.getSurface();
|
||||||
|
try surface.fillRect(null, surface.mapRgb(128, 30, 255));
|
||||||
|
try window.updateSurface();
|
||||||
|
|
||||||
|
// Event logic.
|
||||||
|
while (sdl3.events.poll()) |event|
|
||||||
|
switch (event) {
|
||||||
|
.quit => quit = true,
|
||||||
|
.terminating => quit = true,
|
||||||
|
else => {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,7 +55,18 @@ pub fn main() !void {
|
|||||||
.FrameMetadataLength = 0,
|
.FrameMetadataLength = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const content = try std.fs.cwd().readFileAlloc("california-1080-uyvy.yuv", allocator, .unlimited);
|
// 0.15
|
||||||
|
const content = try std.fs.cwd().readFileAlloc(
|
||||||
|
allocator,
|
||||||
|
"california-1080-uyvy.yuv",
|
||||||
|
std.math.maxInt(usize),
|
||||||
|
);
|
||||||
|
// 0.16
|
||||||
|
// const content = try std.fs.cwd().readFileAlloc(
|
||||||
|
// "california-1080-uyvy.yuv",
|
||||||
|
// allocator,
|
||||||
|
// .unlimited,
|
||||||
|
// );
|
||||||
defer allocator.free(content);
|
defer allocator.free(content);
|
||||||
|
|
||||||
const audio_samples = 800;
|
const audio_samples = 800;
|
||||||
Reference in New Issue
Block a user