Reputation: 1849
I want to be able to render a win32 control inside an OpenGL texture. In order to be able to 3d transform it. Specifically I want to embed Internet explorer to show webpages and video inside a 3D transformed window.
How do I render a win32 window to a texture in a fast enough way (I need to keep 60 fps)?
Upvotes: 4
Views: 1118
Reputation: 26066
There are a few ways you can go about it. In all cases, you will need to fetch a device context (DC) from the target window (GetDC
, GetDCEx
).
Then, you can either read the pixels directly (GetPixel
); or blit the contents into your own DC (BitBlt
) and then access that (e.g. GetDIBits
).
Since you want to "embed" Internet Explorer, and by that you probably mean keeping its window hidden; you will want to consider how to make the above work on windows that are not visible, partially visible, etc. Consider as well your Windows version and/or whether the DWM might be disabled (and therefore the content of a window may not be available). Take a look at PrintWindow
to force a WM_PAINT
/WM_PRINT
.
One small MSDN guide that can introduce you to all this and has a full example is: Capturing an Image.
In any case, you can always go for an alternative solution by embedding some other browser/engine as a library (e.g. Chromium Embedded Framework (CEF), Qt's WebEngine, Electron...).
Upvotes: 5