For the complete documentation index, see llms.txt. This page is also available as Markdown.

Silk.NET

Introduction

This page assumes you have an existing Silk.NET project. This can be an empty project or an existing game.

Adding Gum NuGet package

The easiest way to add Gum to your project is to use the NuGet package. Open your project in your preferred IDE, or add Gum through the command line.

Add the Gum.SilkNet NuGet package (https://www.nuget.org/packages/Gum.SilkNet)

Modify csproj:

<PackageReference Include="Gum.SilkNet" />

Or add through command line:

dotnet add package Gum.SilkNet

Gum.SilkNet renders through SkiaSharp and adds real Forms input (mouse, keyboard, focus) via Silk.NET.Input. Your project still owns window creation and the render loop; Gum takes an SKCanvas and an IInputContext you hand it.

Adding Source (Optional)

You can directly link your project to source instead of a NuGet package for improved debuggability, access to fixes and features before NuGet packages are published, or if you are interested in contributing.

To add source, first clone the Gum repository: https://github.com/vchelaru/Gum

If you have already added the Gum NuGet package to your project, remove it.

Add the following project to your solution:

  • <Gum Root>/Runtimes/SilkNetGum/SilkNetGum.csproj

SilkNetGum.csproj already references GumCommon itself, so you do not need to add GumCommon separately.

Next, add SilkNetGum as a project reference in your game project. Your project might look like this depending on the location of the Gum repository relative to your game project:

Initializing Gum

Gum requires SkiaSharp to render in Silk.NET, and Silk.NET.Windowing to create the window and OpenGL/ANGLE context that SkiaSharp draws into. A full Silk.NET project requires a few hundred lines of code (window creation, ANGLE backend selection, the GL debug callback, and so on), so an entire Program file is not included here — the relevant setup and initialization code is shown below.

Create the window and input context using Silk.NET.Windowing.Window.Create, then hand Gum the resulting SKCanvas and IInputContext:

Each frame, pump window events before updating and drawing Gum:

For a working project, see the Gum Silk.NET sample:

Gum running in a Silk.NET project

Last updated

Was this helpful?