shawind 发表于 2006-10-16 14:51:08

[讨论]irrlicht和openal,audiere的配合使用

又遇到了那个问题,
使用Use Unicode Character Set配置进行编译的时候,
opengal的官方sdk中的framework里面的LoadOAL.cpp的数据类型又报错了。
把char转成wchar就可以正常编译了,但是这样又不能正常link。
原装库文件中的数据还是原来的char类型,显然是需要自己重新去编译openal32.lib
现在的问题是lgpl的东西,可以随便修改原来发布的文件么?
如果不能改动原来的东西,怎么样让它以unicode正常编译?

shawind 发表于 2006-10-16 22:19:39

自己用最笨的办法解决了,
不调用uicode的winapi来获取OpenAL32.dll的路径就可以了。
只是这样做就必须用把OpenAL32.dll和生成的exe放在同一个目录下面。
唉,管他的,能用就行了。

shawind 发表于 2006-10-17 22:24:03

看了另外一个音频引擎audiere,http://audiere.sourceforge.net/
它的API使用比OpenAL要简单了不少。
新的1.9.4版已经增加了windows下对midi和cd音轨的支持。
现在可以方便的使用wav,aiff,ogg,flac,mp3,mod,s3m,it,xm,midi,cd等众多的格式。
只是还没有直接支持3D声效。

附一个简单的例子

#include <windows.h>
#include <irrlicht.h>
#include <audiere.h>

#pragma comment (lib, "Irrlicht.lib")
#pragma comment (lib, "audiere.lib")

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace audiere;


INT WINAPI WinMain ( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
{
    IrrlichtDevice *Device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 32, false, false, 0);
    IVideoDriver   *Driver = Device->getVideoDriver();
    IGUIEnvironment*env    = Device->getGUIEnvironment();
    ISceneManager*Scene= Device->getSceneManager();
   
   //初始化音频

    AudioDevicePtraudiereDevice;
    OutputStreamPtrstream;

    audiereDevice = OpenDevice();
    if (!audiereDevice)
   return 1;

    stream = OpenSound(audiereDevice.get(), "demo.ogg", true); //载入ogg文件
    if (!stream)
   return 2;

    stream->setRepeat(true);//并设定为循环播放
    stream->setVolume(1.0f); //50%音量
    stream->play(); //播放

    while(Device->run())
    {
      Driver->beginScene(true, true, SColor(0,64,64,64));

      Scene->drawAll();
      
      env->drawAll();
      
      Driver->endScene();

    }

    Device->drop();
    return 0;
}


效果是出来一个空窗口,然后循环播放demo.ogg文件。
因为api设计的简洁明快,用起来也显得相当的简单。不多说了。
页: [1]
查看完整版本: [讨论]irrlicht和openal,audiere的配合使用