c++ - 最小无窗口 OpenGL 上下文初始化

标签 c++ opengl wgl

如何使用最少的代码初始化无窗口的 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/

相关文章:

windows - Windows 上的 OpenGL 1.0 和 1.1 函数指针

c++ - 如何使用Makefile使用VTK库编译项目?

c++ - Orwell Dev C++ 不适用于 C++11

c++ - 不同的Ubuntu版本二进制执行差异

java - LWJGL 中使用什么版本的 GL 有关系吗?

c - 不理解为什么 win32 api 和 OpenGL 和 wgl 的上下文创建失败

performance - wglGetCurrentContext 是否同步 GPU 和 CPU?

c++ - 如何修复 "There too many argument in this opreator"

c++ - 计算机图形行业的人们使用什么进行光线追踪?

Java OpenGL GL_TEXTURE_2D 使其他颜色变暗