OpenAL 设备、缓冲区和上下文关系

发布于 2024-09-04 03:45:16 字数 410 浏览 2 评论 0原文

我正在尝试创建一个面向对象的模型来包装 OpenAL,但在理解设备、缓冲区和上下文方面遇到了一些问题。

从我在程序员指南中看到的,有多个设备,每个设备都可以有多个上下文以及多个缓冲区。每个上下文都有一个监听器,alListener*() 函数都对活动上下文的监听器进行操作。 (这意味着如果我想更改它的侦听器,我必须首先激活另一个上下文,如果我做对了。)到目前为止,一切都很好。 但令我恼火的是,我需要将设备传递给 alcCreateContext() 函数,但不需要传递给 alGenBuffers()

那么这是如何运作的呢?当我打开多个设备时,缓冲区是在哪个设备上创建的?所有设备之间是否共享缓冲区?如果我关闭所有打开的设备,缓冲区会发生什么情况?

(或者我错过了什么?)

I'm trying to create an object oriented model to wrap OpenAL and have a little problem understanding the devices, buffers and contexts.

From what I can see in the Programmer's Guide, there are multiple devices, each of which can have multiple contexts as well as multiple buffers. Each context has a listener, and the alListener*() functions all operate on the listener of the active context. (Meaning that I have to make another context active first if I wanted to change it's listener, if I got that right.) So far, so good.
What irritates me though is that I need to pass a device to the alcCreateContext() function, but none to alGenBuffers().

How does this work then? When I open multiple devices, on which device are the buffers created? Are the buffers shared between all devices? What happens to the buffers if I close all open devices?

(Or is there something I missed?)

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

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

发布评论

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

评论(1

我做我的改变 2024-09-11 03:45:16

好的,问题解决了。我在此处提出了问题答案是

所有 al* 函数(而不是 alc* 函数)都在当前
语境。因此,alGenBuffer 调用将在当前上下文上进行操作
创建属于上下文设备的缓冲区(上下文只能有
一台设备)。

在一台设备上创建的缓冲区在另一台设备上不可用。

当您调用时,设备的缓冲区将(可能)自动销毁
alc关闭设备。

因此,我必须使该设备的任意上下文处于活动状态,然后创建缓冲区,然后再次使旧上下文处于活动状态。或者,如果设备不活动,则完全阻止创建缓冲区,这意味着它的上下文都不活动。

Okay, problem solved. I asked the question here and the answer was

All the al* functions (rather than alc* functions) operate on the current
context. So, alGenBuffer calls will operate on the current context and
create Buffers that belong to the Context's Device (a Context can only have
one Device).

Buffers created on one Device are not available on another Device.

A Device's Buffers will (probably) be automatically destroyed when you call
alcCloseDevice.

So I will have to make an arbitrary context of that device active, then create the buffers, then make the old context active again. Or prevent creation of buffers altogether if the device is not active, meaning that none of it's contexts is active.

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