Skip to content

Helper control and library to provide OpenTK-based OpenGL rendering in Avalonia apps

License

Notifications You must be signed in to change notification settings

SamboyCoding/OpenTKAvalonia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Helper control and library to provide OpenTK-based OpenGL rendering in Avalonia apps

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages