#handmade hero day 23 in zig
1 messages · Page 1 of 1 (latest)
I'm currently doing it, at day 28
Can you share your code? How did you do day 23
I am currently watching it and not sure what is virtual alloc and if it is simillar to page_allocator that we have in zig
VirtualAlloc is a windows api function https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc. it's used to manage virtual memory space. zig doesn't have cross-platform abstractions for managing virtual memory, so you will need to use OS-specific APIs.
page_allocator in zig is an allocator that requests a page of virtual memory for every allocation.
there are other issues that I am struggling with but particually with virtual alloc I don't know if it is important to the implementation the Casey wrote. He did emphasize it so it must play a role but what exactly I don't know
I don't know what he's using it for, so I can't say if it's important or not
hmm i dont remember exactly what part it was but I also use https://github.com/marlersoft/zigwin32 to call win32 api
Zig bindings for Win32 generated by https://github.com/marlersoft/zigwin32gen - marlersoft/zigwin32
so you can call the same functions that casey uses
I can then call VirtualAlloc like this
@ptrFromInt(base_address),
total_storage_size,
.{ .COMMIT = 1, .RESERVE = 1 },
.{ .PAGE_READWRITE = 1 },
) orelse fatalLastError("VirtualAlloc");```
Oh nice, haven't seen it before. I was just thinking of trying mmap to recreate it
yes very useful to follow what casey does 🙂
you can then import it like so const win32 = @import("win32").everything; and do win32."any win32 function and/or constants here"
Thank you for the advice
if you need help to setup the build.zig I can show what I did to make it work
I want to try by myself to get into the water but thanks 😃
Do you plan to finish all of handmade hero in zig?
I know theres alot of episodes ahead but yes. Or least far enough where I feel confident building my own game/engine
goodluck, I am just planning to go over the basics and a few general episode of tidbits