问题描述
我正在尝试找出为离屏渲染创建无窗口 OpenGL 程序的最简单方法是什么.
I'm trying to figure out what is the simplest way to create a windowless OpenGL program for offscreen rendering.
目前我使用这个,到目前为止它工作正常:(为了清楚起见,这里删除了错误检查)
Currently I use this, and it works fine so far: (error checks removed here for clarity)
BOOL create_opengl_context(){
GLuint PixelFormat;
static PIXELFORMATDESCRIPTOR pfd;
hDC = GetDC(NULL);
PixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, PixelFormat, &pfd);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
}
这样使用安全吗?创建无窗口 OpenGL 程序的标准"方法是什么?
Is this safe to use? What is the "standard" way to create a windowless OpenGL program?
我使用 FBO 进行离屏渲染.
I'm using FBO for the offscreen rendering.
推荐答案
纯无窗口 OpenGL 的旧方法是使用 PBuffer.在 Windows 上,这需要使用常规窗口创建中间 OpenGL 上下文以获得所需的扩展函数指针.在 X11/GLX 上,它可以毫不费力地工作.
The old method for purely windowless OpenGL is using a PBuffer. On Windows this requires the creation of a intermediate OpenGL context using a regular window to obtain the required extension function pointers. On X11/GLX it works without further ado.
实现离屏渲染的现代方法是使用常规但隐藏的窗口,其中包含常用的 OpenGL 上下文和 FBO 作为渲染目标.
The modern way to implement off-screen rendering is using a regular, but hidden window with the usual OpenGL context and a FBO as render target.
最前沿但支持度不高的方法(某些嵌入式设备除外)是使用 EGL 创建可绘制对象.
The bleeding edge, and yet not very well supported method (except on certain embedded devices) is using EGL for drawable creation.
这篇关于在没有窗口的情况下创建 OpenGL 上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)