0

I am trying to capture screenshots for OpenGL based games on Windows. Most answers on the internet are to make the window visible and take screenshots. But when I use OBS(Open Broadcaster Software) to broadcast my game play, it is able to streaming the game content even the game window is minimized.

Can anyone help me understand how they do that?

Thanks!

1 Answers1

2

The OpenGL API provides a way to draw to an internal "Frame buffer object" (FBO) which can be blitted to the window. If OBS doesn't provide a way to access that FBO, then your only solution is to make the window visible. Well, you could also hack the broadcast and try to figure out about those bytes...

EDIT:

When the OP clarified his question I was curious. So I dug into OBS code and found that for Windows it uses .dll injection and process hook.

I also found that it hooks "swap buffers" and get the current Frame Buffer with glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING...), copies it and then let Windows continues its job.

Please, notice that I can be wrong. But what I found looks good to me.

Ripi2
  • 7,031
  • 1
  • 17
  • 33
  • Thanks but I don't quite understand what you mean... OBS doesn't do any hacking or dll injection. I was trying to do the same thing as OBS does, not trying to use OBS features. And I don't own that openGL game. How do I access the FBO from my own Windows app? – Ramie Jordan Mar 11 '17 at 20:28
  • 1
    OK. You have an app, using OpenGL or not. And want to capture screenshots from another app which does use OpenGL, But you know nothing on that app, right?. Your only feasible way is ask Windows to get it for you. But Windows only knows of windows, not FBOs. – Ripi2 Mar 11 '17 at 20:34
  • Correct. So how does OBS do it? – Ramie Jordan Mar 11 '17 at 20:53
  • I'don't know. But it's open source, you can browse its files. Perhaps it uses IPC pipes. – Ripi2 Mar 11 '17 at 21:11
  • 1
    @RamieJordan: What makes you think that OBS doesn't do any injection or hooking? It does this [_a lot_](https://github.com/jp9000/obs-studio/blob/master/plugins/win-capture/inject-library.c). – derhass Mar 12 '17 at 16:27
  • I was curious, so I explored a bit. Yes OBS **does** injection **and** hooking on Windows OS. – Ripi2 Mar 12 '17 at 16:53