如何使用最少的代码初始化无窗口的 OpenGL 上下文?
我读过 here您可以使用 wglCreateContextAttribsARB
来创建无窗口上下文,但是它没有解释如何做?
最佳答案
来自链接:
Creating a context without a window, for off-screen rendering. This may not actually work.
第二句话很重要。来自WGL_ARB_create_context specification :
4) Should there be a way to make a context current without binding it to a window system drawable at the same time?
RESOLVED: Yes, but only in OpenGL 3.0 and later. This results in a context with an invalid default framebuffer, the meaning of which is defined in the OpenGL 3.0 specification.
NOTE: Apparently on Windows, opengl32.dll makes use of the drawable argument to identify the namespace of the driver, so we may not be able to work around it.
规范不允许您创建没有窗口的上下文,因为它需要您在设备上下文中设置的像素格式。但是您理论上可以在使上下文成为当前上下文时为 HDC 传递 NULL,这会导致 OpenGL 没有默认的帧缓冲区。
但是,如上所述,这实际上可能行不通。您可以尝试看看会发生什么,但我不会抱太大希望。
关于c++ - 最小无窗口 OpenGL 上下文初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7062804/