Orge在VS2008的配置方法

<一>.安装VS2008。

<二>.安装VS2008SP1(需要一定耐性)。

<三>.安装OgreSDK。地址http://downloads.sourceforge.net/ogre/OgreSDKSetup1.6.0RC1_VC90.exe

 只对应VS2008.

<四>.打开VS2008,新建项目Example,添加源文件Example.cpp

<五>.设置IDE环境(步骤如下)

  • 调试-->工作目录为"..\OgreSDK\bin\debug"(这里有使Ogre能正常工作的dll);
  • C/C++-->常规-->附加包含目录中加三个目录:("..\OgreSDK\Project\Example\include""..\OgreSDK\include""..\OgreSDK\samples\include");
  • C/C++-->代码生成-->运行时库"为"多线程调试 DLL (/MDd)"(这个好像是默认的);  
  • 链接器-->常规-->输出文件为"..\OgreSDK\bin\debug\$(ProjectName).exe" ;
  • 链接器-->常规-->附加库目录中添加"..\OgreSDK\lib";
  • 链接器-->输入-->附加依赖项中添加"OgreMain_d.lib"和"OIS_d.lib"(如果是Release版则添加"OgreMain.lib"和"OIS.lib")

<六>.添加以下代码:

#include "ExampleApplication.h"
class MyApplication : public ExampleApplication
{
protected:
public:
    MyApplication()
    
{
    }


    
~MyApplication()
    
{
    }

protected:
    
void createScene(void)
    
{
    }

}
;

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include 
"windows.h"

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
    
// Create application object
    MyApplication app;

    
try {
        app.go();
    }
 catch( Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBoxA( NULL, e.getFullDescription().c_str(), 
"An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
        fprintf(stderr, 
"An exception has occurred: %s ",
                e.getFullDescription().c_str());
#endif
    }


    
return 0;
}

<七>.If you get an Ogre Exception which complains about being unable to load a dynamic plugin then go to ..\OgreSDK\bin\debug\Plugins.cfg and take out the following lines..
(去..\OgreSDK\bin\debug\Plugins.cfg删除以下行并保存):

Plugin=Plugin_PCZSceneManager_d.dll Plugin=Plugin_OctreeZone_d.dll 

 

 <八>.开始执行,exe文件会在"..\OgreSDK\bin\debug\Example.exe"。

运行结果:

        

posted @ 2009-04-02 21:00  剑鬼鬼  阅读(2071)  评论(0编辑  收藏  举报