jayhf / OpenTkControl

A faster way to use OpenTk in WPF without Forms dependencies
MIT License
30 stars 6 forks source link
csharp opengl opentk wpf

OpenTkControl

This project aims to make it possible to achieve better performance with OpenTk in WPF and it achieves this by copying the data less than existing solutions, such as the examples here: https://github.com/freakinpenguin/OpenTK-WPF. It also allows for all of the rendering to be performed off of the UI thread to improve responsiveness and provides a variety of settings that can be used to further improve performance.

Getting Started

  1. Install the nuget package available here: https://www.nuget.org/packages/JayFleischer.OpenTkControl
  2. Add either a ThreadOpenTkControl or UiOpenTkControl to a WPF window
  3. Subscribe to the GlRender event and draw something!

Class Overview

This library provides two different implementations:

UiOpenTkControl - Performs all rendering on the UI thread. In general, this version will perform worse, even if it's the only thing drawn on the screen and therefore I recomment using ThreadOpenTkControl, unless you really need rendering to occur on the UI thread for some reason

ThreadOpenTkControl - Performs all OpenGL rendering on a dedicated update thread to improve performance.

Features

Bugs

Please report any issues on GitHub. I also welcome pull requests with bug fixes and improvements.