Development/Tutorials/Games/KALEngine
< Development | Tutorials
KALEngine tutorial
Tutorial Series | KALEngine developement |
Prerequisites | None |
What's Next | Nothing at the moment |
Further Reading | KGLEngine2d's code |
Abstract
Phonon is not really designed to handle multiple sounds at the same time. KALEngine is made for games and create one thread per sound, using the excellent openAL librairy. you also get all the other openAL goodness like 3D sounds, effects and multichannel.
Installation
1: Be sure you have installed dependent librairy. - openAL ( sound api) - alut (openal toolkit) - libSndFile (load sound file).
2: compile and install kalengine from svn : /trunk/playground/games/KALEngine/
Hello Word
- include <KALEngine>
- include <KALSource>
- include <KDebug>
int main(int argc, char **argv)
{
KALEngine snd; //create an openAL object
snd.init(); // Initialize OpenAL Context + Device!
KALSource *son = new KALSource(); // create a sample, if no argument, It will play an "hello world"
son->play(); // play the sound!!
while (son->getStatus() == AL_PLAYING) // wait while sound is playing
{
kDebug()<<son->getElapsedTime(); //print the elapsed time.
}
delete son; //when it finished! Don't forget to clear the buffer!!
snd.shutdown(); // and close the device!!
return 0;
}