dotnet / Silk.NET

The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX bindings library your mother warned you about.
https://dotnet.github.io/Silk.NET
MIT License
3.88k stars 378 forks source link

Interactive Silk.NET Windowing in Polyglot Notebooks #2208

Open ibrahim324 opened 1 month ago

ibrahim324 commented 1 month ago

Summary

I wanted to try out Silk.NET without a console application. I like to use Polyglot Notebooks / .NET Interactive for quick iteration and prototyping. I got a System.PlatformNotSupportedException instead (Silk.NET works in Console Apps, however).

Steps to reproduce

Requirements: VS Code with the Polyglot Notebooks Extension installed

My script is the following, inside a Polyglot Notebook Cell:

#r "nuget: Silk.NET"
using Silk.NET.Windowing;

var window = 
    Window.Create(
        WindowOptions.Default
    );
window.Run();

Again, the same code snippet would work in a Console App.

I am sure this can be resolved by just referencing the right dependency, I haven't yet found out which one or where to locate it.

full error message: Error: System.PlatformNotSupportedException: Couldn't find a suitable window platform. (GlfwPlatform - not applicable, SdlPlatform - not applicable) https://dotnet.github.io/Silk.NET/docs/hlu/troubleshooting.html at Silk.NET.Windowing.Window.Create(WindowOptions options) at Submission#6.<>d__0.MoveNext() --- End of stack trace from previous location --- at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray1 precedingExecutors, Func2 currentExecutor, StrongBox1 exceptionHolderOpt, Func2 catchExceptionOpt, CancellationToken cancellationToken)