1
votes

We're developing Windows desktop app with full-screen OpenGL graphics. Now we want to display a bunch of controls over the OpenGL (arrows, buttons, etc.) It turns out it is very difficult to do that.

The majority of tutorials suggest using WindowsFormsHost for OpenGL rendering, and we did so: http://www.codeproject.com/Articles/23736/Creating-OpenGL-Windows-in-WPF

Unfortunately now we cannot draw WPF controls over WindowsFormsHost, there's a lot of discussion about this all over the internet too: WindowsFormsHost is always the most top from WPF element Render WPF control on top of WindowsFormsHost

There are some hacks that can work around this, but they all seem very dirty. Is there a proper way to draw OpenGL directly in WPF without messing with Windows Forms? (I just have no idea why you cannot have this in WPF directly).

In short: is there a known solution for drawing UI over OpenGL in WPF applications?

1
How about rendering your control to a bitmap target and then updating a GL texture from that?GlGuru
You mean render all my buttons, labels etc. to bitmaps and then render them in OpenGL with the rest of my graphics? That's what I usually call "dirty hacks" :) If there is a way to avoid this I'd be happy.Aleksei Petrenko
Dwayne Need managed to resolve this problem. I haven't looked at his solution though. Also, what we do is to simply popup a borderless WPF Window above the GL content, and track it's position so the window's location is always "on top of" the GL content.Federico Berasategui
It's not a hack. This is a fairly standard way of displaying stuff on graphics windows. This is very similar to how it's actually done as well.GlGuru
Why not to use Qt SDK ?Michael IV

1 Answers

1
votes

Create a wpf window. Render your opengl viewport in background. Get the Snapshot of the opengl viewport and display the image in the WPF. Transfer all UI Events on the WPF Image to the opengl viewport.