跳到正文
GameFromScratch · 游戏开发技术· 来源· Mike·· 4 小时前AI 评分35

Brutal C# 游戏开发框架发布大量示例代码

Brutal Gets A Bit Less Brutal

正文 · 原文

GameFromScratch.com

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.

SampleWhat it shows
HelloCore.csPlatform detection, ByteSize/ElementCount arithmetic and Ptr<T>
HelloMemory.csAllocating and freeing unmanaged memory with Mem, and owning a pointer with PtrOwner<T>
HelloCollections.csNativeList<T>, a growable list backed by unmanaged memory
HelloStrings.csUTF-8 text with String8 and StringBuilder<byte>, which are designed to avoid allocations
HelloNumerics.csVector and matrix basics with float3 and float4x4
HelloMaths.csThe Random extensions: ranges, points in shapes and random directions
HelloConcurrency.csRunning jobs across worker threads with JobScheduler
HelloLogging.csLogging to the console with the default and named categories
HelloLocalization.csLocalised strings with named variables, and swapping in a translation

Windowing and UI

SampleWhat it shows
HelloGlfw.csAn empty GLFW window
HelloSdl.csAn SDL window with a renderer drawing a filled rectangle
HelloSdlImage.csSaving a generated image as PNG with Sdl.Image and loading it back
HelloSdlTtf.csRendering text to a surface with Sdl.Ttf, using a system font if you don’t pass one
HelloImGui.csDear ImGui on its GLFW and OpenGL backends with some text, a button and a slider
HelloImGuiFreeType.csBuilding the ImGui font atlas with FreeType, without a window
HelloImPlot.csPlotting a sine wave with ImPlot in one headless frame
HelloImGuiAbstractions.csThe in-game console: registering [TerminalAction] commands and running command lines
HelloImGuiExtensions.csImGuiEx widgets bound straight to C# enums
HelloNativeFileDialog.csThe operating system’s native file picker
HelloNotCurses.csColoured text in the terminal with notcurses (run it in a real terminal)

Graphics

SampleWhat it shows
HelloOpenGl.csA coloured triangle with OpenGL
HelloVulkan.csCreating a Vulkan instance, listing GPUs and their queue families, and creating a device
HelloVulkanAbstractions.csThe Vulkan.Abstractions setup helpers, and a vertex input layout built from C# structs
HelloVulkanVma.csCreating a VMA allocator and a mapped buffer, writing to it and reading it back
HelloShaderC.csCompiling GLSL to SPIR-V with shaderc
HelloSlang.csCompiling Slang to SPIR-V
HelloRenderMesh.csGenerating a procedural sphere mesh

Textures and assets

SampleWhat it shows
HelloStb.csWriting and reading a PNG with stb_image
HelloTexture.csTexture format descriptors, filling a GenericTexture, and saving and loading it as PNG and KTX2 with TextureWriter and TextureLoader
HelloKtx.csCreating, writing and loading a KTX2 texture
HelloGli.csA texture with a full mip chain, saved and loaded as DDS with GLI
HelloGltf.csParsing a tiny inline glTF, reading its vertices and saving it back out
HelloMeshOptimizer.csReordering triangles for the vertex cache with meshoptimizer

Audio

SampleWhat it shows
HelloOpenAl.csPlaying a generated tone with OpenAL
HelloSdlMixer.csPlaying a generated tone with Sdl.Mixer
HelloFmod.csPlaying a tone with FMOD. FMOD’s native libraries aren’t bundled, so you need your own licensed copy

Physics

SampleWhat it shows
HelloBox2D.csDropping a box onto the ground with Box2D and printing where it lands
HelloJolt.csDropping a box onto the ground with Jolt Physics and printing where it lands

Networking

SampleWhat it shows
HelloRakNet.csA RakNet server and client connecting over localhost and sending a message

Diagnostics

SampleWhat it shows
HelloMonitorHost.csStarting the Monitor watchdog and writing logs to a file
HelloRenderDoc.csChecking whether RenderDoc’s in-application API is loaded (Windows and Linux)
HelloRenderDocImGui.csDrawing the RenderDoc control panel with Dear ImGui, headless

Demos

SampleWhat it shows
DemoVulkan.csA coloured triangle with Vulkan, the Vulkan.Abstractions helpers, a VMA-allocated vertex buffer and shaders compiled with ShaderC
DemoGltfViewer.csLoading 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.csWriting a mipmapped texture as KTX2, loading it back and drawing it on a floor with OpenGL, with each mip level tinted
DemoImGui.csDear ImGui with FreeType fonts and an ImPlot plot, on GLFW and OpenGL
DemoSdl.csAn 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.csAn OpenGL triangle that captures a frame with RenderDoc when you press F12 (Windows and Linux)
DemoBox2D.csBoxes falling onto the ground with Box2D, drawn with OpenGL
DemoJolt.csBoxes 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

Brutal Framework Homepage

Brutal Samples

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