在窗口的特定区域创建 GLX 上下文

发布于 2024-08-02 11:58:27 字数 382 浏览 5 评论 0原文

我想在窗口内使用 GLX 创建 OpenGL 上下文。但是,我不希望它跨越整个窗口区域。相反,它应该只覆盖一个次区域。

例如,GLUT 为这种行为提供了一个函数。 GTK+ 或 QT 等主要工具包也提供 GL 小部件,它们只是 X 窗口的子区域。然而我需要做低水平的工作。

glXMakeCurrent() 接受 X Drawable 标识符。是否可以将 Drawable 定义为窗口的子区域?或者还有其他方法将上下文绑定到窗口区域吗?

GLX 参考(蓝皮书)

编辑:添加了很棒的赏金!

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?

GLX reference (Blue Book)

Edit: Added awesome bounty!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人生戏 2024-08-09 11:58:27

您只能 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.

杯别 2024-08-09 11:58:27

我在 BSD 手册页中找到了这条有用的信息:

几乎在所有对您来说重要的方面,子窗口都类似于顶级窗口。它有一个窗口ID;它有自己的一组事件回调;你可以渲染它;您会收到其创建的通知; ...

子窗口位于其他一些窗口(可能是顶级窗口,也可能是另一个子窗口)内。因此,它通常只与您自己创建的其他窗口交互,因此它不受窗口管理器的约束。这是其与顶级窗口差异的主要来源:

所以我假设流行工具包中的 GL 小部件实际上也充当不同的(子)窗口。有趣的是,这对窗口管理器是透明的,因此对用户也是透明的。

I found this helpful piece of information in a BSD manpage:

In almost every regard that is important to you, a subwindow is like a top-level window. It has a window id; it has its own set of event callbacks; you can render to it; you are notified of its creation; ...

A subwindow lives inside of some other window (possibly a top-level window, possibly another subwindow). Because of this, it generally only interacts with other windows of your own creation, hence it is not subjected to a window manager. This is the primary source for its differences from a top-level window:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文