Skip to content

Commit

Permalink
Merge branch 'master' into package
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Dec 4, 2023
2 parents ae51b3b + affdb5c commit 2a0d82e
Show file tree
Hide file tree
Showing 17 changed files with 4,298 additions and 2,256 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Related projects:
- [pacman.zig](https://github.com/floooh/pacman.zig)
- [kc85.zig](https://github.com/floooh/kc85.zig)

> NOTE: for experimental package manager support see the branch [package](https://github.com/floooh/sokol-zig/tree/package),
> and as example for how to integrate sokol-zig as package the [pacman.zig branch sokol-package](https://github.com/floooh/pacman.zig/tree/sokol-package)
## BUILD

Supported platforms are: Windows, macOS, Linux (with X11)
Expand Down
39 changes: 32 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep {
_backend = .d3d11;
} else if (lib.target.getCpu().arch == .wasm32) {
_backend = .gles3;
} else if (lib.target.getAbi() == .android) {
_backend = .gles3;
} else {
_backend = .gl;
}
Expand All @@ -154,28 +156,51 @@ pub fn buildLibSokol(b: *Build, options: LibSokolOptions) !*CompileStep {
.flags = &[_][]const u8{ "-ObjC", "-DIMPL", backend_option },
});
}
lib.linkFramework("Cocoa");
lib.linkFramework("QuartzCore");
lib.linkFramework("Foundation");
lib.linkFramework("AudioToolbox");
if (.metal == _backend) {
lib.linkFramework("MetalKit");
lib.linkFramework("Metal");
} else {
lib.linkFramework("OpenGL");
}
if (lib.target.getOsTag() == .ios) {
lib.linkFramework("UIKit");
lib.linkFramework("AVFoundation");
if (.gl == _backend) {
lib.linkFramework("OpenGLES");
lib.linkFramework("GLKit");
}
} else if (lib.target.getOsTag() == .macos) {
lib.linkFramework("Cocoa");
lib.linkFramework("QuartzCore");
if (.gl == _backend) {
lib.linkFramework("OpenGL");
}
}
} else if (lib.target.getAbi() == .android) {
if (.gles3 != _backend) {
@panic("For android targets, you must have backend set to GLES3");
}
for (csources) |csrc| {
lib.addCSourceFile(.{
.file = .{ .path = try std.fmt.allocPrint(b.allocator, "{s}/{s}", .{ sokol_path, csrc }) },
.flags = &[_][]const u8{ "-DIMPL", backend_option },
});
}
lib.linkSystemLibrary("GLESv3");
lib.linkSystemLibrary("EGL");
lib.linkSystemLibrary("android");
lib.linkSystemLibrary("log");
} else if (lib.target.isLinux()) {
const egl_flag = if (options.force_egl) "-DSOKOL_FORCE_EGL " else "";
const x11_flag = if (!options.enable_x11) "-DSOKOL_DISABLE_X11 " else "";
const wayland_flag = if (!options.enable_wayland) "-DSOKOL_DISABLE_WAYLAND" else "";

const link_egl = options.force_egl or options.enable_wayland;
for (csources) |csrc| {
lib.addCSourceFile(.{
.file = .{ .path = try std.fmt.allocPrint(b.allocator, "{s}/{s}", .{ sokol_path, csrc }) },
.flags = &[_][]const u8{ "-DIMPL", backend_option, egl_flag, x11_flag, wayland_flag },
});
}
const link_egl = options.force_egl or options.enable_wayland;

lib.linkSystemLibrary("asound");
lib.linkSystemLibrary("GL");
if (options.enable_x11) {
Expand Down
2 changes: 1 addition & 1 deletion src/examples/debugtext-print.zig
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export fn frame() void {
sdtx.color3b(255, 128, 0);

// can also use sdtx.Writer with std.fmt directly:
var writer: sdtx.Writer = .{};
const writer: sdtx.Writer = .{};
fmt.format(writer, "using std.fmt directly ({d})\n", .{state.frame_count}) catch unreachable;

// render the frame via sokol.gfx
Expand Down
16 changes: 8 additions & 8 deletions src/examples/shaders/mrt.glsl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const sg = @import("sokol").gfx;
// Multisampled: false
// Bind slot: SLOT_tex = 0
// Sampler 'smp':
// Type: .SAMPLE
// Type: .FILTERING
// Bind slot: SLOT_smp = 0
// Image Sampler Pair 'tex_smp':
// Image: tex
Expand Down Expand Up @@ -51,7 +51,7 @@ const sg = @import("sokol").gfx;
// Multisampled: false
// Bind slot: SLOT_tex2 = 2
// Sampler 'smp':
// Type: .SAMPLE
// Type: .FILTERING
// Bind slot: SLOT_smp = 0
// Image Sampler Pair 'tex0_smp':
// Image: tex0
Expand Down Expand Up @@ -1212,7 +1212,7 @@ pub fn dbgShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand All @@ -1233,7 +1233,7 @@ pub fn dbgShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand All @@ -1249,7 +1249,7 @@ pub fn dbgShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand Down Expand Up @@ -1286,7 +1286,7 @@ pub fn fsqShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[2].image_type = ._2D;
desc.fs.images[2].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand Down Expand Up @@ -1325,7 +1325,7 @@ pub fn fsqShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[2].image_type = ._2D;
desc.fs.images[2].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand Down Expand Up @@ -1357,7 +1357,7 @@ pub fn fsqShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[2].image_type = ._2D;
desc.fs.images[2].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/examples/shaders/offscreen.glsl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const sg = @import("sokol").gfx;
// Multisampled: false
// Bind slot: SLOT_tex = 0
// Sampler 'smp':
// Type: .SAMPLE
// Type: .FILTERING
// Bind slot: SLOT_smp = 0
// Image Sampler Pair 'tex_smp':
// Image: tex
Expand Down Expand Up @@ -816,7 +816,7 @@ pub fn defaultShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand All @@ -843,7 +843,7 @@ pub fn defaultShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand All @@ -861,7 +861,7 @@ pub fn defaultShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/examples/shaders/texcube.glsl.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const sg = @import("sokol").gfx;
// Multisampled: false
// Bind slot: SLOT_tex = 0
// Sampler 'smp':
// Type: .SAMPLE
// Type: .FILTERING
// Bind slot: SLOT_smp = 0
// Image Sampler Pair 'tex_smp':
// Image: tex
Expand Down Expand Up @@ -445,7 +445,7 @@ pub fn texcubeShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand All @@ -472,7 +472,7 @@ pub fn texcubeShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand All @@ -490,7 +490,7 @@ pub fn texcubeShaderDesc(backend: sg.Backend) sg.ShaderDesc {
desc.fs.images[0].image_type = ._2D;
desc.fs.images[0].sample_type = .FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = .SAMPLE;
desc.fs.samplers[0].sampler_type = .FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
Expand Down
16 changes: 14 additions & 2 deletions src/sokol/app.zig
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ pub const IconDesc = extern struct {
images: [8]ImageDesc = [_]ImageDesc{.{}} ** 8,
};
pub const Allocator = extern struct {
alloc: ?*const fn (usize, ?*anyopaque) callconv(.C) ?*anyopaque = null,
free: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = null,
alloc_fn: ?*const fn (usize, ?*anyopaque) callconv(.C) ?*anyopaque = null,
free_fn: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = null,
user_data: ?*anyopaque = null,
};
pub const LogItem = enum(i32) {
Expand Down Expand Up @@ -309,6 +309,18 @@ pub const LogItem = enum(i32) {
ANDROID_NATIVE_ACTIVITY_ONCREATE,
ANDROID_CREATE_THREAD_PIPE_FAILED,
ANDROID_NATIVE_ACTIVITY_CREATE_SUCCESS,
WGPU_SWAPCHAIN_CREATE_SURFACE_FAILED,
WGPU_SWAPCHAIN_CREATE_SWAPCHAIN_FAILED,
WGPU_SWAPCHAIN_CREATE_DEPTH_STENCIL_TEXTURE_FAILED,
WGPU_SWAPCHAIN_CREATE_DEPTH_STENCIL_VIEW_FAILED,
WGPU_SWAPCHAIN_CREATE_MSAA_TEXTURE_FAILED,
WGPU_SWAPCHAIN_CREATE_MSAA_VIEW_FAILED,
WGPU_REQUEST_DEVICE_STATUS_ERROR,
WGPU_REQUEST_DEVICE_STATUS_UNKNOWN,
WGPU_REQUEST_ADAPTER_STATUS_UNAVAILABLE,
WGPU_REQUEST_ADAPTER_STATUS_ERROR,
WGPU_REQUEST_ADAPTER_STATUS_UNKNOWN,
WGPU_CREATE_INSTANCE_FAILED,
IMAGE_DATA_SIZE_MISMATCH,
DROPPED_FILE_PATH_TOO_LONG,
CLIPBOARD_STRING_TOO_BIG,
Expand Down
4 changes: 2 additions & 2 deletions src/sokol/audio.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub const Logger = extern struct {
user_data: ?*anyopaque = null,
};
pub const Allocator = extern struct {
alloc: ?*const fn (usize, ?*anyopaque) callconv(.C) ?*anyopaque = null,
free: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = null,
alloc_fn: ?*const fn (usize, ?*anyopaque) callconv(.C) ?*anyopaque = null,
free_fn: ?*const fn (?*anyopaque, ?*anyopaque) callconv(.C) void = null,
user_data: ?*anyopaque = null,
};
pub const Desc = extern struct {
Expand Down
Loading

0 comments on commit 2a0d82e

Please sign in to comment.