0

I'm trying to take a screenshot of a game (with window) in C++, but I couldn't get any other image than the black screen, even though I tried all the methods here.

This game is captured without any problems in the OBS game capture tool. (Note: black screen again in window capture tool)

You will say yes, OBS is an open source program, look there. Yes, I tried looking and decoding, but I couldn't find anything other than confusion.

I found something like a game capture plugin for Gst Streamer that uses OBS GameCapture. I did not understand anything here, as in OBS.

Can you help me on how to do this?

  • Some crazy stuff going on there - game-capture.c is loading a DLL into the other process and I guess that DLL probably overwrites some DirectX function to detect when the game is done rendering and uses DirectX calls to copy the pixels and send them back to OBS. You can see the function hook_direct. [Here's inject_library_obf](https://github.com/obsproject/obs-studio/blob/dde4d57d726ed6d9e244ffbac093d8ef54e29f44/plugins/win-capture/inject-library.c) – user253751 Jul 22 '22 at 19:11
  • DLL path comes from [here](https://github.com/obsproject/obs-studio/blob/dde4d57d726ed6d9e244ffbac093d8ef54e29f44/plugins/win-capture/game-capture-file-init.c#L156) and the source code of the DLL is in [this folder](https://github.com/obsproject/obs-studio/tree/dde4d57d726ed6d9e244ffbac093d8ef54e29f44/plugins/win-capture/graphics-hook) – user253751 Jul 22 '22 at 19:13
  • My advice: You might be better off figuring out how to hook up your code to the OBS plugin, and being glad someone else has done the capturing work for you! Maybe you can use gst-gamecapture, maybe you can use the OBS plugin directly, maybe you can actually run OBS and somehow get the pixel data into your software from there – user253751 Jul 22 '22 at 19:13
  • I also want to learn how to use the obs plugin in my own code. – Gürkan KARADAĞ Jul 22 '22 at 19:56
  • probably by copying a whole bunch of code from OBS - whatever the plugin needs to work. Idk anything about OBS plugins. I bet they are documented somewhere, and *that* means you can [read the documentation from the other side](https://devblogs.microsoft.com/oldnewthing/20031226-00/?p=41343) – user253751 Jul 22 '22 at 19:58

0 Answers0