I'm currently trying to embed FMOD
in my project and I want to get and print the version of FMOD
.
I done this:
#include "fmodmanager.h"
#include "fmod_errors.h"
#include <string>
using namespace FMOD;
EventSystem *pEventSystem;
Event *pEvent = NULL;
System *pSystem;
FMOD_RESULT result;
CFMODManager gFMODMng;
CFMODManager* FMODManager()
{
return &gFMODMng;
}
void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
WarnMsg("FMod error! (%d) %s\n", result, FMOD_ErrorString(result));
}
}
CFMODManager::CFMODManager()
{
}
CFMODManager::~CFMODManager()
{
}
// This starts FMOD
void CFMODManager::InitFMOD( void )
{
ERRCHECK(result = FMOD::EventSystem_Create(&pEventSystem));
ERRCHECK(result = pEventSystem->init(64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL));
// Print the version
fmodVersion = pSystem->getVersion(&fmodVersion);
Msg("FMod initialized (%d)\n", fmodVersion);
}
But what I get is:
FMod initialized (36)
Instead of returning the version, FMOD
return 36
The FMOD version number is stored as hexadecimal so it's easy to read in memory, i.e. 0x00044421 is easily read as 4.44.21, so you should print it using %x instead of %d.
Also the return from System:::getVersion is actually an FMOD_RESULT error code for the success or failure of the function call, you should not assign it to the version number you a trying to fetch.
Finally, you are getting the FMOD_RESULT 36 (FMOD_ERR_INVALID_HANDLE) because the pSystem pointer you are using hasn't been initialized. You should use EventSystem::getSystemObject after EventSystem_Create to fetch the valid low level system handle.