Skip to content

Latest commit

 

History

History
76 lines (54 loc) · 3.38 KB

NOTES.adoc

File metadata and controls

76 lines (54 loc) · 3.38 KB

SDL Platform

Internet resources

Handmade Penguin - companion to Casey Muratori’s amazing Handmade Hero series, for Linux. https://davidgow.net/handmadepenguin/default.html

DONE

Pass controller input to the application

Add sound

Which approach is better - SDL_QueueAudio or SDL_AudioSpec.callback? https://wiki.libsdl.org/SDL2/SDL_AudioSpec https://wiki.libsdl.org/SDL2/SDL_QueueAudio SDL_QueueAudio is simpler to use - you don’t have to maintain a ringbuffer of audio data. But it could be more complicated to do the "optimistic" writing of audio: https://davidgow.net/handmadepenguin/ch12.html

We might want to "optimistically" write an extra frame or two's worth of audio data into our buffer,
and then overwrite it when we actually render the next frame. This would give us some leeway if the
game ran slowly. While this can be done with SDL_QueueAudio() and its companion function
SDL_ClearQueuedAudio(), it is much harder to get right.

It seems that the callback function gives more control, so I will use that.

Game defines a callback method for filling a sound buffer. For now the callback receives the target buffer and requested sample count.

Platform initializes a persistent ring buffer for storing the received sound data. Platform executes the callback with a temporary buffer. Platform writes sound data from the temporary buffer to the ring buffer. SDL reads the sound data from the ring buffer via another callback, defined in the platform.

Fix the example application on NixOS

/home/reinis/dev/learn/zig/zig_sdl_platform/zig-out/bin/example: /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by /nix/store/yaz7pyf0ah88g2v505l38n0f3wg2vzdj-glibc-2.37-8/lib/libpthread.so.0)
/home/reinis/dev/learn/zig/zig_sdl_platform/zig-out/bin/example: /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by /nix/store/yaz7pyf0ah88g2v505l38n0f3wg2vzdj-glibc-2.37-8/lib/librt.so.1)
/home/reinis/dev/learn/zig/zig_sdl_platform/zig-out/bin/example: /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libc.so.6: version `GLIBC_2.36' not found (required by /nix/store/0d4xl0xk1g0w41yqyd64jvzbip5lhfig-libXdmcp-1.1.3/lib/libXdmcp.so.6)

This could be related: NixOS/nixpkgs#228899

Checked that the application builds and runs OK on non-NixOS.

A bug has been registered against Zig: ziglang/zig#15898

For now I will use nixpkgs 22.11 (same as my NixOS config) as a workaround.