Skip to content

DirectorRen-TV/GLWpfControl

 
 

Repository files navigation

GLWpfControl

Nuget

A native control for WPF in OpenTK.

(Probably) faster than GLControl, and solves the airspace problem.

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

Hardware rendering using NV_DX_interop:

Currently a work in progress. Contributions welcome!

About

A native control for OpenTK 3.0 on WPF.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 75.1%
  • F# 20.7%
  • Shell 2.2%
  • Batchfile 2.0%