这是我的代码(简化):
//wrapper.h
#include <play3d.h>
class wrapper
{
private:
soundengine *soundEngine;
public:
sound *playSound3D(source *source, D3DXVECTOR3 pos, bool loop=false);
};
//wrapper.cpp
sound *wrapper::playSound3D(source *source, D3DXVECTOR3 pos, bool loop)
{
return soundEngine->play3D(source, pos, loop);
};
这是我的完整代码(根据要求)。它使用 irrKlang 声音引擎:
//irrKlang.h
virtual ISound* play3D(ISoundSource* source, vec3df pos,
bool playLooped = false,
bool startPaused = false,
bool track = false,
bool enableSoundEffects = false) = 0;//the version i want
virtual ISound* play3D(const char* soundFileName, vec3df pos,
bool playLooped = false,
bool startPaused = false,
bool track = false,
E_STREAM_MODE streamMode = ESM_AUTO_DETECT,
bool enableSoundEffects = false) = 0;//the version vc++ finds
//fsCore.h
#include <irrklang.h>
class fsEngine
{
private:
static fsEngine *instance;
static fsBool exists;
irrklang::ISoundEngine *soundEngine;
fsEngine();
~fsEngine();
public:
static fsEngine *getInstance()
{
if (!exists)
{
instance = new fsEngine();
exists = true;
return instance;
}
else
{
return instance;
}
};
void release()
{
exists = false;
delete instance;
soundEngine->drop();
};
public:
irrklang::ISoundSource *loadSound(fsString filename);
irrklang::ISoundSource *cloneSound(irrklang::ISoundSource *source, fsString alias=NULL);
irrklang::ISound *playSound2D(irrklang::ISoundSource *source, fsBool loop=false);
irrklang::ISound *playSound3D(irrklang::ISoundSource *source, D3DXVECTOR3 soundpos, fsBool loop=false);
};
//fsCore.cpp
#include "fsCore.h"
irrklang::ISound *fsEngine::playSound3D(irrklang::ISoundSource *source, D3DXVECTOR3 soundpos, bool loop)
{
return soundEngine->play3D(source, soundpos, loop);
};
我不知从哪里得到一个C2664 错误。
1>c:\users\...\documents\visual studio 2008\projects\core\fscore.cpp(20) : error C2664: 'irrklang::ISound *irrklang::ISoundEngine::play3D(const char *,irrklang::vec3df,bool,bool,bool,irrklang::E_STREAM_MODE,bool)' : cannot convert parameter 1 from 'irrklang::ISoundSource *' to 'const char *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Play3D() 有两个定义:一个接受 a'const char *'
作为参数 1,另一个接受'source *'
作为参数 1。Intellisense 指出了这两个定义,但我无法让 VC++ 2008 express 编译器识别我想要的版本。我要改变什么?