在窗口的特定区域创建 GLX 上下文
我想在窗口内使用 GLX 创建 OpenGL 上下文。但是,我不希望它跨越整个窗口区域。相反,它应该只覆盖一个次区域。
例如,GLUT 为这种行为提供了一个函数。 GTK+ 或 QT 等主要工具包也提供 GL 小部件,它们只是 X 窗口的子区域。然而我需要做低水平的工作。
glXMakeCurrent() 接受 X Drawable 标识符。是否可以将 Drawable 定义为窗口的子区域?或者还有其他方法将上下文绑定到窗口区域吗?
编辑:添加了很棒的赏金!
I would like to create an OpenGL context with GLX inside a window. However, I do not want it to span over the whole window region. Instead, it should only cover a subregion.
For example, GLUT provides a function for this behaviour. Also major toolkits like GTK+ or QT provide GL widgets, which are only subregions of X windows. However I need to work low-level.
glXMakeCurrent() accepts a X Drawable identifier. Is it possible to define a Drawable as being a subregion of a window? Or are there other ways to bind the context to a window region?
Edit: Added awesome bounty!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只能 glXMakeCurrent() 一个 X Drawable,而不是它的一部分,但是您的解决方案很简单:停止将 X 窗口视为您的应用程序。每个 X 应用程序通常由 10 个或 100 个 X 窗口组成。在您想要的区域创建一个子窗口并绘制到其中。
或者,您可以创建一个像素图,渲染到其中,然后复制到窗口的某个区域,但这会比较慢。
You can only glXMakeCurrent() an X Drawable, not a subsection of it, however your solution is simple: stop thinking about an X window as if it is your application. Each X application is typically made up of 10's or 100's of X windows. Create a child window in the area you want and draw into it.
Alternately, you could create a pixmap, render into it and then copy to an area of a window, but that would be slower.
我在 BSD 手册页中找到了这条有用的信息:
所以我假设流行工具包中的 GL 小部件实际上也充当不同的(子)窗口。有趣的是,这对窗口管理器是透明的,因此对用户也是透明的。
I found this helpful piece of information in a BSD manpage:
So I assume that GL widgets in popular toolkits also act in fact as a distinct (sub)window. The interesting part is that this is transparent to the window manager, and therefore the user.