Table of Contents

DrawnUI for OpenTK

Run DrawnUI canvases inside an OpenTK GameWindow on Windows and Linux.

When to use

Use case Recommendation
Create cross-platform DrawnUI app/game, same code will run in browser etc DrawnUiWindow -> Canvas
Add rich UIs overlay to your existing app scene CanvasHost-> Canvas

Install

DrawnUi.OpenTk is currently distributed as a project reference:

dotnet add package DrawnUi.OpenTk

Initialization

Call Super.UseDrawnUi().Build() once before creating windows or canvases:

Super.UseDrawnUi()
    .ConfigureFonts(fonts =>
    {
        fonts.AddFont("fonts/Orbitron-Regular.ttf", "FontGame");
    })
    .Build();

Font files must be present next to the executable at runtime. Mark them as content with CopyToOutputDirectory:

<ItemGroup>
  <Content Include="fonts\**">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </Content>
</ItemGroup>

Samples

See OpenTK Samples for a fuller walkthrough of the sample projects and which one to start with.