Getting Handle of DirectX Output inside a WPF Window - wpf

I am hoping this makes sense.
I am developing an application which will be a plugin inside of an existing application. The application has DirectX output that is placed in a WPF container/window.
I would like to get a "handle" on that DirectX output such that I can change basic properties of that Output such as switching to a stereoscopic 3d display, switching said output to full screen, etc.
I am not trying to manipulate the objects/information/etc. of that output, just how it is presented.
Any direction I can head in?
Thank you.

Related

Using PIX with a WPF app

I have a WPF application that uses an HwndHost to display DirectX 9 content. I'm trying to use the PIX for Windows graphics profiler (which comes bundled with the DirectX SDK) to see render states and debug shaders in this DirectX window.
The problem I'm running into is that when I try to do a single-frame capture by pressing F12 in PIX, I sometimes don't get all the draw information for an entire frame. Also, when I try clicking on a DrawPrimitive call in PIX I get an error message saying "A call that previously succeeded failed during playback."
I think the reason for these problems is that WPF also uses DirectX to render all the WPF widgets. It does this on the WPF render thread which is hidden from the user in WPF. It looks like PIX uses calls to IDirect3DDevice9::Present to determine when a frame has ended. The WPF render thread is making calls to IDirect3DDevice9::Present in the middle of a frame of my render, causing PIX to get confused and truncate that frame (and errors when I try to look at DrawPrimitive calls).
Here's a little more information about how my application is set up: I have a WPF application with an HwndHost inside the main window that I use to show some 3D content. In the HwndHost::BuildWindowCore function, I create a window using CreateWindowEx which gives me an hwnd. I then initialize the DirectX 9 device using this hwnd. I then return the hwnd to the HwndHost. I hook up to the CompositionTarget.Render event which calls my unmanaged render function to draw everything in the scene.
I've tried getting this working using the D3DImage control to display my DirectX surface, but I run into the same problem.
It seems to me like the only way to solve this problem is to make sure that the WPF render thread has completely finished before doing a frame capture in PIX. That way, PIX won't be thrown off by any WPF DirectX calls. However, I don't see that there is any way to determine that WPF has finished rendering everything. There is a good post here that explains how to use the Dispatcher.Invoke function to determine when a single WPF element has completed rendering, but I need to know when everything has finished rendering.
I'm wondering if anybody has successfully set up a WPF application with their own DirectX window and was able to get PIX to work properly. Any help would be appreciated.

WPF and DirectX - Game Overlay

Greetings
I've read WPF utilizes DirectX so I'm wondering if it is possible to create a Game Overlay with WPF. I have tried with Winforms or WPF by itself and the transparent forms or windows always cause problems for streaming software thus I'm wondering is it possible to do the following:
Create a WPF application which shows a Window on the desktop with all the options needed for the overlay. Once all the options is filled in you can press Update and the Overlay is created in the game with all the information on it. The WPF app itself won't be visible on the stream. This means all the viewers will not have any trouble with it when the broadcaster changes settings.
More about the overlay
The overlay will be a scoreboard so it will need a set amount of info. For example:
So to sum up my question(s)
Can I make a WPF application which
dynamically creates a DirectX overlay
ingame?
Since it needs to work in DirectX9,
is this project possible to make by a
single dev (me) which has little to
no exp with DirectX?
If it is possible, where should I
start?
Thanks in advance for all your possible insights and replies!
What you want would be possible using D3DImage. It allows you to host any Direct3D content within WPF and also allows you to have overlay with transparency. Here is a simple example.
From your comment above, it sounds like your really trying to inject your overlay (at least from the user's perspective) into Starcraft II. You would almost have to host a copy of the directx buffer.
Also, besides WPF, you might want to look at XNA.

Hooking into Forms redrawing

I'm looking for a way to overlay the graphical output of a third-party application with some lines, arcs etc. The applications accepts a handle of a window in which it will then display its output.
Using VC++ I put together a Windows Forms app in Visual Studio that draws (non-static) stuff in the onPaint-method of a form. Passing this form's handle to the other app, of course, overwrites my graphics stuff every time the other app redraws.
Can I somehow hook into this redrawing process to add my graphics after the other app redraws? Overlaying the form with a transparent panel onto which I draw could be an alternative. But real transparency for controls seem to be a problem of its own in Windows ...
You can't do this easily without getting notifications from the app. Which, if it doesn't provide them, would require setting a global hook with SetWindowsHookEx() so you can see the WM_ERASEBKGND and WM_PAINT messages. That's hard to get right, you cannot write such a hook in managed code. Since it requires injecting a DLL into the target process.
The only other option is that you put a transparent overlay on top of your form. Another form that has its TransparencyKey property set. The basic code you need to get that right is available in my answer in this thread. You just need to tweak it so it is permanent.

Drawing directly to the screen via GTK or GDK

I am working on a demo application for a library me and two colleagues are writing to allow GNOME applications that run audio events though libCanberra to allow users to select visual events to replace them. This is an accessibility-minded effort to help both visually and aurally impaired users gain the benefits of audio alerts and such.
For our first demo we're simply trying to make the entire screen flash with a color when a button is pressed in our simple GTK sample app. I've been looking at the GTK documentation and all drawing that I've seen has had to do with drawing directly to a window or other widget. I want to control the entire screen's hue. Would this be a GDK thing? Am I completely off base?
Any links/help will be much appreciated! Thanks.
PS: This is being written in C, though functions should be the same between languages with proper bindings, I assume.
You cannot. Your application has access only to its own window, and does not (and should not) know anything about other windows, or the screen. The "screen" is managed by whatever back-end GTK uses (X? Win32? DirectFB?).
That said, you could try to create a "full-screen" window that covers the entire screen area. That is the way full-screen apps are implemented in most windowing systems.
GTK doesn't have such option AFAIK, you probably want to use the backend: Xlib (or Xcb) for that.

Morae Screen Text search not capturing screen text in WPF app

When I try to use Morae Manager 3.0 to run a Screen Text search on a recording of our prototype (coded in WPF, .NET version 3.5 SP1), the only things that come up are the window titles. We are using Windows XP.
Even when I search for something that is editable, like text typed into a text box, it does not come up.
Screen text for things outside the prototype (e.g. desktop icons) still comes up perfectly.
I contacted TechSmith support on two separate occassions and both times the reply I got was it must be an issue with our technology, since the screen text search does work for other things, and that the support people are not developers and thus do not know what might be causing this.
Does anyone know:
what precisely might be causing this -- e.g. does WPF's rendering engine bypass some sort of Windows layer where Morae looks for text (please forgive me for any errors in terminology)
if there is anything I can tweak in the prototype to fix it
how I can get through to someone at TechSmith who knows the answers to 1. and 2.
P.S. Morae is a wonderful product and we've usually had great support from TechSmith. We are only having problems with this one little thing, and one can hardly blame Morae for not being compatible with something as new as WPF.
I have no idea what Morae is or how it works, but one big difference between WPF and for example WinForms is the following, copied from here:
When you create a WPF Window, WPF
creates a top-level HWND, and uses an
HwndSource to put the Window and its
WPF content inside the HWND. The rest
of your WPF content in the application
shares that singular HWND.
If Morae depends on HWNDs to find texts on the screen, this could explain why it can not find the text box. In contrast, i believe in WinForms every control (button, textbox) has its own HWND.

Resources