c++ - How do I render a win32 window to an opengl texture?
问题描述
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)?
解决方案
有几种方法可以解决。在所有情况下,您都需要从目标窗口 ( GetDC
, ) 获取设备上下文 (DC GetDCEx
)。
然后,您可以直接读取像素(GetPixel
);或将内容 blit 到您自己的 DC ( BitBlt
) 中,然后访问该内容 (例如GetDIBits
)。
既然你想“嵌入”Internet Explorer,那么你可能意味着隐藏它的窗口;您将需要考虑如何在不可见、部分可见等的窗口上进行上述工作。还要考虑您的 Windows 版本和/或 DWM 是否可能被禁用(因此窗口的内容可能不可用)。看看PrintWindow
强制WM_PAINT
/ WM_PRINT
。
一个可以向您介绍所有这些并具有完整示例的小型 MSDN 指南是:捕获图像。
在任何情况下,您都可以通过将其他浏览器/引擎嵌入为库(例如Chromium Embedded Framework (CEF)、Qt 的 WebEngine、Electron ...)来寻求替代解决方案。
推荐阅读
- python-3.x - python补丁没有修补测试的类
- javascript - Firebase“未处理的拒绝”和“设置标头后无法设置标头”JavaScript 错误
- oracle-apex - Oracle Apex:如何翻译消息:您的会话已过期?
- symfony - Symfony 5 LDAP JumpCloud 身份验证
- java - KMP DFA 重启状态
- python-3.x - 格式化输出(python)
- python - 将csv文件转换为python中的列表字典
- reactjs - 在 redux reducer 中克隆对象
- django - 如何检查 Django 数组字段是否有数据
- javascript - 如何使 setTimeout 使用负数?