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
I think your problem, that the sounds stop, is somewhere else. alGetSourcei
is not required to keep the sound playing.
Anyway you can't do that in a while loop because it will block the update of the windows messages and OpenGL and will prevent the scene from redrawing.
To play it you just need to call alSourcePlay
, after this you could check each frame if the source is still playing ( if you need to do this for some reason ).