{"id":25323758,"url":"https://github.com/mdmrk/zsdl","last_synced_at":"2025-06-12T00:34:09.040Z","repository":{"id":277220317,"uuid":"931719772","full_name":"mdmrk/zsdl","owner":"mdmrk","description":"SDL3 wrapper for Zig","archived":false,"fork":false,"pushed_at":"2025-03-12T17:40:51.000Z","size":387,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T23:13:44.451Z","etag":null,"topics":["sdl3","zig"],"latest_commit_sha":null,"homepage":"https://mdmrk.github.io/zsdl/","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdmrk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-12T18:38:59.000Z","updated_at":"2025-04-06T18:06:15.000Z","dependencies_parsed_at":"2025-03-10T12:49:30.078Z","dependency_job_id":null,"html_url":"https://github.com/mdmrk/zsdl","commit_stats":null,"previous_names":["mdmrk/zsdl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mdmrk/zsdl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdmrk%2Fzsdl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdmrk%2Fzsdl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdmrk%2Fzsdl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdmrk%2Fzsdl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdmrk","download_url":"https://codeload.github.com/mdmrk/zsdl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdmrk%2Fzsdl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259370969,"owners_count":22847488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sdl3","zig"],"created_at":"2025-02-14T00:25:36.531Z","updated_at":"2025-06-12T00:34:09.011Z","avatar_url":"https://github.com/mdmrk.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zsdl - SDL3 wrapper for Zig\n\nSDL3 wrapper for Zig 0.14.0 built on top of [castholm/SDL](https://github.com/castholm/SDL)'s Zig build system implementation for SDL.\n\nCheck out the [documentation](https://mdmrk.github.io/zsdl/) for more info.\n\n## Usage\n\n```sh\nzig fetch --save git+https://github.com/mdmrk/zsdl.git\n```\n\n```zig\nconst zsdl = b.dependency(\"zsdl\", .{\n    .target = target,\n    .optimize = optimize,\n});\nexe.root_module.addImport(\"zsdl\", zsdl.module(\"zsdl\"));\n```\n## Examples\n\u003cdetails\u003e\n\u003csummary\u003eSimple event loop\u003c/summary\u003e\n\n```zig\nconst std = @import(\"std\");\nconst zsdl = @import(\"zsdl\");\n\npub fn main() !void {\n    try zsdl.init(.{ .video = true });\n    defer zsdl.quit();\n\n    const window = try zsdl.video.Window.create(\n        \"redbed\",\n        1280,\n        720,\n        .{ .resizable = true },\n    );\n    defer window.destroy();\n\n    main_loop: while (true) {\n        while (zsdl.events.pollEvent()) |event| {\n            switch (event) {\n                .quit =\u003e {\n                    break :main_loop;\n                },\n                .window_resized =\u003e |wr| {\n                    std.debug.print(\n                        \"window resized: (w: {any}, h: {any})\\n\",\n                        .{ wr.size.width, wr.size.height },\n                    );\n                },\n                else =\u003e {},\n            }\n        }\n    }\n}\n\n```\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eGPU Spinning Cube\u003c/summary\u003e\n\n```zig\nconst zsdl = @import(\"zsdl\");\nconst std = @import(\"std\");\nconst gpu = zsdl.gpu;\nconst video = zsdl.video;\nconst math = std.math;\n\npub fn rotateMatrix(angle: f32, x: f32, y: f32, z: f32, result: *[16]f32) void {\n    const radians = angle * math.pi / 180.0;\n    const c = @cos(radians);\n    const s = @sin(radians);\n    const c1 = 1.0 - c;\n\n    const length = @sqrt(x * x + y * y + z * z);\n    const u = [3]f32{\n        x / length,\n        y / length,\n        z / length,\n    };\n\n    // Zero the matrix first\n    for (result) |*val| {\n        val.* = 0.0;\n    }\n    result[15] = 1.0;\n\n    // Set up rotation matrix\n    for (0..3) |i| {\n        result[i * 4 + ((i + 1) % 3)] = u[(i + 2) % 3] * s;\n        result[i * 4 + ((i + 2) % 3)] = -u[(i + 1) % 3] * s;\n    }\n\n    for (0..3) |i| {\n        for (0..3) |j| {\n            result[i * 4 + j] += c1 * u[i] * u[j] + (if (i == j) c else 0.0);\n        }\n    }\n}\n\npub fn perspectiveMatrix(fovy: f32, aspect: f32, znear: f32, zfar: f32, result: *[16]f32) void {\n    const f = 1.0 / @tan(fovy * 0.5);\n\n    // Zero the matrix first\n    for (result) |*val| {\n        val.* = 0.0;\n    }\n\n    result[0] = f / aspect;\n    result[5] = f;\n    result[10] = (znear + zfar) / (znear - zfar);\n    result[11] = -1.0;\n    result[14] = (2.0 * znear * zfar) / (znear - zfar);\n    result[15] = 0.0;\n}\n\npub fn multiplyMatrix(lhs: *const [16]f32, rhs: *const [16]f32, result: *[16]f32) void {\n    var tmp: [16]f32 = undefined;\n\n    for (0..4) |i| {\n        for (0..4) |j| {\n            tmp[j * 4 + i] = 0.0;\n\n            for (0..4) |k| {\n                tmp[j * 4 + i] += lhs[k * 4 + i] * rhs[j * 4 + k];\n            }\n        }\n    }\n\n    // Copy result\n    for (0..16) |i| {\n        result[i] = tmp[i];\n    }\n}\n\npub fn translateMatrix(matrix: *[16]f32, x: f32, y: f32, z: f32) void {\n    matrix[12] += x;\n    matrix[13] += y;\n    matrix[14] += z;\n}\n\npub fn main() !void {\n    const Vertex = extern struct {\n        pos: [3]f32,\n        color: [3]f32,\n    };\n\n    const vertices = [_]Vertex{\n        .{ .pos = .{ -0.5, 0.5, -0.5 }, .color = .{ 1.0, 0.0, 0.0 } },\n        .{ .pos = .{ 0.5, -0.5, -0.5 }, .color = .{ 0.0, 0.0, 1.0 } },\n        .{ .pos = .{ -0.5, -0.5, -0.5 }, .color = .{ 0.0, 1.0, 0.0 } },\n        .{ .pos = .{ -0.5, 0.5, -0.5 }, .color = .{ 1.0, 0.0, 0.0 } },\n        .{ .pos = .{ 0.5, 0.5, -0.5 }, .color = .{ 1.0, 1.0, 0.0 } },\n        .{ .pos = .{ 0.5, -0.5, -0.5 }, .color = .{ 0.0, 0.0, 1.0 } },\n        .{ .pos = .{ -0.5, 0.5, 0.5 }, .color = .{ 1.0, 1.0, 1.0 } },\n        .{ .pos = .{ -0.5, -0.5, -0.5 }, .color = .{ 0.0, 1.0, 0.0 } },\n        .{ .pos = .{ -0.5, -0.5, 0.5 }, .color = .{ 0.0, 1.0, 1.0 } },\n        .{ .pos = .{ -0.5, 0.5, 0.5 }, .color = .{ 1.0, 1.0, 1.0 } },\n        .{ .pos = .{ -0.5, 0.5, -0.5 }, .color = .{ 1.0, 0.0, 0.0 } },\n        .{ .pos = .{ -0.5, -0.5, -0.5 }, .color = .{ 0.0, 1.0, 0.0 } },\n        .{ .pos = .{ -0.5, 0.5, 0.5 }, .color = .{ 1.0, 1.0, 1.0 } },\n        .{ .pos = .{ 0.5, 0.5, -0.5 }, .color = .{ 1.0, 1.0, 0.0 } },\n        .{ .pos = .{ -0.5, 0.5, -0.5 }, .color = .{ 1.0, 0.0, 0.0 } },\n        .{ .pos = .{ -0.5, 0.5, 0.5 }, .color = .{ 1.0, 1.0, 1.0 } },\n        .{ .pos = .{ 0.5, 0.5, 0.5 }, .color = .{ 0.0, 0.0, 0.0 } },\n        .{ .pos = .{ 0.5, 0.5, -0.5 }, .color = .{ 1.0, 1.0, 0.0 } },\n        .{ .pos = .{ 0.5, 0.5, -0.5 }, .color = .{ 1.0, 1.0, 0.0 } },\n        .{ .pos = .{ 0.5, -0.5, 0.5 }, .color = .{ 1.0, 0.0, 1.0 } },\n        .{ .pos = .{ 0.5, -0.5, -0.5 }, .color = .{ 0.0, 0.0, 1.0 } },\n        .{ .pos = .{ 0.5, 0.5, -0.5 }, .color = .{ 1.0, 1.0, 0.0 } },\n        .{ .pos = .{ 0.5, 0.5, 0.5 }, .color = .{ 0.0, 0.0, 0.0 } },\n        .{ .pos = .{ 0.5, -0.5, 0.5 }, .color = .{ 1.0, 0.0, 1.0 } },\n        .{ .pos = .{ 0.5, 0.5, 0.5 }, .color = .{ 0.0, 0.0, 0.0 } },\n        .{ .pos = .{ -0.5, -0.5, 0.5 }, .color = .{ 0.0, 1.0, 1.0 } },\n        .{ .pos = .{ 0.5, -0.5, 0.5 }, .color = .{ 1.0, 0.0, 1.0 } },\n        .{ .pos = .{ 0.5, 0.5, 0.5 }, .color = .{ 0.0, 0.0, 0.0 } },\n        .{ .pos = .{ -0.5, 0.5, 0.5 }, .color = .{ 1.0, 1.0, 1.0 } },\n        .{ .pos = .{ -0.5, -0.5, 0.5 }, .color = .{ 0.0, 1.0, 1.0 } },\n        .{ .pos = .{ -0.5, -0.5, -0.5 }, .color = .{ 0.0, 1.0, 0.0 } },\n        .{ .pos = .{ 0.5, -0.5, 0.5 }, .color = .{ 1.0, 0.0, 1.0 } },\n        .{ .pos = .{ -0.5, -0.5, 0.5 }, .color = .{ 0.0, 1.0, 1.0 } },\n        .{ .pos = .{ -0.5, -0.5, -0.5 }, .color = .{ 0.0, 1.0, 0.0 } },\n        .{ .pos = .{ 0.5, -0.5, -0.5 }, .color = .{ 0.0, 0.0, 1.0 } },\n        .{ .pos = .{ 0.5, -0.5, 0.5 }, .color = .{ 1.0, 0.0, 1.0 } },\n    };\n\n    const vertex_shader_source = [_]u8{ 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x08, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc2, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x16, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x43, 0x6c, 0x69, 0x70, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x00, 0x06, 0x00, 0x07, 0x00, 0x16, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x43, 0x75, 0x6c, 0x6c, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x00, 0x05, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x55, 0x42, 0x4f, 0x00, 0x06, 0x00, 0x07, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x22, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x15, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x06, 0x00, 0x16, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x91, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 };\n\n    const fragment_shader_source = [_]u8{ 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x08, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc2, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 };\n\n    try zsdl.init(.{ .video = true });\n    defer zsdl.quit();\n\n    const window = try video.Window.create(\n        \"Spinning Cube\",\n        600,\n        400,\n        .{},\n    );\n    defer window.destroy();\n\n    const device = try gpu.Device.create(\n        .{ .spirv = true },\n        true,\n        null,\n    );\n    defer device.destroy();\n\n    try device.claimWindow(window);\n    defer device.releaseWindow(window);\n\n    const vertex_shader = try device.createShader(.{\n        .code = \u0026vertex_shader_source,\n        .entrypoint = \"main\",\n        .format = .{ .spirv = true },\n        .stage = .vertex,\n        .num_samplers = 0,\n        .num_storage_textures = 0,\n        .num_storage_buffers = 0,\n        .num_uniform_buffers = 1,\n    });\n    defer device.releaseShader(vertex_shader);\n\n    const fragment_shader = try device.createShader(.{\n        .code = \u0026fragment_shader_source,\n        .entrypoint = \"main\",\n        .format = .{ .spirv = true },\n        .stage = .fragment,\n        .num_samplers = 0,\n        .num_storage_textures = 0,\n        .num_storage_buffers = 0,\n        .num_uniform_buffers = 0,\n    });\n    defer device.releaseShader(fragment_shader);\n\n    const vertex_buffer = try device.createBuffer(.{\n        .size = @sizeOf(@TypeOf(vertices)),\n        .usage = .{\n            .vertex = true,\n        },\n    });\n    defer device.releaseBuffer(vertex_buffer);\n\n    const transfer_buffer = try device.createTransferBuffer(.{\n        .size = @sizeOf(@TypeOf(vertices)),\n        .usage = .upload,\n    });\n\n    const map_tb: [*]u8 = @ptrCast(try device.mapTransferBuffer(transfer_buffer, false));\n    @memcpy(map_tb[0..@sizeOf(@TypeOf(vertices))], std.mem.asBytes(\u0026vertices));\n    device.unmapTransferBuffer(transfer_buffer);\n\n    var cmd_buffer = try device.acquireCommandBuffer();\n    const copy_pass = try cmd_buffer.beginCopyPass();\n    const buf_location: gpu.TransferBufferLocation = .{\n        .transfer_buffer = transfer_buffer,\n        .offset = 0,\n    };\n    copy_pass.uploadToBuffer(\u0026buf_location, \u0026.{\n        .buffer = vertex_buffer,\n        .offset = 0,\n        .size = @sizeOf(@TypeOf(vertices)),\n    }, false);\n    copy_pass.end();\n    try cmd_buffer.submit();\n    device.releaseTransferBuffer(transfer_buffer);\n\n    const pipeline = try device.createGraphicsPipeline(.{\n        .vertex_shader = vertex_shader,\n        .fragment_shader = fragment_shader,\n        .vertex_input_state = .{\n            .vertex_buffer_descriptions = \u0026[_]gpu.VertexBufferDescription{\n                .{\n                    .slot = 0,\n                    .pitch = @sizeOf(Vertex),\n                    .input_rate = .vertex,\n                    .instance_step_rate = 0,\n                },\n            },\n            .vertex_attributes = \u0026[_]gpu.VertexAttribute{\n                .{\n                    .location = 0,\n                    .buffer_slot = 0,\n                    .format = .float3,\n                    .offset = @offsetOf(Vertex, \"pos\"),\n                },\n                .{\n                    .location = 1,\n                    .buffer_slot = 0,\n                    .format = .float3,\n                    .offset = @offsetOf(Vertex, \"color\"),\n                },\n            },\n        },\n        .primitive_type = .triangle_list,\n        .multisample_state = .{\n            .sample_count = .@\"1\",\n        },\n        .depth_stencil_state = .{\n            .compare_op = .less_or_equal,\n            .enable_depth_write = true,\n            .enable_depth_test = true,\n        },\n        .target_info = .{\n            .color_target_descriptions = \u0026[_]gpu.ColorTargetDescription{\n                .{\n                    .format = device.getSwapchainTextureFormat(window),\n                },\n            },\n            .depth_stencil_format = .d16_unorm,\n            .has_depth_stencil_target = true,\n        },\n    });\n    defer device.releaseGraphicsPipeline(pipeline);\n\n    const window_size = try window.getSizeInPixels();\n\n    const depth_texture = try device.createTexture(.{\n        .type = .@\"2d\",\n        .format = .d16_unorm,\n        .width = @intCast(window_size.width),\n        .height = @intCast(window_size.height),\n        .layer_count_or_depth = 1,\n        .num_levels = 1,\n        .sample_count = .@\"1\",\n        .usage = .{ .depth_stencil_target = true },\n        .props = 0,\n    });\n    defer device.releaseTexture(depth_texture);\n\n    const msaa_texture = try device.createTexture(.{\n        .type = .@\"2d\",\n        .format = device.getSwapchainTextureFormat(window),\n        .width = @intCast(window_size.width),\n        .height = @intCast(window_size.height),\n        .layer_count_or_depth = 1,\n        .num_levels = 1,\n        .sample_count = .@\"1\",\n        .usage = .{ .color_target = true },\n        .props = 0,\n    });\n    defer device.releaseTexture(msaa_texture);\n\n    const resolve_texture = try device.createTexture(.{\n        .type = .@\"2d\",\n        .format = device.getSwapchainTextureFormat(window),\n        .width = @intCast(window_size.width),\n        .height = @intCast(window_size.height),\n        .layer_count_or_depth = 1,\n        .num_levels = 1,\n        .sample_count = .@\"1\",\n        .usage = .{ .color_target = true, .sampler = true },\n        .props = 0,\n    });\n    defer device.releaseTexture(resolve_texture);\n\n    var angle_x: f32 = 0.0;\n    var angle_y: f32 = 0.0;\n    var angle_z: f32 = 0.0;\n    main_loop: while (true) {\n        while (zsdl.events.pollEvent()) |event| {\n            switch (event) {\n                .quit =\u003e {\n                    break :main_loop;\n                },\n                else =\u003e {},\n            }\n        }\n\n        cmd_buffer = try device.acquireCommandBuffer();\n\n        var swapchain_tex_size_w: u32 = undefined;\n        var swapchain_tex_size_h: u32 = undefined;\n        const swapchain_tex = try cmd_buffer.waitAndAcquireSwapchainTexture(window, \u0026swapchain_tex_size_w, \u0026swapchain_tex_size_h);\n\n        const color_target: gpu.ColorTargetInfo = .{\n            .texture = swapchain_tex,\n            .load_op = .clear,\n            .store_op = .store,\n        };\n\n        const depth_target: gpu.DepthStencilTargetInfo = .{\n            .clear_depth = 1,\n            .load_op = .clear,\n            .store_op = .dont_care,\n            .stencil_load_op = .dont_care,\n            .stencil_store_op = .dont_care,\n            .texture = depth_texture,\n            .cycle = true,\n        };\n\n        const vertex_binding: gpu.BufferBinding = .{\n            .buffer = vertex_buffer,\n            .offset = 0,\n        };\n\n        var matrix_rotate: [16]f32 = undefined;\n        var matrix_modelview: [16]f32 = undefined;\n        var matrix_perspective: [16]f32 = undefined;\n        var matrix_final: [16]f32 = undefined;\n        rotateMatrix(angle_x, 1.0, 0.0, 0.0, \u0026matrix_modelview);\n\n        // Rotate around Y axis\n        rotateMatrix(angle_y, 0.0, 1.0, 0.0, \u0026matrix_rotate);\n        multiplyMatrix(\u0026matrix_rotate, \u0026matrix_modelview, \u0026matrix_modelview);\n\n        // Rotate around Z axis\n        rotateMatrix(angle_z, 0.0, 0.0, 1.0, \u0026matrix_rotate);\n        multiplyMatrix(\u0026matrix_rotate, \u0026matrix_modelview, \u0026matrix_modelview);\n\n        // Pull the camera back from the cube\n        translateMatrix(\u0026matrix_modelview, 0.0, 0.0, -2.5);\n\n        // Create perspective projection\n        const aspect = @as(f32, @floatFromInt(swapchain_tex_size_w)) / @as(f32, @floatFromInt(swapchain_tex_size_h));\n        perspectiveMatrix(45.0, aspect, 0.01, 100.0, \u0026matrix_perspective);\n\n        // Combine modelview and perspective matrices\n        multiplyMatrix(\u0026matrix_perspective, \u0026matrix_modelview, \u0026matrix_final);\n\n        // Update angles for animation\n        angle_x += 3.0;\n        angle_y += 2.0;\n        angle_z += 1.0;\n\n        // Keep angles in 0-360 range\n        angle_x = @mod(angle_x, 360.0);\n        angle_y = @mod(angle_y, 360.0);\n        angle_z = @mod(angle_z, 360.0);\n\n        cmd_buffer.pushVertexUniformData(0, \u0026matrix_final, @sizeOf(@TypeOf(matrix_final)));\n        const render_pass = try cmd_buffer.beginRenderPass(\u0026.{color_target}, \u0026depth_target);\n        render_pass.bindGraphicsPipeline(pipeline);\n        render_pass.bindVertexBuffers(0, \u0026.{vertex_binding});\n        render_pass.drawPrimitives(vertices.len, 1, 0, 0);\n        render_pass.end();\n        try cmd_buffer.submit();\n    }\n}\n```\n\u003c/details\u003e\n\n## Support\n\n| Category | Status | Category | Status | Category | Status |\n|:-|:-:|:-|:-:|:-|:-:|\n| Init | ✅ | Camera | ✅ | Hints | ❌ |\n| Properties | ❌ | Log | ✅ | Video | ✅ |\n| Events | ✅ | Keyboard | ✅ | Mouse | ✅ |\n| Touch | ✅ | Gamepad | ✅ | Joystick | ✅ |\n| Haptic | ✅ | Audio | ✅ | Gpu | ✅ |\n| Clipboard | ✅ | Dialog | ✅ | Filesystem | ❌ |\n| Iostream | ❌ | Atomic | ❌ | Time | ❌ |\n| Timer | ✅ | Render | ✅ | Pixels | ✅ |\n| Surface | ✅ | Platform | ❌ | Misc | ❌ |\n| Main | ❌ | Strings | ❌ | CPU | ❌ |\n| Intrinsics | ❌ | Locale | ❌ | System | ❌ |\n| Metal | ❌ | Vulkan | ❌ | Rect | ✅ |\n\nLegend:\n- ✅ Fully implemented\n- 🧪 Partially implemented/experimental\n- ❌ Not implemented\n\n## Supported targets\n\nRefer to [supported targets](https://github.com/castholm/SDL?tab=readme-ov-file#supported-targets).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdmrk%2Fzsdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdmrk%2Fzsdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdmrk%2Fzsdl/lists"}