forked from NCDyson/StudioCCS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
67 lines (61 loc) · 2.52 KB
/
Copy pathProgram.cs
File metadata and controls
67 lines (61 loc) · 2.52 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Avalonia;
using Avalonia.OpenGL;
namespace StudioCCS;
internal sealed class Program
{
// The CCS shaders are desktop GLSL #version 330 and use geometry shaders,
// so every platform must hand us a desktop OpenGL 3.3 (or newer) core
// context rather than the GLES/ANGLE default. Listed newest-first; the
// backend negotiates the first one the driver can provide. We ask for 4.6
// (the highest GL version) so capable drivers also light up the KHR_debug
// output we register in debug builds (core in 4.3); 3.3 is the floor the
// shaders actually require, used when the driver cannot grant anything newer.
private static List<GlVersion> DesktopGlProfiles()
{
return new List<GlVersion>
{
new GlVersion(GlProfileType.OpenGL, 4, 6),
new GlVersion(GlProfileType.OpenGL, 3, 3),
};
}
[STAThread]
public static void Main(string[] args)
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
public static AppBuilder BuildAvaloniaApp()
{
var builder = AppBuilder.Configure<App>()
.UsePlatformDetect();
if (OperatingSystem.IsWindows())
{
// Windows defaults to ANGLE, which only exposes OpenGL ES and so
// cannot compile our desktop #version 330 / geometry shaders.
// Switch the backend to native WGL and request a desktop profile.
// (This routes Avalonia's own compositor through WGL too; that is
// the supported way to get a desktop GL context here.)
builder = builder.With(new Win32PlatformOptions
{
RenderingMode = new[] { Win32RenderingMode.Wgl },
WglProfiles = DesktopGlProfiles(),
});
}
else if (OperatingSystem.IsLinux())
{
builder = builder.With(new X11PlatformOptions
{
GlProfiles = DesktopGlProfiles(),
});
}
// macOS (AvaloniaNative) exposes no GL-version selector: the OS hands
// back an OpenGL 3.2 or 4.1 Core context of its choosing. Geometry
// shaders work on both, but #version 330 compiles only on the 4.1 Core
// context (3.2 Core caps GLSL at 1.50). This must be verified on real
// Mac hardware; if it lands on a 3.2 context the shaders need a
// #version 150 variant. Apple has deprecated OpenGL, so macOS is the
// least certain target here.
return builder
.WithInterFont()
.LogToTrace();
}
}