2

I need to draw an overlay consisting of lines and text on top of another application. The application in question is a 3D outside world viewpoint, and the overlay is a head up display.

I don't have access to any type of callback from the outside world application to execute draw code in it's draw loop.

Drawing directly over the application's window will result in flickering as the draw loops will not be synchronized, so to me that doesn't seem like an option.

One method I can think of is to capture the outside world application's pixels and stream them into my application, so I can draw the overlay on top in the same draw loop, but that seems very inefficient.

Is there an efficient way to draw over the outside world application without flickering?

Is it possible to draw something over the final graphics card output / at the monitor's refresh rate?

P.s. It doesn't have to be OpenGL, but the HUD is already written in OpenGL so it would make it easier.

genpfault
  • 51,148
  • 11
  • 85
  • 139
parrowdice
  • 1,902
  • 15
  • 24
  • Just asking, but why would you want to render on top of another application, why not render both the 3D world and then the HUD in the same application and in the same render loop? – vallentin Oct 29 '13 at 12:01
  • You want to look at the way applications like steam, teamspeak, mumble etc. do it. I believe they hijack some of the GL calls to figure out when a swap buffers occurs and inject their own calls. Again, guessing, but this involves saving the memory location of a real function call before overwriting it with your own. Then your own function is a proxy and can do what ever it wants when the target application tries to call the real function. – jozxyqk Oct 29 '13 at 12:07
  • We used to, but the division of the company that writes the 3D world code dropped support for allowing us to draw in the same app. So now it's a standalone app, but it still needs the HUD overlay for what we use it for. Go figure... – parrowdice Oct 29 '13 at 12:10
  • @jozxyqk: Genius. I wrote a DLL not too long ago that hijacks some WinAPI calls for a similar situation. I don't know why I didn't think of that technique for this. Thanks, that should do the trick! Make that an answer and I'll accept it. – parrowdice Oct 29 '13 at 13:02

1 Answers1

1

To repeat what I said in the comments, I've come across quite a few apps that hijack the 3D api calls and inject their own code to draw stuff right at the end of each frame - steam, teamspeak, mumble. Since it's in the same application there's no flickering and you can draw directly, rather than copying the result somewhere and compositing. I've never done it before and probably won't do a good job explaining it.

A relted question is here: Overlaying on a 3D fullscreen application

Community
  • 1
  • 1
jozxyqk
  • 16,424
  • 12
  • 91
  • 180