当前位置: 首页>>代码示例>>C++>>正文


C++ FilePath::directory方法代码示例

本文整理汇总了C++中FilePath::directory方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::directory方法的具体用法?C++ FilePath::directory怎么用?C++ FilePath::directory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilePath的用法示例。


在下文中一共展示了FilePath::directory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initScene

Viewer::Viewer(const char* title, const FilePath& applicationPath, const FilePath& settingsFilePath):
    m_Path(settingsFilePath.directory()),
    m_Settings(applicationPath.file(), settingsFilePath),
    m_WindowManager(m_Settings.m_WindowSize.x, m_Settings.m_WindowSize.y,
                    title),
    m_GUI(applicationPath.file(), m_WindowManager),
    m_ShaderManager(applicationPath.directory() + "shaders"),
    m_GLImageRenderer(m_ShaderManager),
    m_ViewController(m_WindowManager.getWindow()) {

    std::clog << "applicationPath = " << applicationPath << std::endl;
    std::clog << "settingsFilePath = " << settingsFilePath << std::endl;

    initScene();
    initConfigManager();

    m_ViewController.setSpeed(m_Settings.m_fSpeedFarRatio * length(size(m_pScene->getBBox())));

    std::clog << "Number of system threads = " << getSystemThreadCount() << std::endl;

    m_RenderModule.setUp(m_Path,
                         m_Settings.m_pCacheRoot,
                         m_Settings.m_FramebufferSize);

    {
        // Load current config
        auto pConfig = m_Settings.m_pCacheRoot->FirstChildElement("Config");
        if(pConfig) {
            std::string name;
            if(getAttribute(*pConfig, "name", name)) {
                try {
                    ProjectiveCamera camera;
                    m_ConfigManager.loadConfig(name, camera, *m_pScene,
                        m_Settings.m_FramebufferSize.x, m_Settings.m_FramebufferSize.y,
                        m_ZNearFar.x, m_ZNearFar.y);
                    m_nCurrentConfig = m_ConfigManager.getConfigIndex(name);
                } catch(...) {
                    std::cerr << "Unable to load previously cached configuration" << std::endl;
                }
            }
        } else {
            auto configCount = m_ConfigManager.getConfigs().size();
            if(configCount > 0u) {
                ProjectiveCamera camera;
                m_ConfigManager.loadConfig(0, camera, *m_pScene,
                    m_Settings.m_FramebufferSize.x, m_Settings.m_FramebufferSize.y,
                    m_ZNearFar.x, m_ZNearFar.y);
                m_nCurrentConfig = 0;
            } else {
                LOG(INFO) << "No configs for the scene, the program might eventually crash.";
            }
        }
    }
}
开发者ID:Celeborn2BeAlive,项目名称:pg2015-code,代码行数:54,代码来源:Viewer.cpp

示例2: runtime_error

Viewer::Settings::Settings(const std::string& applicationName, const FilePath& filepath):
    m_FilePath(filepath) {

    if(tinyxml2::XML_NO_ERROR != m_Document.LoadFile(filepath.c_str())) {
        throw std::runtime_error("Unable to load viewer settings file");
    }

    if(nullptr == (m_pRoot = m_Document.RootElement())) {
        throw std::runtime_error("Invalid viewer settings file format (no root element)");
    }

    auto pWindow = m_pRoot->FirstChildElement("Window");
    if(!pWindow) {
        throw std::runtime_error("Invalid viewer settings file format (no Window element)");
    }

    if(!getAttribute(*pWindow, "width", m_WindowSize.x) ||
            !getAttribute(*pWindow, "height", m_WindowSize.y)) {
        throw std::runtime_error("Invalid viewer settings file format (no width/height params)");
    }

    auto pViewController = m_pRoot->FirstChildElement("ViewController");
    if(pViewController) {
        if(!getAttribute(*pViewController, "speedFarRatio", m_fSpeedFarRatio)) {
            throw std::runtime_error("Invalid viewer settings file format (no speedFarRatio params in ViewController)");
        }
    }

    auto pFramebuffer = m_pRoot->FirstChildElement("Framebuffer");
    if(!getAttribute(*pFramebuffer, "width", m_FramebufferSize.x) ||
            !getAttribute(*pFramebuffer, "height", m_FramebufferSize.y)) {
        throw std::runtime_error("Invalid viewer settings file format (no width/height params for the framebuffer)");
    }
    m_fFramebufferRatio = float(m_FramebufferSize.x) / m_FramebufferSize.y;

    auto cacheDirectory = filepath.directory() + "cache";
    createDirectory(cacheDirectory);
    m_CacheFilePath = cacheDirectory + (applicationName + ".cache.bnz.xml");
    if(tinyxml2::XML_NO_ERROR != m_CacheDocument.LoadFile(m_CacheFilePath.c_str())) {
        auto pRoot = m_CacheDocument.NewElement("Cache");
        m_CacheDocument.InsertFirstChild(pRoot);
    }
    m_pCacheRoot = m_CacheDocument.RootElement();
}
开发者ID:Celeborn2BeAlive,项目名称:pg2015-code,代码行数:44,代码来源:Viewer.cpp


注:本文中的FilePath::directory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。