Looking for help in understanding the desktop capture architecture

gskrills

New Member
I am having a hard time understanding how OBS draws the preview window and I am looking for someone to help explain the code / architecture behind the DrawPreview function.

For the sake of discussion, lets refer to only capturing the desktop.

I am having a hard time understanding where DrawPreview gets its textures from and how it updates every frame. Are the textures created / updated every frame using BitBlt and sending directly to the DC of the curCaptureTexture surface? I only see BitBlt called during PreProcess() function and not anywhere else, how does the program update the texture on every frame? If I am on the wrong path as to how the textures are updated, please point me the right way.

Let me know if I need to explain something better. Any explanation on the general texture capture architecture for OBS would be much appreciated as sometimes the source is hard to follow.
 

gskrills

New Member
So after a day of no answers I have created a standalone program that uses BitBlt to capture the screen similar to the way of draw preview but its quite a bit worse. This makes me think the DrawPreview function doesn't rely on BitBlt and uses something else to capture the desktop. Anyone have any insight on how the DrawPreview function works?
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
I wasn't really able to spend much time on the forum because I've been busy on the new release.

The reason why Preprocess() updates the texture every frame is because it's called every frame before the actual rendering is done. It updates the texture via the BitBlt using IDXGISurface1::GetDC() to paint the HDC of the target window directly to the texture (which is more efficient than normal means when aero is enabled). It updates that texture every Preprocess() and then draws it on every Render().

This isn't the only capture method though, just one of many.

OBS::DrawPreview() just draws the preview/projector windows. It doesn't do any BitBlt there, it's just painting the current main output texture, which is already rendered with the captures beforehand.
 
Top