I want to write a short of chat client that display the messages in-game (OpenGL/DirectX), but I really don't know how to handle this.

It is easy to write my client in my graphic context... but what about the other game-apps context?.

My primary target is Windows and Win 7, then mac, then Linux. But I would be happy to solve it for Windows.

By the way, it should try to be the most compatible with different DX versions and OGL versions.


2 Answers 2


One of the most common ways to render into another application's GL or D3D rendering context is to hook the creation of the context or device objects in that application's process. This will let you gain access to the returned context or device pointer. You can then hook the actual rendering invocation methods (for example, Present() in D3D) and inject your own rendering before or after the rendering of the hooked process.

Google can provide a wealth of links on hooking/detouring/patching GL or D3D DLLs to enable this. For example:

Because you are patching the rendering API DLLs (essentially), you will have to do this different for D3D and OpenGL -- there is no way to do it in a uniform fashion for both APIs. You will probably need to write different code for Mac and Windows machines as well, even when utilizing OpenGL.

D3D9 on Windows supports hardware overlay surfaces in some scenarios, which can be much easier to use (I believe this is what some voice chat clients like Ventrilo use) if they do what you want. I don't know if OpenGL provides something similar -- it would likely be through an extension.


For the most part, it's not possible to write to a graphics context that isn't your own computer (there's... sort of ways to do this, but they're all really silly, and technically still not performing the rendering on the remote PC). In terms of your specific question, making a chat client, you should just send the text of the message (along with other useful information, like who said what and when) to the other clients (ideally, you'd send it to a server, which would pass it on to the clients, and possible perform some other actions, but...). Then, each client would handle rendering the text to their own graphics context. This solves the problem of dealing with multiple OSes and multiple rendering systems, too (again, sort of...)

TL;DL, just send the text, don't try to render something on another computer.

  • 2
    \$\begingroup\$ I think what tyoc213 wants to know here is how to do something like steam overlay, fraps, etc. i.e. render something on top of the game so that he can display all text from the chat in-game \$\endgroup\$
    – Durza007
    Oct 3, 2011 at 15:30
  • \$\begingroup\$ Yes, more like steam or other clients that show its interface over a game. Thx anyway. \$\endgroup\$
    – tyoc213
    Oct 3, 2011 at 16:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .