I’ve been out of the .NET loop for a very long time. I would never have thought that it was so easy to get a .NET project up and running on Linux. But, I guess a decade of embracing Open Source at Microsoft changes things. Here are the steps I took to get an OpenGL window up and running on Ubuntu using .NET Core, VSCode, and OpenTK.
Open up the command line and create a directory for your project, then
cd into it.
Register the apt repositories listed on this website.
Install .NET Core:
sudo apt install dotnet-runtime-7.0 dotnet-sdk-7.0
Once installed, set up a solution:
dotnet new sln
Followed by the main executable project:
dotnet new console -o game --use-program-main
I named the project
game, but call it whatever you want. While still in the solution directory, add the new project to the solution:
dotnet sln add game
cd into the game directory and add the OpenTK package:
dotnet add package OpenTK
That’s it. Follow the tutorial at The OpenTK site, and you should be up and running. If you install the official C# extension, you should be able to use the same keybindings from Visual Studio to run and debug your program.
I can’t think of an easier way to create a cross-platform OpenGL executable than this. This setup is great for little demos and trivial graphical apps that don’t need to be blazing fast. Not to mention being able to do your primary development cycles in Linux, with its dev-centric *nixy tools, and switching to Windows once the program is completed and ready for distribution. It’s a far cry from the burning hoops I had to jump through a decade ago with Mono and a lack of tools outside of Windows.