Initializing FMOD
The first code that we need to add is the code that will initialize the audio engine. Just like we must initialize OpenGL, the code will set up FMOD and check to see if there are any errors along the way.
Open RoboRacer2D.cpp
and add the following code to the variable declarations area:
FMOD::System* audiomgr;
Then add the following function:
bool InitFmod() { FMOD_RESULT result; result = FMOD::System_Create(&audiomgr); if (result != FMOD_OK) { return false; } result = audiomgr->init(50, FMOD_INIT_NORMAL, NULL); if (result != FMOD_OK) { return false; } return true; }
This function creates the FMOD system and initializes it:
First, we define a variable to catch FMOD error codes
The
System_Create
call creates the engine and stores the results inaudiomgr
We then initialize FMOD with 50 virtual channels, normal mode, and
Finally, we need call the InitAudio
function. Modify the GameLoop
function, adding the highlighted line:
void GameLoop(const float...