最小无窗口 OpenGL 上下文初始化
如何使用最少量的代码初始化无窗口 OpenGL 上下文?
我在此处读到您可以使用wglCreateContextAttribsARB
来创建无窗口上下文,但它没有解释如何?
How can I initialize a windowless OpenGL context with the minimal amount of code?
I've read here that you can use wglCreateContextAttribsARB
to create windowless context, however it doesn't explain how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从链接:
第二句话很重要。来自 WGL_ARB_create_context 规范:
该规范不允许您创建没有窗口的上下文,因为它需要您在设备上下文中设置的像素格式。但是理论上可以在使上下文成为当前上下文时为 HDC 传递 NULL,这会导致 OpenGL 没有默认的帧缓冲区。
但是,如上所述,这实际上可能行不通。你可以尝试看看会发生什么,但我不会抱太大希望。
From the link:
That second sentence is important. From the WGL_ARB_create_context specification:
The specification doesn't allow you to create a context without a window, since it needs the pixel format that you set into the device context. But you theoretically can pass NULL for the HDC when making the context current, which causes OpenGL to not have a default framebuffer.
But, as noted above, this may not actually work. You can try it to see what happens, but I wouldn't get my hopes up.
实现离屏渲染的通常方法是:
另一种选择是使用 Framebuffer 对象( FBO),您可以通过它创建常规 OpenGL 窗口,但不是渲染到主帧缓冲区,而是渲染到帧缓冲区对象缓冲区,并且 OpenGL 窗口变得不可见。
The usual way to implement offscreen rendering is:
Another option is using Framebuffer Objects (FBO) by which you create a regular OpenGL window, but instead of rendering to the main framebuffer you render to Framebuffer Object buffers, with the OpenGL window being made invisible.
另一件事:
但是ReleaseDC不能用它。DeleteDC可以。
another stuff:
But
ReleaseDC
not work with it.DeleteDC does.