brutal/samples
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Rian Drake c4c62f5528
samples: bump every package pin to the latest release (#39)
Fixes #38

Co-authored-by: LesoDeVaren <268139647+LesoDeVaren@users.noreply.github.com>
2026-11-12 14:15:04 +13:00
..
Demo samples: bump every package pin to the latest release (#39) 2026-11-12 14:15:04 +13:00
Hello samples: bump every package pin to the latest release (#39) 2026-11-12 14:15:04 +13:00
README.md samples: add Hello/Demo samples for most BRUTAL packages (#19) 2026-10-27 09:10:25 +13:00

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

Sample What it shows
HelloGlfw.cs An empty GLFW window
HelloSdl.cs An SDL window with a renderer drawing a filled rectangle
HelloSdlImage.cs Saving a generated image as PNG with Sdl.Image and loading it back
HelloSdlTtf.cs Rendering text to a surface with Sdl.Ttf, using a system font if you don't pass one
HelloImGui.cs Dear ImGui on its GLFW and OpenGL backends with some text, a button and a slider
HelloImGuiFreeType.cs Building the ImGui font atlas with FreeType, without a window
HelloImPlot.cs Plotting a sine wave with ImPlot in one headless frame
HelloImGuiAbstractions.cs The in-game console: registering [TerminalAction] commands and running command lines
HelloImGuiExtensions.cs ImGuiEx widgets bound straight to C# enums
HelloNativeFileDialog.cs The operating system's native file picker
HelloNotCurses.cs Coloured text in the terminal with notcurses (run it in a real terminal)

Graphics

Sample What it shows
HelloOpenGl.cs A coloured triangle with OpenGL
HelloVulkan.cs Creating a Vulkan instance, listing GPUs and their queue families, and creating a device
HelloVulkanAbstractions.cs The Vulkan.Abstractions setup helpers, and a vertex input layout built from C# structs
HelloVulkanVma.cs Creating a VMA allocator and a mapped buffer, writing to it and reading it back
HelloShaderC.cs Compiling GLSL to SPIR-V with shaderc
HelloSlang.cs Compiling Slang to SPIR-V
HelloRenderMesh.cs Generating a procedural sphere mesh

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

Sample What it shows
HelloMonitorHost.cs Starting the Monitor watchdog and writing logs to a file
HelloRenderDoc.cs Checking whether RenderDoc's in-application API is loaded (Windows and Linux)
HelloRenderDocImGui.cs Drawing the RenderDoc control panel with Dear ImGui, headless

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