0

I have a scene that is modified when mouse left button is clicked.

My problem is: this modified scene was supposed to appear with a sound, but the scene waits the sounds to finish before it renders itself.

I'm using this function:

do {
        alGetSourcei(source, AL_SOURCE_STATE, &state);
 } while (state == AL_PLAYING);

Of course, this function tells the program to wait. But what alternative could I use? if I remove this function, the sound isnt played

I even tried to create a function sound(), that is called after glutPostRedisplay but it still waits the sound complete to render

4

1 回答 1

1

我认为您的问题,即声音停止,在其他地方。alGetSourcei不需要保持声音播放。

无论如何,您不能在 while 循环中执行此操作,因为它会阻止 Windows 消息和 OpenGL 的更新,并会阻止场景重绘。

要播放它,您只需要调用alSourcePlay,之后您可以检查源是否仍在播放(如果您出于某种原因需要这样做)。

于 2013-07-07T18:57:56.493 回答