duplicatesrenderingvirtual-realitybitblt

Win32 Duplicate, mirror, copy or draw window contents twice, with perfect frame synchronization. For stereo left-eye right-eye rendering


I have written a Win32 C++ program.

I would like to duplicate the visual content of the left window every frame, so it appears at another location on the screen. (One rectangle on the left side of the screen, and an identical rectangle on the right side of the screen.)

This is for stereo rendering, where the left rectangle is seen in the user's left eye, and the right rectangle in the right eye.

Text

The two rectangles must be "frame synced", meaning that they must show the same frame at all times. Or to put it another way, if the right eye is behind the left by "one draw call", then the viewer becomes ill.

NOTE: I have the source code to both windows, because I created them. (Both windows reside within the same exe at the moment.)

What I have tried:

Potential Solutions:

Any help would be greatly appreciated!


Solution

  • I don’t know if you still need an answer, but I don’t think you can do it better than using the DWM Thumbnails API [1]. You basically do an association of a region on your window <-> a region of a foreign window, and then each time the windows are composed and presented on the screen, the specified rectangle of the foreign window will be painted on the specified rectangle of your window. DWM will do scaling if necessary and you can also specify a transparency level. This is the most efficient way to do it, as the compositor does all the heavy lifting, so it is at the lowest level you could go without writing kernel mode code (custom drivers etc). You can’t draw on top, and won’t “see” the foreign window data on your window if you BitBlt it for example, as the image is not actually drawn on your window, but overlaid on top when the final image of your window is composed and presented to the user by the window manager. But for most purposes, it works really well.

    [1] https://learn.microsoft.com/en-us/windows/win32/dwm/thumbnail-ovw