BRUTAL Samples
Small, self-contained samples for the BRUTAL packages. Each sample is a single C# file that you can run directly with the .NET 10 SDK, with no project file. From a fresh clone of the repository:
cd samples/Hello
dotnet run HelloGlfw.cs
Or from the repository root, dotnet run samples/Hello/HelloGlfw.cs.
The samples come in two kinds:
- Hello/ has one sample per package. Each is the smallest useful starting point for that package.
- Demo/ has fuller programs that combine several packages.
These samples are deliberately minimal.
Error handling
Error handling is kept light on purpose. The samples check the failures you're likely to hit, such as a window that can't be created, a missing GPU feature or a file that doesn't exist, and let everything else throw.
Requirements
- The .NET 10 SDK.
- Windows x64, Linux x64 or macOS on Apple silicon. The packages bundle native libraries for these three.
- Vulkan samples: the packages ship Brutal's own Vulkan helper library, which loads the system's Vulkan loader, and the loader then finds your GPU driver. On Windows both come with your GPU driver. On Linux, install the Vulkan loader and a driver, for example
libvulkan1 and mesa-vulkan-drivers on Debian or Ubuntu. On macOS, install the Vulkan SDK, which provides the loader and MoltenVK.
- Windowed samples: a desktop session. On Linux that means X11 or Wayland.
- Audio samples: an audio output device.
- HelloNativeFileDialog on Linux: GTK 3.
- HelloFmod: your own licensed FMOD libraries; see the file's header.
- HelloNotCurses: a real terminal.
Start here
Foundations
| Sample |
What it shows |
| HelloCore.cs |
Platform detection, ByteSize/ElementCount arithmetic and Ptr<T> |
| HelloMemory.cs |
Allocating and freeing unmanaged memory with Mem, and owning a pointer with PtrOwner<T> |
| HelloCollections.cs |
NativeList<T>, a growable list backed by unmanaged memory |
| HelloStrings.cs |
UTF-8 text with String8 and StringBuilder<byte>, which are designed to avoid allocations |
| HelloNumerics.cs |
Vector and matrix basics with float3 and float4x4 |
| HelloMaths.cs |
The Random extensions: ranges, points in shapes and random directions |
| HelloConcurrency.cs |
Running jobs across worker threads with JobScheduler |
| HelloLogging.cs |
Logging to the console with the default and named categories |
| HelloLocalization.cs |
Localised strings with named variables, and swapping in a translation |
Windowing and UI
Graphics
Textures and assets
| Sample |
What it shows |
| HelloStb.cs |
Writing and reading a PNG with stb_image |
| HelloTexture.cs |
Texture format descriptors, filling a GenericTexture, and saving and loading it as PNG and KTX2 with TextureWriter and TextureLoader |
| HelloKtx.cs |
Creating, writing and loading a KTX2 texture |
| HelloGli.cs |
A texture with a full mip chain, saved and loaded as DDS with GLI |
| HelloGltf.cs |
Parsing a tiny inline glTF, reading its vertices and saving it back out |
| HelloMeshOptimizer.cs |
Reordering triangles for the vertex cache with meshoptimizer |
Audio
| Sample |
What it shows |
| HelloOpenAl.cs |
Playing a generated tone with OpenAL |
| HelloSdlMixer.cs |
Playing a generated tone with Sdl.Mixer |
| HelloFmod.cs |
Playing a tone with FMOD. FMOD's native libraries aren't bundled, so you need your own licensed copy |
Physics
| Sample |
What it shows |
| HelloBox2D.cs |
Dropping a box onto the ground with Box2D and printing where it lands |
| HelloJolt.cs |
Dropping a box onto the ground with Jolt Physics and printing where it lands |
Networking
| Sample |
What it shows |
| HelloRakNet.cs |
A RakNet server and client connecting over localhost and sending a message |
Diagnostics
Demos
| Sample |
What it shows |
| DemoVulkan.cs |
A coloured triangle with Vulkan, the Vulkan.Abstractions helpers, a VMA-allocated vertex buffer and shaders compiled with ShaderC |
| DemoGltfViewer.cs |
Loading a glTF scene with its node transforms, optimising it with meshoptimizer and drawing it lit with OpenGL. Pass your own .gltf or .glb, or it builds a torus knot |
| DemoTexturedQuad.cs |
Writing a mipmapped texture as KTX2, loading it back and drawing it on a floor with OpenGL, with each mip level tinted |
| DemoImGui.cs |
Dear ImGui with FreeType fonts and an ImPlot plot, on GLFW and OpenGL |
| DemoSdl.cs |
An SDL window using Sdl.Image (PNG save and load), Sdl.Mixer (a beep on Space) and Sdl.Ttf (text, if you pass a font) |
| DemoRenderDoc.cs |
An OpenGL triangle that captures a frame with RenderDoc when you press F12 (Windows and Linux) |
| DemoBox2D.cs |
Boxes falling onto the ground with Box2D, drawn with OpenGL |
| DemoJolt.cs |
Boxes falling onto the ground with Jolt Physics, drawn in 3D with OpenGL |