mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 12:38:24 +01:00
samples: add Hello/Demo samples for most BRUTAL packages
Add samples/, a collection of single-file .NET 10 apps run with `dotnet run <file>.cs`. Hello/ has one minimal sample per package that has a public API, many of them headless; Demo/ has fuller programs that combine packages into a more interesting application. samples/README.md indexes every sample and covers the layout, error handling and per-OS requirements.
This commit is contained in:
parent
a25cdf80b2
commit
b0c9fd9cdc
1 changed files with 4599 additions and 1 deletions
37
samples/Hello/HelloShaderC.cs
Normal file
37
samples/Hello/HelloShaderC.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* HelloShaderC
|
||||
*
|
||||
* Compiles a small inline GLSL vertex shader to SPIR-V with shaderc and prints its size.
|
||||
*/
|
||||
|
||||
#:package Ahwoo.Brutal.ShaderC@2026.10.2
|
||||
#:package Ahwoo.Brutal.Core@2026.10.1
|
||||
#:package Ahwoo.Brutal.Strings@2026.10.1
|
||||
|
||||
using Brutal.ShaderCApi;
|
||||
|
||||
Run();
|
||||
|
||||
static void Run()
|
||||
{
|
||||
// Disposed in reverse when Run returns: the result, the options, then the compiler.
|
||||
using var compiler = ShaderC.CreateCompiler();
|
||||
using var options = ShaderC.CreateCompilerOptions();
|
||||
|
||||
using var result = compiler.Compile(
|
||||
"""
|
||||
#version 450
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
"""u8,
|
||||
ShaderKind.VertexShader,
|
||||
"hello.vert"u8,
|
||||
"main"u8,
|
||||
options
|
||||
);
|
||||
|
||||
Console.WriteLine($"Compiled GLSL to {result.GetLength().Value} bytes of SPIR-V");
|
||||
}
|
||||
Loading…
Reference in a new issue