From 879d8c101f5181d9db3a60af088b523481969e7b Mon Sep 17 00:00:00 2001 From: Senryoku Date: Thu, 14 Nov 2024 21:59:48 +0100 Subject: [PATCH] Fix windows compilation --- src/gdi.zig | 12 ++++++++++-- src/renderer.zig | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gdi.zig b/src/gdi.zig index e4839b9..8d4d10d 100644 --- a/src/gdi.zig +++ b/src/gdi.zig @@ -250,8 +250,16 @@ pub const GDI = struct { .access_mask = std.os.windows.GENERIC_READ | std.os.windows.SYNCHRONIZE, .creation = std.os.windows.FILE_OPEN, }); + errdefer std.os.windows.CloseHandle(file_handle); + const mapping_handle = windows.CreateFileMappingA(file_handle, null, std.os.windows.PAGE_READONLY, 0, 0, null); + if (mapping_handle == null) return error.FileMapError; + errdefer std.os.windows.CloseHandle(mapping_handle.?); + const ptr = windows.MapViewOfFile(mapping_handle.?, std.os.windows.SECTION_MAP_READ, 0, 0, 0); + if (ptr == null) return error.MapViewOfFileError; + errdefer _ = windows.UnmapViewOfFile(ptr.?); + var info: std.os.windows.MEMORY_BASIC_INFORMATION = undefined; _ = try std.os.windows.VirtualQuery(ptr, &info, @sizeOf(std.os.windows.MEMORY_BASIC_INFORMATION)); @@ -261,10 +269,10 @@ pub const GDI = struct { .track_type = track_type, .format = format, .pregap = pregap, - .data = @as([]align(std.mem.page_size) const u8, @alignCast(@ptrCast(ptr)))[0..info.RegionSize], + .data = @as([*]align(std.mem.page_size) const u8, @alignCast(@ptrCast(ptr)))[0..info.RegionSize], .platform_specific = .{ .file_handle = file_handle, - .mapping_handle = mapping_handle, + .mapping_handle = mapping_handle.?, }, }); } diff --git a/src/renderer.zig b/src/renderer.zig index 3f47eeb..0607b9b 100644 --- a/src/renderer.zig +++ b/src/renderer.zig @@ -2787,7 +2787,7 @@ pub const Renderer = struct { pass.draw(3 * volume.triangle_count, 1, 3 * volume.first_triangle_index, 0); } } else { - renderer_log.warn(termcolor.yellow("TODO: Unhandled Open Translucent Mofifier Volume!"), .{}); + renderer_log.warn(termcolor.yellow("TODO: Unhandled Open Translucent Modifier Volume!"), .{}); // TODO: Almost the same thing, but the compute shader is really simple: Take the smallest // depth value and add a volume from it to "infinity" (1.0+ depth). Or find a more efficient way :) }