在 X11 上设置 OpenGL [英] Setup OpenGL on X11

查看:91
本文介绍了在 X11 上设置 OpenGL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于 X11 窗口的 Window 标识符.我没有设置这个窗口,我只能得到它的 id(我想,visual id).如何为此窗口设置 OpenGL 上下文?

I have an Window identifier for X11 Window. I didn't setup this window, I just can get its id (and I suppose, visual id). How can I setup OpenGL context for this window?

特别是,我想使用glXMakeCurrent,但是这个函数接收DisplayGLXContext 对象.我可以使用 glXCreateContext(display, vi, 0, GL_TRUE); 创建上下文,但我再次需要 DisplayXVisualInfo 对象.

In particular, I want to use glXMakeCurrent, but this function receives Display and GLXContext objects. I can create context using glXCreateContext(display, vi, 0, GL_TRUE); but again I need in Display and XVisualInfo objects.

推荐答案

我的一个代码示例(基于 FTB/fungus 的示例)介绍了在 X11 窗口上设置 OpenGL 上下文,显着的区别在于是在常规 Visual 上使用 FBConfig.

Setting up a OpenGL context on a X11 window is covered by one of my code examples (based upon an example by FTB/fungus), with the notable difference that is uses FBConfig over a regular Visual.

https://github.com/datenwolf/codesamples/blob/master/samples/OpenGL/x11argb_opengl/x11argb_opengl.c

你只得到一个窗口,而不是一个显示是一个问题.您不能只是假设窗口在默认显示上,因此无论您从何处获得该窗口,它也必须 为您提供相应的显示连接.在 X11 中,仅仅传递 Window ID 是 API 设计的失败.

That you're given only a Window, but not a Display is a problem. You can't just go around assume the window being on the default display, so whereever you get that Window from, it also must give you the corresponding Display connection as well. Just passing around Window IDs is a failure in API design, when it comes to X11.

这篇关于在 X11 上设置 OpenGL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆