zoukankan      html  css  js  c++  java
  • OgreSDK_vc8_v172 sample compile problem

    本本上编译的是比较早的ogre3d代码,看到新的ogre3d版本的sample做了修改, 每个例子都弄成dll,想看看怎么样,下了一个来编译,结果出问题了,一个是vc版本问题,下了VS80sp1-KB971090-X86-INTL.exe补丁打上, 另一个是装的directx版本也老了,找不到d3dx9d_42.dll,又下了个DXSDK_Aug09.exe,最后终于ok了,结果运行sample brower时候,TMD出现异常,提示0: fileexception, can not create saveconfig file... ..., 最后只好照着异常提示,看ogre3d的ogreroot.cpp代码,查找问题,终于揪出了元凶:

    首先是找到这里:

    //ogreroot.cpp

    void Root::saveConfig(void)
        {
            if (mConfigFileName.empty ())
                return;

      std::ofstream of(mConfigFileName.c_str()); //这里啦!!!!

            if (!of)  //这里啦!!!!!!!!
                OGRE_EXCEPT(Exception::ERR_CANNOT_WRITE_TO_FILE, "Cannot create settings file.",
                "Root::saveConfig");

    -----------------------------------------------------------------

    ‍mConfigFileName----------->

    -----------------------------------------------------------

    到这里啦:samplecontext.h

    virtual void createRoot()
      {
                Ogre::String pluginsPath = Ogre::StringUtil::BLANK;
                #ifndef OGRE_STATIC_LIB
        pluginsPath = mFSLayer->getConfigFilePath("plugins.cfg");
                #endif
       mRoot = OGRE_NEW Ogre::Root(pluginsPath, mFSLayer->getWritablePath("ogre.cfg"),  //这里啦!!!!!!!!
        mFSLayer->getWritablePath("ogre.log"));

    --------------------------------------------------------------

    ‍最后到这里啦:。。。。。。。。

     //就是这里出问题的啦,sample的coder脑子哪有问题,为什么不在sample brower执行文件同目录下,设置ogre.cfg路径!!!

    //跑到我的:我的文档下,搞出\Ogre\Cthugha 这鬼东西

    //Samples\Browser\src\FileSystemLayerImpl_WIN32.cpp

     void FileSystemLayerImpl::prepareUserHome(const Ogre::String& subdir)
     {

      TCHAR path[MAX_PATH];
      //////////////////////////////////////////////////////////////////////////这是我添加的代码,改变sample code的路径mHomePath到sample brower执行文件目录下
            GetModuleFileName(NULL, path, MAX_PATH);
      TCHAR oemPath[MAX_PATH];
      CharToOem(path, oemPath);
      mHomePath = oemPath;
      return;
      //////////////////////////////////////////////////////////////////////////这是我添加的代码,改变sample code的路径mHomePath到sample brower执行文件目录下

    ‍不过为什么:我的文档\Ogre\Cthugha 这个路径有问题呢?

    原来是:

    问题出在std::ofstream of(mConfigFileName.c_str()); //这里啦!!!!

     如果文件的路径中含有中文字符的话这个文件不会被创建也不会被打开,sample coder设置到:D:\我的文档\Ogre\Cthugha, 出问题的。

    当然如果不想改prepareUserHome,就设置setlocale(LC_ALL, "chs");支持中文路径

    最后去享受sample啦!

    最后说句感想:无源代码无真相!

    if没有查看ogreroot.cpp

    my head will be reeling!

  • 相关阅读:
    有向无环图描述表达式 (a+b)*((a+b)/a)至少需要的顶点数目
    图的深度优先是 树的先序遍历的推广。 广度优先
    leader failed to send out heartbeat on time; took too long, leader is overloaded likely from slow disk
    优化 并发
    最终一致和强一致性缓存实践
    Go语言逆向初探 原创 半个大西瓜 看雪学院 2021-06-23
    中通快递的云原生改造之路 施尧 InfoQ 2021-06-23
    Stable Minimum Storage Merging by Symmetric Comparisons Pok-Son Kim1? and Arne Kutzner2
    A Method for the Construction of Minimum-Redundancy Codes
    滴滴基于Binlog的采集架构与实践 原创 滴滴技术团队 滴滴技术 2021-06-22
  • 原文地址:https://www.cnblogs.com/europelee/p/3388661.html
Copyright © 2011-2022 走看看