| 163 | } |
| 164 | |
| 165 | void DemoBase::init(int argc, char **argv, const char *demoName) |
| 166 | { |
| 167 | initParameters(); |
| 168 | m_exePath = FileSystem::getProgramPath(); |
| 169 | |
| 170 | m_sceneFile = ""; |
| 171 | setUseCache(true); |
| 172 | for (int i = 1; i < argc; i++) |
| 173 | { |
| 174 | string argStr = argv[i]; |
| 175 | if (argStr == "--no-cache") |
| 176 | setUseCache(false); |
| 177 | else |
| 178 | { |
| 179 | m_sceneFile = string(argv[i]); |
| 180 | if (FileSystem::isRelativePath(m_sceneFile)) |
| 181 | m_sceneFile = FileSystem::normalizePath(m_exePath + "/" + m_sceneFile); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | if (m_sceneFile != "") |
| 186 | m_outputPath = FileSystem::normalizePath(getExePath() + "/output/" + FileSystem::getFileName(m_sceneFile)); |
| 187 | else |
| 188 | m_outputPath = FileSystem::normalizePath(getExePath() + "/output/" + std::string(demoName)); |
| 189 | |
| 190 | #ifdef DL_OUTPUT |
| 191 | std::string sceneFilePath = FileSystem::normalizePath(m_outputPath + "/scene"); |
| 192 | FileSystem::makeDirs(sceneFilePath); |
| 193 | FileSystem::copyFile(m_sceneFile, sceneFilePath + "/" + FileSystem::getFileNameWithExt(m_sceneFile)); |
| 194 | |
| 195 | std::string progFilePath = FileSystem::normalizePath(m_outputPath + "/program"); |
| 196 | FileSystem::makeDirs(progFilePath); |
| 197 | FileSystem::copyFile(argv[0], progFilePath + "/" + FileSystem::getFileNameWithExt(argv[0])); |
| 198 | #endif |
| 199 | |
| 200 | std::string logPath = FileSystem::normalizePath(m_outputPath + "/log"); |
| 201 | FileSystem::makeDirs(logPath); |
| 202 | Utilities::logger.addSink(unique_ptr<Utilities::FileSink>(new Utilities::FileSink(Utilities::LogLevel::DEBUG, logPath + "/PBD_log.txt"))); |
| 203 | |
| 204 | LOG_DEBUG << "Git refspec: " << GIT_REFSPEC; |
| 205 | LOG_DEBUG << "Git SHA1: " << GIT_SHA1; |
| 206 | LOG_DEBUG << "Git status: " << GIT_LOCAL_STATUS; |
| 207 | LOG_DEBUG << "Host name: " << SystemInfo::getHostName(); |
| 208 | LOG_INFO << "PositionBasedDynamics " << PBD_VERSION; |
| 209 | |
| 210 | m_gui->init(); |
| 211 | |
| 212 | // OpenGL |
| 213 | MiniGL::init(argc, argv, 1280, 1024, demoName, m_gui->getVSync(), m_gui->getMaximized()); |
| 214 | MiniGL::initLights(); |
| 215 | MiniGL::initTexture(); |
| 216 | MiniGL::getOpenGLVersion(m_context_major_version, m_context_minor_version); |
| 217 | MiniGL::setViewport(40.0, 0.1f, 500.0, Vector3r(0.0, 3.0, 8.0), Vector3r(0.0, 0.0, 0.0)); |
| 218 | MiniGL::setSelectionFunc(selection, this); |
| 219 | |
| 220 | if (MiniGL::checkOpenGLVersion(3, 3)) |
| 221 | initShaders(); |
| 222 |
no test coverage detected