// If a "root surface" has already been created, we will use Surface.Current internally to create a "subsurface"
ISurface surface = Surface.CreateNew() // returns ISurfaceBuilder
// requests in order of preference
// equivalent to .RequestSingleton<T>(...) where T is a IComponentBuilder containing a HluComponentType that we use to discriminate (e.g. HluComponentType.Graphics)
.RequestGraphics<IVkSurfaceBuilder>(
ctx => ctx.WithVersion(1, 3)
.WithSupportedInstanceExtensions<Silk.NET.Vulkan.ExtDebugUtils>() // in addition to the ones required to create the surface
.Build()
)
.RequestGraphics<IGLContextBuilder>(
ctx => ctx.WithVersion(4, 3)
.WithProfile(OpenGLProfile.Core)
.Build()
)
.Build();
// equivalent to .Singleton(HluComponentType.Graphics)
surface.Graphics() switch
{
IGLContext ctx => Console.WriteLine("Using OpenGL"),
IVkSurface surf => Console.WriteLine("Using Vulkan"),
_ => throw new("no requests were able to be fulfilled")
};
// If a "root surface" has already been created, we will use Surface.Current internally to create a "subsurface"
ISurface surface = Surface.CreateNew() // returns ISurfaceBuilder
// requests in order of preference
// equivalent to .RequestSingleton<T>(...) where T is a IComponentBuilder containing a HluComponentType that we use to discriminate (e.g. HluComponentType.Graphics)
.RequestGraphics<IVkSurfaceBuilder>(
ctx => ctx.WithVersion(1, 3)
.WithSupportedInstanceExtensions<Silk.NET.Vulkan.ExtDebugUtils>() // in addition to the ones required to create the surface
.Build()
)
.RequestGraphics<IGLContextBuilder>(
ctx => ctx.WithVersion(4, 3)
.WithProfile(OpenGLProfile.Core)
.Build()
)
.Build();
// equivalent to .Singleton(HluComponentType.Graphics)
surface.Graphics() switch
{
IGLContext ctx => Console.WriteLine("Using OpenGL"),
IVkSurface surf => Console.WriteLine("Using Vulkan"),
_ => throw new("no requests were able to be fulfilled")
};