我第一次使用 OpenAL,在我的一生中,我无法弄清楚为什么设置源的位置对声音没有任何影响。声音是立体声格式,我确定我设置了听者的位置,声音对听者来说不是真实的,OpenAL 没有发出任何错误。
任何人都可以解释一下吗?
创建音频设备
ALenum result;
mDevice = alcOpenDevice(NULL);
if((result = alGetError()) != AL_NO_ERROR)
{
std::cerr << "Failed to create Device. " << GetALError(result) << std::endl;
return;
}
mContext = alcCreateContext(mDevice, NULL);
if((result = alGetError()) != AL_NO_ERROR)
{
std::cerr << "Failed to create Context. " << GetALError(result) << std::endl;
return;
}
alcMakeContextCurrent(mContext);
SoundListener::SetListenerPosition(0.0f, 0.0f, 0.0f);
SoundListener::SetListenerOrientation(0.0f, 0.0f, -1.0f);
两个监听函数调用
alListener3f(AL_POSITION, x, y, z);
Real vec[6] = {x, y, z, 0.0f, 1.0f, 0.0f};
alListenerfv(AL_ORIENTATION, vec);
我将源位置设置为 1,0,0,它应该在听者的右侧,但它没有效果
alSource3f(mSourceHandle, AL_POSITION, x, y, z);
任何指导将不胜感激