{"id":14990720,"url":"https://github.com/zig-gamedev/zwindows","last_synced_at":"2025-04-12T02:43:41.877Z","repository":{"id":252545208,"uuid":"840717050","full_name":"zig-gamedev/zwindows","owner":"zig-gamedev","description":"Windows development SDK for Zig game developers.","archived":false,"fork":false,"pushed_at":"2025-03-25T21:27:13.000Z","size":319,"stargazers_count":11,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-25T22:21:49.988Z","etag":null,"topics":["bindings","gamedev","win32","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zig-gamedev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-08-10T13:23:05.000Z","updated_at":"2025-03-25T21:27:17.000Z","dependencies_parsed_at":"2024-09-24T16:04:11.338Z","dependency_job_id":"c4b3dcc3-0eff-4a6b-95a1-4b54689ae418","html_url":"https://github.com/zig-gamedev/zwindows","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"d81644270ab867ff0ffb4e940f14c643fcb228f7"},"previous_names":["zig-gamedev/zwin32"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-gamedev%2Fzwindows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-gamedev%2Fzwindows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-gamedev%2Fzwindows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zig-gamedev%2Fzwindows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zig-gamedev","download_url":"https://codeload.github.com/zig-gamedev/zwindows/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248507827,"owners_count":21115679,"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":["bindings","gamedev","win32","zig"],"created_at":"2024-09-24T14:20:39.423Z","updated_at":"2025-04-12T02:43:41.871Z","avatar_url":"https://github.com/zig-gamedev.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [zwindows](https://github.com/zig-gamedev/zwindows)\n\nWindows development SDK for Zig game developers.\n\n- Vendored DirectX Compiler binaries for Windows and Linux\n- Vendored DirectX and DirectML runtime libraries\n- Lightweight partial bindings for:\n    * Win32 API (extends std.os.windows)\n    * Direct3D 12\n    * Direct3D 11\n    * DXGI\n    * DirectML\n    * Direct2D\n    * XAudio2\n    * Wincodec (WIC)\n    * WASAPI\n    * Media Foundation\n    * DirectWrite\n- Optional D3D12 helper library (zd3d12)\n- Optional XAudio2 helper library (zxaudio2)\n\n## Using the Zig package\n\nExample build.zig\n```zig\npub fn build(b: *std.Build) !void {\n\n    ...\n\n    const zwindows_dependency = b.dependency(\"zwindows\", .{\n        .zxaudio2_debug_layer = (builtin.mode == .Debug),\n        .zd3d12_debug_layer = (builtin.mode == .Debug),\n        .zd3d12_gbv = b.option(\"zd3d12_gbv\", \"Enable GPU-Based Validation\") orelse false,\n    });\n    \n    // Import the Windows API bindings\n    exe.root_module.addImport(\"zwindows\", zwindows_dependency.module(\"zwindows\"));\n\n    // Import the optional zd3d12 helper library\n    exe.root_module.addImport(\"zd3d12\", zwindows_dependency.module(\"zd3d12\"));\n\n    // Import the optional zxaudio2 helper library\n    exe.root_module.addImport(\"zxaudio2\", zwindows_dependency.module(\"zxaudio2\"));\n    \n    // Install vendored binaries\n    const zwindows = @import(\"zwindows\");\n    try zwindows.install_xaudio2(\u0026exe.step, zwindows_dependency, .bin);\n    try zwindows.install_d3d12(\u0026exe.step, zwindows_dependency, .bin);\n    try zwindows.install_directml(\u0026exe.step, zwindows_dependency, .bin);\n}\n```\n\n### Bindings Usage Example\n```zig\nconst zwindows = @import(\"zwindows\");\nconst windows = zwindows.windows;\nconst dwrite = zwindows.dwrite;\nconst dxgi = zwindows.dxgi;\nconst d3d12 = zwindows.d3d12;\nconst d3d12d = zwindows.d3d12d;\nconst dml = zwindows.directml;\n// etc\n\npub fn main() !void {\n    ...\n    const winclass = windows.WNDCLASSEXA{\n        .style = 0,\n        .lpfnWndProc = processWindowMessage,\n        .cbClsExtra = 0,\n        .cbWndExtra = 0,\n        .hInstance = @ptrCast(windows.HINSTANCE, windows.GetModuleHandleA(null)),\n        .hIcon = null,\n        .hCursor = windows.LoadCursorA(null, @intToPtr(windows.LPCSTR, 32512)),\n        .hbrBackground = null,\n        .lpszMenuName = null,\n        .lpszClassName = name,\n        .hIconSm = null,\n    };\n    _ = windows.RegisterClassExA(\u0026winclass);\n}\n```\n\n## zd3d12\nzd3d12 is an optional helper library for Direct3d 12 build ontop of the zwindows bindings\n\n### Features\n- Basic DirectX 12 context management (descriptor heaps, memory heaps, swapchain, CPU and GPU sync, etc.)\n- Basic DirectX 12 resource management (handle-based resources and pipelines)\n- Basic resource barriers management with simple state-tracking\n- Transient and persistent descriptor allocation\n- Fast image loading using WIC (Windows Imaging Component)\n- Helpers for uploading data to the GPU\n- Fast mipmap generator running on the GPU\n- Interop with Direct2D and DirectWrite for high-quality vector graphics and text rendering (optional)\n\n### Example applications\n- https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/triangle\n- https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/textured_quad\n- https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/vector_graphics_test\n- https://github.com/zig-gamedev/zig-gamedev/blob/main/samples/rasterization\n- https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/bindless\n- https://github.com/zig-gamedev/zig-gamedev/blob/main/samples/mesh_shader_test\n- https://github.com/zig-gamedev/zig-gamedev/blob/main/samples/directml_convolution_test\n\n### Usage Example\n```zig\nconst zd3d12 = @import(\"zd3d12\");\n\n// We need to export below symbols for DirectX 12 Agility SDK.\npub export const D3D12SDKVersion: u32 = 610;\npub export const D3D12SDKPath: [*:0]const u8 = \".\\\\d3d12\\\\\";\n\npub fn main() !void {\n    ...\n    var gctx = zd3d12.GraphicsContext.init(.{\n        .allocator = allocator, \n        .window = win32_window,\n    });\n    defer gctx.deinit(allocator);\n\n    while (...) {\n        gctx.beginFrame();\n\n        const back_buffer = gctx.getBackBuffer();\n        gctx.addTransitionBarrier(back_buffer.resource_handle, .{ .RENDER_TARGET = true });\n        gctx.flushResourceBarriers();\n\n        gctx.cmdlist.OMSetRenderTargets(\n            1,\n            \u0026.{back_buffer.descriptor_handle},\n            TRUE,\n            null,\n        );\n        gctx.cmdlist.ClearRenderTargetView(back_buffer.descriptor_handle, \u0026.{ 0.2, 0.4, 0.8, 1.0 }, 0, null);\n\n        gctx.addTransitionBarrier(back_buffer.resource_handle, d3d12.RESOURCE_STATES.PRESENT);\n        gctx.flushResourceBarriers();\n\n        gctx.endFrame();\n    }\n}\n```\n\n## zxaudio2\nzxaudio2 is an optional helper library for XAudio2 build ontop of the zwindows bindings\n\n### Usage Example\n```zig\nconst zxaudio2 = @import(\"zxaudio2\");\n\npub fn main() !void {\n    ...\n    var actx = zxaudio2.AudioContext.init(allocator);\n\n    const sound_handle = actx.loadSound(\"content/drum_bass_hard.flac\");\n    actx.playSound(sound_handle, .{});\n\n    var music = zxaudio2.Stream.create(allocator, actx.device, \"content/Broke For Free - Night Owl.mp3\");\n    hrPanicOnFail(music.voice.Start(0, xaudio2.COMMIT_NOW));\n    ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzig-gamedev%2Fzwindows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzig-gamedev%2Fzwindows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzig-gamedev%2Fzwindows/lists"}