A fast native control for OpenTK 4.x + 3.x on WPF.
Перейти к файлу
varon 0e657c1033
Merge pull request #45 from Svabik/patch-1
Adding stencil to the Frame Buffer:  DxGLFrameBuffer.cs
2021-03-15 01:26:53 +02:00
.paket Add FAKE build for parity with 3.0 2019-06-20 16:52:20 +02:00
src Adding stencil to the Frame Buffer: DxGLFrameBuffer.cs 2021-03-13 17:08:51 +01:00
.gitignore Cleanup before github upload 2019-06-16 15:47:22 +02:00
GLWpfControl.sln Upgrade to OpenTK 4.2.0 bindings for Wgl 2020-11-12 17:15:32 +02:00
GLWpfControl.sln.DotSettings Documentation & cleanup 2019-06-20 16:10:47 +02:00
LICENSE.md Fix LICENSE extension 2019-06-20 16:26:02 +02:00
README.md Update README.md 2020-11-25 09:28:09 +02:00
RELEASE_NOTES.md Release 4.1.0 2021-02-24 13:26:18 +02:00
build.cmd nuget package build stuff 2020-11-12 19:10:45 +02:00
build.fsx Build tweaks 2020-11-12 19:12:34 +02:00
build.sh Add FAKE build for parity with 3.0 2019-06-20 16:52:20 +02:00
paket.dependencies Fix paket deps 2020-11-21 15:57:42 +02:00
paket.lock DXInterop without SharpDX 2020-11-15 16:28:20 +01:00

README.md

GLWpfControl - A fast OpenGL Control for WPF

Nuget

A native control for WPF in OpenTK 3.x and 4.x.

Supported configurations:

  • .Net Framework for OpenTK 3.x (the 3.x series NuGet packages)
  • .Net Core for OpenTK 4.x (the 4.x series NuGet packages)

Since version 3.0.0, we're using full OpenGL/DirectX interop via OpenGL extensions - NV_DX_interop. This should run almost everywhere with AMAZING PERFORMANCE and is fully supported on Intel, AMD and Nvidia graphics.

This offers a way more clean solution than embedding GLControl and totally solves the airspace problem. As controls can be layered, nested and structured over your 3D view.

This package is intended to supercede the legacy GLControl completely, and we strongly encourage upgrading to this native WPF control instead.

Getting started:

  1. Install via NuGet

  2. In your window, include GLWpfControl.

        <Window 
            ...
            xmlns:glWpfControl="clr-namespace:OpenTK.Wpf;assembly=GLWpfControl"
            ... >    
    
  3. Add the control into a container (Grid, StackPanel, etc.) and add a handler dethod to the render event.

        <Grid>
            ...
            <glWpfControl:GLWpfControl 
                x:Name="OpenTkControl" 
                Render="OpenTkControl_OnRender"/>
            ...
        </Grid>
    
  4. In the code behind add to the constructor, after the InitializeComponents call, a call to the start method of the GLWpfControl.

    public MainWindow() {
            InitializeComponent();
            // [...]
            var settings = new GLWpfControlSettings
            {
                MajorVersion = 3,
                MinorVersion = 6
            };
            OpenTkControl.Start(settings);
    }
    
  5. You can now render in the OnRender handler.

    private void OpenTkControl_OnRender(TimeSpan delta) {
        GL.ClearColor(Color4.Blue);
        GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
    }
    

For additional examples, see MainWindow.xaml and MainWindow.xaml.cs in the example project.

Build instructions

  1. Clone repository
    $ git clone https://github.com/varon/GLWpfControl.git
    $ cd GLWpfControl
    
    or for SSH
    $ git clone git@github.com:varon/GLWpfControl.git
    $ cd GLWpfControl
    
  2. Run build.cmd or build.sh.
  3. Develop as normal in whatever IDE you like.

Planned features

DX-Hijacking rendering

It's possible to bypass the RTT that takes place in WPF D3dImage by stealing the actual D3d handle from WPF and drawing manually. This is incredibly challenging, but would offer APEX performance as zero indirection is required. Currently more of an idea than a work in progress. Contributions welcome - Drop by the Discord server if you want to give this a shot!