Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samboycoding/opentkavalonia
Helper control and library to provide OpenTK-based OpenGL rendering in Avalonia apps
https://github.com/samboycoding/opentkavalonia
avalonia opengl opentk opentk-library
Last synced: 2 months ago
JSON representation
Helper control and library to provide OpenTK-based OpenGL rendering in Avalonia apps
- Host: GitHub
- URL: https://github.com/samboycoding/opentkavalonia
- Owner: SamboyCoding
- License: mit
- Created: 2022-02-02T11:20:39.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-26T17:12:07.000Z (11 months ago)
- Last Synced: 2024-10-11T09:58:37.541Z (3 months ago)
- Topics: avalonia, opengl, opentk, opentk-library
- Language: C#
- Homepage:
- Size: 289 KB
- Stars: 42
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```c#
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure()
.UsePlatformDetect()
.With(new Win32PlatformOptions { RenderingMode = new Collection { 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](https://i.imgur.com/mAElUU9.png)