Skip to content

Commit

Permalink
* Updated to Wwise 2023.1.5
Browse files Browse the repository at this point in the history
* Updated to latest upstream zigwin32
  • Loading branch information
mlarouche committed Aug 27, 2024
1 parent f1b8499 commit 790604a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# wwise-zig-demo - Demo application of the wwise-zig bindings (2023.1.4)
# wwise-zig-demo - Demo application of the wwise-zig bindings (2023.1.5)

This a port of the Integration Demo from the samples in Zig using [wwise-zig](https://github.com/Cold-Bytes-Games/wwise-zig) and using [zig-gamedev](https://github.com/michal-z/zig-gamedev) `zgui` for the UI rendering.

Expand Down
10 changes: 5 additions & 5 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.{
.name = "wwise-zig-demo",
.version = "2023.1.4-zig1",
.version = "2023.1.5-zig0",
.paths = .{"."},
.dependencies = .{
.@"wwise-zig" = .{
.url = "https://github.com/Cold-Bytes-Games/wwise-zig/archive/4698db00aafd0a220f6aa33bd47d24c76e606a24.tar.gz",
.hash = "1220fabf555f2ab9c2950dcedd7f0563a1ca3772e96450a9588d4bbb8974e146961b",
.url = "https://github.com/Cold-Bytes-Games/wwise-zig/archive/840b9b34a18b97754e6c535d07f86ccbfec86183.tar.gz",
.hash = "1220adb0b295d6ec9c9def87e2aa3f63e1d46fa477a6562744140372b3cc994f6c70",
},
.zgui = .{
.path = "vendor/zgui",
},
.zigwin32 = .{
.url = "https://github.com/Cold-Bytes-Games/zigwin32/archive/c1b683e26930f0356eebb826fe8ece4132f2845a.tar.gz",
.hash = "122023ef82db4cd40ca336e907ae3ee3b46c957b24fea36a4e72048d5884e67ea9cc",
.url = "https://github.com/marlersoft/zigwin32/archive/407a4c7b869ee3d10db520fdfae8b9faf9b2adb5.tar.gz",
.hash = "1220cc9c9028e20f4ec2ece1155ae3479acc1cc509f9ab93acb74e8f5bbf8eefd2a9",
},
},
}
24 changes: 12 additions & 12 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,32 @@ pub const DxContext = struct {
pub fn createRenderTarget(self: *DxContext) void {
var back_buffer_opt: ?*d3d11.ID3D11Texture2D = null;
if (self.swap_chain) |swap_chain| {
_ = swap_chain.IDXGISwapChain_GetBuffer(0, d3d11.IID_ID3D11Texture2D, @ptrCast(&back_buffer_opt));
_ = swap_chain.GetBuffer(0, d3d11.IID_ID3D11Texture2D, @ptrCast(&back_buffer_opt));
}
if (self.device) |device| {
_ = device.ID3D11Device_CreateRenderTargetView(@ptrCast(back_buffer_opt), null, @ptrCast(&self.main_render_target_view));
_ = device.CreateRenderTargetView(@ptrCast(back_buffer_opt), null, @ptrCast(&self.main_render_target_view));
}
if (back_buffer_opt) |back_buffer| {
_ = back_buffer.IUnknown_Release();
_ = back_buffer.IUnknown.Release();
}
}

pub fn cleanupDeviceD3D(self: *DxContext) void {
self.cleanupRenderTarget();
if (self.swap_chain) |swap_chain| {
_ = swap_chain.IUnknown_Release();
_ = swap_chain.IUnknown.Release();
}
if (self.device_context) |device_context| {
_ = device_context.IUnknown_Release();
_ = device_context.IUnknown.Release();
}
if (self.device) |device| {
_ = device.IUnknown_Release();
_ = device.IUnknown.Release();
}
}

pub fn cleanupRenderTarget(self: *DxContext) void {
if (self.main_render_target_view) |main_render_target_view| {
_ = main_render_target_view.IUnknown_Release();
_ = main_render_target_view.IUnknown.Release();
self.main_render_target_view = null;
}
}
Expand Down Expand Up @@ -495,7 +495,7 @@ fn update(allocator: std.mem.Allocator, demo: *DemoState) !void {
if (demo.graphics_context.swap_chain) |swap_chain| {
var desc: dxgi.DXGI_SWAP_CHAIN_DESC = undefined;

_ = swap_chain.IDXGISwapChain_GetDesc(&desc);
_ = swap_chain.GetDesc(&desc);

width = desc.BufferDesc.Width;
height = desc.BufferDesc.Height;
Expand Down Expand Up @@ -543,14 +543,14 @@ fn draw(demo: *DemoState) void {
};

if (graphics_context.device_context) |device_context| {
_ = device_context.ID3D11DeviceContext_OMSetRenderTargets(1, @ptrCast(@constCast(&graphics_context.main_render_target_view)), null);
_ = device_context.ID3D11DeviceContext_ClearRenderTargetView(graphics_context.main_render_target_view, @ptrCast(&clear_color));
_ = device_context.OMSetRenderTargets(1, @ptrCast(@constCast(&graphics_context.main_render_target_view)), null);
_ = device_context.ClearRenderTargetView(graphics_context.main_render_target_view, @ptrCast(&clear_color));
}

zgui.backend.draw();

if (graphics_context.swap_chain) |swap_chain| {
_ = swap_chain.IDXGISwapChain_Present(1, 0);
_ = swap_chain.Present(1, 0);
}
}

Expand Down Expand Up @@ -662,7 +662,7 @@ pub fn WndProc(hWnd: win32.HWND, msg: u32, wParam: win32.WPARAM, lParam: win32.L
if (demo_opt) |demo| {
if (demo.graphics_context.swap_chain) |swap_chain| {
demo.graphics_context.cleanupRenderTarget();
_ = swap_chain.IDXGISwapChain_ResizeBuffers(0, @as(u32, @intCast(lParam)) & 0xFFFF, (@as(u32, @intCast(lParam)) >> 16) & 0xFFFF, .UNKNOWN, 0);
_ = swap_chain.ResizeBuffers(0, @as(u32, @intCast(lParam)) & 0xFFFF, (@as(u32, @intCast(lParam)) >> 16) & 0xFFFF, .UNKNOWN, 0);
demo.graphics_context.createRenderTarget();
}
}
Expand Down

0 comments on commit 790604a

Please sign in to comment.