Home > Net >  Capture OpenGL output of child process?
Capture OpenGL output of child process?

Time:03-02

Is there any possibility of capturing opengl output of child process?

Child should not have a different window. Output should be captured and displayed by parent instead.

I know that i can create a layer that my child could use to create opengl callbacks in my parent application. And send data by socket or pipe.

Edit: I write main and child applications.

CodePudding user response:

OK, here's a rundown of how I think this can be done. This is totally untested, so YMMV.

  1. Create your window in the parent process. According to this page, you need to create it with the CS_OWNDC style, which means it has the same HDC permanently associated with it.

  2. Launch your child process. You can pass the HWND to it as a command line parameter, converted to hex-ascii, say, or you can devise some other method.

  3. In the child process, call GetDC to retrieve the HDC of the parent's window and pass it to wglCreateContext (I imagine you know all about doing that sort of thing).

  4. In the child process, draw, draw, draw.

  5. Before exiting the child process, make sure you call ReleaseDC to free up any resources allocated by GetDC.

This ought to work. I know that Chrome uses a separate process for each browser tab, for example (so that if the code rendering into any particular tab should crash, it affects that tab only).


Also, if you're thinking of jumping through all these hoops just because you want to reload some (different) DLLs, maybe you're looking for LoadLibrary and GetProcAddress instead. Hmmm, maybe I didn't need to write all that :)

  • Related