views:

82

answers:

1

I'm wondering if it's possible to draw over an opengl/direct3D surface with GDI? and if so, how might it be done?

The reason I ask is because I'm writing a simple app to draw a few things in games. Such things would all be 2D or text such as framerate info, custom crosshair, clock, etc.

I know the best way is to hook in and use whatever the renderer/game is using natively, be it opengl or direct3d, but I'm looking at GDI as AFAIK both opengl and D3D sit on device contexts which I'm hoping can be draw to with GDI.

+1  A: 

You can't usually do it directly. In theory, you can intermix GDI with OpenGL or DirectX if and only if the OpenGL/DirectX is set up to use single buffering, not double buffering. That, however, is little more than a theoretical possibility, because virtually all use of DirectX and OpenGL is with double buffering.

I'd try something else, such as drawing your data in a borderless layered window.

Jerry Coffin
I confirm the layered window method works for open-gl contexts (as I already used it for a **top-level window**), but you may get unexpected results as Windows is responsible for (re)drawing the layered window and the re-drawing of windows beneath if the layered window moves / gets updated.
DyP