Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 1.29 KB

README.md

File metadata and controls

26 lines (19 loc) · 1.29 KB

OpenTKAvalonia

OpenTKAvalonia is a simple wrapper to provide OpenTK OpenGL bindings for Avalonia, and a control which handles some of the heavy lifting for you.

This includes setting up the OpenGL bindings, setting up the aspect ratio so anything you draw looks as expected, providing events for Initialization, Teardown, and Render, and providing a KeyboardState API for detecting keyboard input.

The library is somewhat work-in-progress but it currently functions for simple applications, and there is a sample included.

Note that, in order for events to be called on Windows, Avalonia must be able to load the OpenGL bindings, which requires switching the default rendering mode, like so:

public static AppBuilder BuildAvaloniaApp()
            => AppBuilder.Configure<App>()
                .UsePlatformDetect()
                .With(new Win32PlatformOptions { RenderingMode = new Collection<Win32RenderingMode> { Win32RenderingMode.Wgl } }) //This line is the important one.
                .LogToTrace();

Without this, your control simply will never receive any of the OpenTK events (Initialization, Teardown, and Render).

The library itself is netstandard2.1, because that's what OpenTK requires, and the sample is net7.0.

Demonstration

Demonstration image