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

Minimal Windowless OpenGL Context Initialization(最小无窗口 OpenGL 上下文初始化)
本文介绍了最小无窗口 OpenGL 上下文初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

如何用最少的代码初始化一个无窗口的 OpenGL 上下文?

How can I initialize a windowless OpenGL context with the minimal amount of code?

我读过这里,您可以使用wglCreateContextAttribsARB创建无窗口上下文,但它没有解释如何?

I've read here that you can use wglCreateContextAttribsARB to create windowless context, however it doesn't explain how?

推荐答案

来自链接:

创建一个没有窗口的上下文,用于离屏渲染.这实际上可能行不通.

Creating a context without a window, for off-screen rendering. This may not actually work.

第二句话很重要.来自 WGL_ARB_create_context 规范:

That second sentence is important. From the WGL_ARB_create_context specification:

4) 是否应该有一种方法可以在不绑定的情况下使上下文成为当前上下文它可以同时绘制到一个窗口系统?

4) Should there be a way to make a context current without binding it to a window system drawable at the same time?

已解决:是的,但仅限于 OpenGL 3.0 及更高版本.这导致一个具有无效默认帧缓冲区的上下文,其含义是在 OpenGL 3.0 规范中定义.

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.

注意:显然在 Windows 上,opengl32.dll 使用了 drawable参数来标识驱动程序的命名空间,所以我们可能不会能够解决它.

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 没有默认帧缓冲区.

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.

这篇关于最小无窗口 OpenGL 上下文初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

OpenGL transforming objects with multiple rotations of Different axis(OpenGL 变换不同轴多次旋转的对象)
GLFW first responder error(GLFW 第一响应者错误)
SOIL not linking correctly(SOIL 连接不正确)
Core profile vs version string? Only getting GLSL 1.3/OGL 3.0 in mesa 10.0.1(核心配置文件与版本字符串?在 mesa 10.0.1 中只获得 GLSL 1.3/OGL 3.0)
What is the range of OpenGL texture ID?(OpenGL 纹理 ID 的范围是多少?)
How taxing are OpenGL glDrawElements() calls compared to basic logic code?(与基本逻辑代码相比,OpenGL glDrawElements() 调用的繁重程度如何?)