Brutal C# 游戏开发框架发布大量示例代码
Brutal Gets A Bit Less Brutal
The Brutal C# game development framework released earlier this month free and open source. One of the core tenets of Brutal is that it isn’t easy to use. In fact, that is the source of the name:
The name is a warning.
BRUTAL is intended for experienced programmers who want to make their own architectural decisions and are prepared to build and maintain the systems their games require. Its scope is deliberately focused. The team prioritises low-level functionality for demanding games, with contributions assessed against that purpose.
At launch however this was extremely true, as Brutal launched with no documentation and no examples. Nothing. To figure anything out you basically had to dive into the code and figure things out yourself. Today, well… there’s still no documentation, but there are now examples… lot’s of them in fact.
| 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 |
Even better, there is also a community created example available as well, that showcases a full Vulkan renderer implementation to create a 3D model loader.
Key Links
Community Sample – Hello Brutal
In the video below we jump into the new samples and determine just how brutal the Brutal framework is to use!
来源:GameFromScratch · 游戏开发技术 · gamefromscratch.com
