-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.bf
More file actions
53 lines (41 loc) · 1.35 KB
/
Program.bf
File metadata and controls
53 lines (41 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using Shaderc;
namespace Example {
class Program {
public static void Main() {
Shaderc.Compiler compiler = scope .();
Shaderc.CompilationResult result = compiler.CompileIntoSpv("", .Vertex, "", "", null);
PrintResult(result);
delete result;
Shaderc.CompileOptions options = scope .();
options.AddMacroDefinition("SOMETHING", "TRUE");
options.SetIncludeCallbacks(new (userData, requestedSource, type, requestingSource, includeDepth) => {
return new .(requestedSource, "float foo() { return 2.0; }");
}, new (userData, includeResult) => {
includeResult.Dispose();
});
//options.SetDirectoryIncludeCallbacks(".");
result = compiler.CompileIntoSpv("""
#version 450
layout(location = 0) in vec2 position;
#include "foo.glsl"
void main() {
gl_Position = vec4(position, 0.0, 0.0);
#ifdef SOMETHING
gl_Position *= foo();
#endif
}
""", .Vertex, "foo/cope.vert", "main", options);
PrintResult(result);
delete result;
Console.Read();
}
private static void PrintResult(Shaderc.CompilationResult result) {
Console.WriteLine("Status: {}", result.Status);
Console.WriteLine("Warnings: {}", result.Warnings);
Console.WriteLine("Errors: {}", result.Errors);
Console.WriteLine("Length: {}", result.Length);
Console.WriteLine("{}", result.ErrorMessage);
}
}
}