Hi all,
I try to load data such as models and bg music from a seperate thread and keep playing a now loading sprite animation while data is loading.
The code is like this:
#include "DarkGDK.h"
#include "process.h"
void LoadDataThread(PVOID pvoid)
{
//dbLoadMusic("bg.mp3",1);
//dbLoopMusic(1);
//dbLoadSound("WA01.wav",2);
//dbLoopSound(2);
dbLoadObject("TestLevel01.X",1);
dbLoadObject("tutolevel.x", 2);
}
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbAutoCamOff();
dbPositionCamera(0, 50, 20);
dbCreateAnimatedSprite(1, "015-Fire01.png", 5,2,1);
_beginthread(&LoadDataThread, 0, NULL);
// our main loop
while ( LoopGDK ( ) )
{
//keep playing the now loading animation
dbPlaySprite(1, 1, 10,100);
dbPasteSprite(1,10,10);
dbControlCameraUsingArrowKeys(0,1.0,0.5);
// update the screen
dbSync ( );
}
// return back to windows
return;
}
It can load models and display it normally but it cannot load mp3 and wav and play it inside the thread.
Anyone know why loading music from another thread would fail?
Thx.