|Project:||The Open Toolkit library|
Right now, it is possible to create an OpenTK.GLControl and host it in a WPF using a WindowsFormsHost.
The question is: can we create an OpenGL context directly on a WPF window and do away with the host control?
The attached solution creates a WPF solution, obtains its handle and creates a GraphicsContext. This works without errors, however OpenGL rendering results in artifacts. The msdn entry for the OnRender method, notes that:
The rendering instructions for this element are not used directly when this method is invoked, and are instead preserved for later asynchronous use by layout and drawing.
This explains why the rendering artifacts appear: OpenGL tries to render to the window directly and does not participate into WPF composition.
One *could* use offscreen OpenGL rendering, perform a readback and present the results into the WPF window, but this is inefficient. It would be nice to find a better solution or confirm that it cannot be done.