mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-21 11:39:51 -06:00
Include VisualStudioOutputLog
Correctly allow '/' character in SceneGraph description files
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/logging/consolelog.h>
|
||||
#include <ghoul/logging/visualstudiooutputlog.h>
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
#include <ghoul/systemcapabilities/systemcapabilities>
|
||||
@@ -71,6 +72,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <WinBase.h>
|
||||
#endif
|
||||
|
||||
using namespace openspace::scripting;
|
||||
using namespace ghoul::filesystem;
|
||||
using namespace ghoul::logging;
|
||||
@@ -79,7 +84,7 @@ using namespace ghoul::cmdparser;
|
||||
namespace {
|
||||
const std::string _loggerCat = "OpenSpaceEngine";
|
||||
const std::string _sgctDefaultConfigFile = "${SGCT}/single.xml";
|
||||
const std::string _defaultCacheLocation = "${BASE_PATH}/cache";
|
||||
const std::string _defaultCacheLocation = "${BASE_PATH}/cache";
|
||||
|
||||
const std::string _sgctConfigArgumentCommand = "-config";
|
||||
|
||||
@@ -88,7 +93,7 @@ namespace {
|
||||
|
||||
struct {
|
||||
std::string configurationName;
|
||||
std::string sgctConfigurationName;
|
||||
std::string sgctConfigurationName;
|
||||
std::string sceneName;
|
||||
} commandlineArgumentPlaceholders;
|
||||
}
|
||||
@@ -113,7 +118,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
|
||||
, _parallelConnection(new network::ParallelConnection)
|
||||
, _windowWrapper(std::move(windowWrapper))
|
||||
, _globalPropertyNamespace(new properties::PropertyOwner)
|
||||
, _isMaster(false)
|
||||
, _isMaster(false)
|
||||
, _runTime(0.0)
|
||||
, _syncBuffer(new SyncBuffer(1024))
|
||||
{
|
||||
@@ -147,7 +152,7 @@ OpenSpaceEngine::~OpenSpaceEngine() {
|
||||
_console = nullptr;
|
||||
_moduleEngine = nullptr;
|
||||
_gui = nullptr;
|
||||
_syncBuffer = nullptr;
|
||||
_syncBuffer = nullptr;
|
||||
}
|
||||
|
||||
OpenSpaceEngine& OpenSpaceEngine::ref() {
|
||||
@@ -164,18 +169,18 @@ bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
|
||||
ghoul::initialize();
|
||||
|
||||
// Initialize the LogManager and add the console log as this will be used every time
|
||||
// and we need a fall back if something goes wrong between here and when we add the
|
||||
// logs from the configuration file. If the user requested as specific loglevel in the
|
||||
// configuration file, we will deinitialize this LogManager and reinitialize it later
|
||||
// with the correct LogLevel
|
||||
LogManager::initialize(
|
||||
// Initialize the LogManager and add the console log as this will be used every time
|
||||
// and we need a fall back if something goes wrong between here and when we add the
|
||||
// logs from the configuration file. If the user requested as specific loglevel in the
|
||||
// configuration file, we will deinitialize this LogManager and reinitialize it later
|
||||
// with the correct LogLevel
|
||||
LogManager::initialize(
|
||||
LogManager::LogLevel::Debug,
|
||||
ghoul::logging::LogManager::ImmediateFlush::Yes
|
||||
);
|
||||
LogMgr.addLog(std::make_unique<ConsoleLog>());
|
||||
|
||||
LDEBUG("Initialize FileSystem");
|
||||
LDEBUG("Initialize FileSystem");
|
||||
|
||||
#ifdef __APPLE__
|
||||
ghoul::filesystem::File app(argv[0]);
|
||||
@@ -184,33 +189,33 @@ bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
FileSys.setCurrentDirectory(dirName);
|
||||
#endif
|
||||
|
||||
// Sanity check of values
|
||||
if (argc < 1 || argv == nullptr) {
|
||||
LFATAL("No arguments were passed to this function");
|
||||
return false;
|
||||
}
|
||||
// Sanity check of values
|
||||
if (argc < 1 || argv == nullptr) {
|
||||
LFATAL("No arguments were passed to this function");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create other objects
|
||||
LDEBUG("Creating OpenSpaceEngine");
|
||||
// Create other objects
|
||||
LDEBUG("Creating OpenSpaceEngine");
|
||||
_engine = new OpenSpaceEngine(std::string(argv[0]), std::move(windowWrapper));
|
||||
|
||||
// Query modules for commandline arguments
|
||||
bool gatherSuccess = _engine->gatherCommandlineArguments();
|
||||
if (!gatherSuccess)
|
||||
return false;
|
||||
// Query modules for commandline arguments
|
||||
bool gatherSuccess = _engine->gatherCommandlineArguments();
|
||||
if (!gatherSuccess)
|
||||
return false;
|
||||
|
||||
// Parse commandline arguments
|
||||
// Parse commandline arguments
|
||||
sgctArguments = *(_engine->_commandlineParser->setCommandLine(argc, argv));
|
||||
bool showHelp = _engine->_commandlineParser->execute();
|
||||
bool showHelp = _engine->_commandlineParser->execute();
|
||||
if (showHelp) {
|
||||
_engine->_commandlineParser->displayHelp();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find configuration
|
||||
std::string configurationFilePath = commandlineArgumentPlaceholders.configurationName;
|
||||
if (configurationFilePath.empty()) {
|
||||
LDEBUG("Finding configuration");
|
||||
// Find configuration
|
||||
std::string configurationFilePath = commandlineArgumentPlaceholders.configurationName;
|
||||
if (configurationFilePath.empty()) {
|
||||
LDEBUG("Finding configuration");
|
||||
try {
|
||||
configurationFilePath =
|
||||
ConfigurationManager::findConfiguration(configurationFilePath);
|
||||
@@ -218,12 +223,12 @@ bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LFATALC(e.component, e.message);
|
||||
}
|
||||
}
|
||||
configurationFilePath = absPath(configurationFilePath);
|
||||
LINFO("Configuration Path: '" << configurationFilePath << "'");
|
||||
}
|
||||
configurationFilePath = absPath(configurationFilePath);
|
||||
LINFO("Configuration Path: '" << configurationFilePath << "'");
|
||||
|
||||
// Loading configuration from disk
|
||||
LDEBUG("Loading configuration from disk");
|
||||
// Loading configuration from disk
|
||||
LDEBUG("Loading configuration from disk");
|
||||
try {
|
||||
_engine->configurationManager().loadFromFile(configurationFilePath);
|
||||
}
|
||||
@@ -233,55 +238,55 @@ bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialize the requested logs from the configuration file
|
||||
_engine->configureLogging();
|
||||
// Initialize the requested logs from the configuration file
|
||||
_engine->configureLogging();
|
||||
|
||||
LINFOC("OpenSpace Version",
|
||||
OPENSPACE_VERSION_MAJOR << "." <<
|
||||
OPENSPACE_VERSION_MINOR << "." <<
|
||||
OPENSPACE_VERSION_PATCH << " (" << OPENSPACE_VERSION_STRING << ")");
|
||||
|
||||
// Create directories that doesn't exist
|
||||
auto tokens = FileSys.tokens();
|
||||
for (const std::string& token : tokens) {
|
||||
if (!FileSys.directoryExists(token)) {
|
||||
std::string p = absPath(token);
|
||||
LDEBUG("Directory '" << p << "' does not exist, creating.");
|
||||
// Create directories that doesn't exist
|
||||
auto tokens = FileSys.tokens();
|
||||
for (const std::string& token : tokens) {
|
||||
if (!FileSys.directoryExists(token)) {
|
||||
std::string p = absPath(token);
|
||||
LDEBUG("Directory '" << p << "' does not exist, creating.");
|
||||
FileSys.createDirectory(p, ghoul::filesystem::FileSystem::Recursive::Yes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register modules
|
||||
_engine->_moduleEngine->initialize();
|
||||
|
||||
// Create the cachemanager
|
||||
FileSys.createCacheManager(
|
||||
// Create the cachemanager
|
||||
FileSys.createCacheManager(
|
||||
absPath("${" + ConfigurationManager::KeyCache + "}"), CacheVersion
|
||||
);
|
||||
_engine->_console->initialize();
|
||||
_engine->_console->initialize();
|
||||
|
||||
// Register the provided shader directories
|
||||
ghoul::opengl::ShaderPreprocessor::addIncludePath(absPath("${SHADERS}"));
|
||||
// Register the provided shader directories
|
||||
ghoul::opengl::ShaderPreprocessor::addIncludePath(absPath("${SHADERS}"));
|
||||
|
||||
// Determining SGCT configuration file
|
||||
LDEBUG("Determining SGCT configuration file");
|
||||
std::string sgctConfigurationPath = _sgctDefaultConfigFile;
|
||||
_engine->configurationManager().getValue(
|
||||
ConfigurationManager::KeyConfigSgct, sgctConfigurationPath);
|
||||
// Determining SGCT configuration file
|
||||
LDEBUG("Determining SGCT configuration file");
|
||||
std::string sgctConfigurationPath = _sgctDefaultConfigFile;
|
||||
_engine->configurationManager().getValue(
|
||||
ConfigurationManager::KeyConfigSgct, sgctConfigurationPath);
|
||||
|
||||
if (!commandlineArgumentPlaceholders.sgctConfigurationName.empty()) {
|
||||
LDEBUG("Overwriting SGCT configuration file with commandline argument: " <<
|
||||
commandlineArgumentPlaceholders.sgctConfigurationName);
|
||||
sgctConfigurationPath = commandlineArgumentPlaceholders.sgctConfigurationName;
|
||||
}
|
||||
if (!commandlineArgumentPlaceholders.sgctConfigurationName.empty()) {
|
||||
LDEBUG("Overwriting SGCT configuration file with commandline argument: " <<
|
||||
commandlineArgumentPlaceholders.sgctConfigurationName);
|
||||
sgctConfigurationPath = commandlineArgumentPlaceholders.sgctConfigurationName;
|
||||
}
|
||||
|
||||
// Prepend the outgoing sgctArguments with the program name
|
||||
// as well as the configuration file that sgct is supposed to use
|
||||
sgctArguments.insert(sgctArguments.begin(), argv[0]);
|
||||
sgctArguments.insert(sgctArguments.begin() + 1, _sgctConfigArgumentCommand);
|
||||
sgctArguments.insert(sgctArguments.begin() + 2, absPath(sgctConfigurationPath));
|
||||
// Prepend the outgoing sgctArguments with the program name
|
||||
// as well as the configuration file that sgct is supposed to use
|
||||
sgctArguments.insert(sgctArguments.begin(), argv[0]);
|
||||
sgctArguments.insert(sgctArguments.begin() + 1, _sgctConfigArgumentCommand);
|
||||
sgctArguments.insert(sgctArguments.begin() + 2, absPath(sgctConfigurationPath));
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::destroy() {
|
||||
@@ -289,30 +294,30 @@ void OpenSpaceEngine::destroy() {
|
||||
_engine->_console->deinitialize();
|
||||
|
||||
_engine->_scriptEngine->deinitialize();
|
||||
delete _engine;
|
||||
ghoul::systemcapabilities::SystemCapabilities::deinitialize();
|
||||
FactoryManager::deinitialize();
|
||||
Time::deinitialize();
|
||||
SpiceManager::deinitialize();
|
||||
delete _engine;
|
||||
ghoul::systemcapabilities::SystemCapabilities::deinitialize();
|
||||
FactoryManager::deinitialize();
|
||||
Time::deinitialize();
|
||||
SpiceManager::deinitialize();
|
||||
|
||||
LogManager::deinitialize();
|
||||
LogManager::deinitialize();
|
||||
|
||||
ghoul::deinitialize();
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::initialize() {
|
||||
// clear the screen so the user don't have to see old buffer contents from the
|
||||
// graphics card
|
||||
clearAllWindows();
|
||||
// clear the screen so the user don't have to see old buffer contents from the
|
||||
// graphics card
|
||||
clearAllWindows();
|
||||
|
||||
// Detect and log OpenCL and OpenGL versions and available devices
|
||||
// Detect and log OpenCL and OpenGL versions and available devices
|
||||
SysCap.addComponent(
|
||||
std::make_unique<ghoul::systemcapabilities::GeneralCapabilitiesComponent>()
|
||||
);
|
||||
SysCap.addComponent(
|
||||
std::make_unique<ghoul::systemcapabilities::OpenGLCapabilitiesComponent>()
|
||||
);
|
||||
SysCap.detectCapabilities();
|
||||
SysCap.detectCapabilities();
|
||||
|
||||
using Verbosity = ghoul::systemcapabilities::SystemCapabilitiesComponent::Verbosity;
|
||||
Verbosity verbosity = Verbosity::Default;
|
||||
@@ -328,43 +333,43 @@ bool OpenSpaceEngine::initialize() {
|
||||
if (verbosityMap.find(v) != verbosityMap.end())
|
||||
verbosity = verbosityMap[v];
|
||||
}
|
||||
SysCap.logCapabilities(verbosity);
|
||||
SysCap.logCapabilities(verbosity);
|
||||
|
||||
std::string requestURL = "";
|
||||
bool success = configurationManager().getValue(ConfigurationManager::KeyDownloadRequestURL, requestURL);
|
||||
if (success)
|
||||
DownloadManager::initialize(requestURL, DownloadVersion);
|
||||
|
||||
// Load SPICE time kernel
|
||||
success = loadSpiceKernels();
|
||||
if (!success)
|
||||
return false;
|
||||
// Load SPICE time kernel
|
||||
success = loadSpiceKernels();
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
// Register Lua script functions
|
||||
LDEBUG("Registering Lua libraries");
|
||||
_scriptEngine->addLibrary(RenderEngine::luaLibrary());
|
||||
_scriptEngine->addLibrary(Scene::luaLibrary());
|
||||
_scriptEngine->addLibrary(Time::luaLibrary());
|
||||
_scriptEngine->addLibrary(interaction::InteractionHandler::luaLibrary());
|
||||
_scriptEngine->addLibrary(LuaConsole::luaLibrary());
|
||||
_scriptEngine->addLibrary(gui::GUI::luaLibrary());
|
||||
// Register Lua script functions
|
||||
LDEBUG("Registering Lua libraries");
|
||||
_scriptEngine->addLibrary(RenderEngine::luaLibrary());
|
||||
_scriptEngine->addLibrary(Scene::luaLibrary());
|
||||
_scriptEngine->addLibrary(Time::luaLibrary());
|
||||
_scriptEngine->addLibrary(interaction::InteractionHandler::luaLibrary());
|
||||
_scriptEngine->addLibrary(LuaConsole::luaLibrary());
|
||||
_scriptEngine->addLibrary(gui::GUI::luaLibrary());
|
||||
_scriptEngine->addLibrary(network::ParallelConnection::luaLibrary());
|
||||
|
||||
// TODO: Maybe move all scenegraph and renderengine stuff to initializeGL
|
||||
scriptEngine().initialize();
|
||||
// TODO: Maybe move all scenegraph and renderengine stuff to initializeGL
|
||||
scriptEngine().initialize();
|
||||
|
||||
// If a LuaDocumentationFile was specified, generate it now
|
||||
const bool hasType = configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentationType);
|
||||
const bool hasFile = configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentationFile);
|
||||
if (hasType && hasFile) {
|
||||
std::string luaDocumentationType;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLuaDocumentationType, luaDocumentationType);
|
||||
std::string luaDocumentationFile;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLuaDocumentationFile, luaDocumentationFile);
|
||||
// If a LuaDocumentationFile was specified, generate it now
|
||||
const bool hasType = configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentationType);
|
||||
const bool hasFile = configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentationFile);
|
||||
if (hasType && hasFile) {
|
||||
std::string luaDocumentationType;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLuaDocumentationType, luaDocumentationType);
|
||||
std::string luaDocumentationFile;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLuaDocumentationFile, luaDocumentationFile);
|
||||
|
||||
luaDocumentationFile = absPath(luaDocumentationFile);
|
||||
_scriptEngine->writeDocumentation(luaDocumentationFile, luaDocumentationType);
|
||||
}
|
||||
luaDocumentationFile = absPath(luaDocumentationFile);
|
||||
_scriptEngine->writeDocumentation(luaDocumentationFile, luaDocumentationType);
|
||||
}
|
||||
|
||||
bool disableMasterRendering = false;
|
||||
configurationManager().getValue(
|
||||
@@ -372,41 +377,41 @@ bool OpenSpaceEngine::initialize() {
|
||||
_renderEngine->setDisableRenderingOnMaster(disableMasterRendering);
|
||||
|
||||
|
||||
// Load scenegraph
|
||||
Scene* sceneGraph = new Scene;
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
// Load scenegraph
|
||||
Scene* sceneGraph = new Scene;
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
|
||||
// initialize the RenderEngine
|
||||
// initialize the RenderEngine
|
||||
_renderEngine->initialize();
|
||||
sceneGraph->initialize();
|
||||
sceneGraph->initialize();
|
||||
|
||||
std::string sceneDescriptionPath = "";
|
||||
if (commandlineArgumentPlaceholders.sceneName.empty()) {
|
||||
success = configurationManager().getValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneDescriptionPath);
|
||||
success = configurationManager().getValue(
|
||||
ConfigurationManager::KeyConfigScene, sceneDescriptionPath);
|
||||
}
|
||||
else
|
||||
sceneDescriptionPath = commandlineArgumentPlaceholders.sceneName;
|
||||
sceneGraph->scheduleLoadSceneFile(sceneDescriptionPath);
|
||||
sceneGraph->scheduleLoadSceneFile(sceneDescriptionPath);
|
||||
|
||||
_interactionHandler->setKeyboardController(new interaction::KeyboardControllerFixed);
|
||||
_interactionHandler->setMouseController(new interaction::OrbitalMouseController);
|
||||
_interactionHandler->setKeyboardController(new interaction::KeyboardControllerFixed);
|
||||
_interactionHandler->setMouseController(new interaction::OrbitalMouseController);
|
||||
|
||||
// Run start up scripts
|
||||
runStartupScripts();
|
||||
// Run start up scripts
|
||||
runStartupScripts();
|
||||
|
||||
// Load a light and a monospaced font
|
||||
// Load a light and a monospaced font
|
||||
loadFonts();
|
||||
|
||||
LINFO("Initializing GUI");
|
||||
_gui->initialize();
|
||||
_gui->initialize();
|
||||
|
||||
LINFO("Finished initializing");
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::isInitialized() {
|
||||
return _engine != nullptr;
|
||||
return _engine != nullptr;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::clearAllWindows() {
|
||||
@@ -416,13 +421,13 @@ void OpenSpaceEngine::clearAllWindows() {
|
||||
bool OpenSpaceEngine::gatherCommandlineArguments() {
|
||||
// TODO: Get commandline arguments from all modules
|
||||
|
||||
commandlineArgumentPlaceholders.configurationName = "";
|
||||
commandlineArgumentPlaceholders.configurationName = "";
|
||||
_commandlineParser->addCommand(std::make_unique<SingleCommand<std::string>>(
|
||||
&commandlineArgumentPlaceholders.configurationName, "-config", "-c",
|
||||
"Provides the path to the OpenSpace configuration file"
|
||||
));
|
||||
|
||||
commandlineArgumentPlaceholders.sgctConfigurationName = "";
|
||||
commandlineArgumentPlaceholders.sgctConfigurationName = "";
|
||||
_commandlineParser->addCommand(std::make_unique<SingleCommand<std::string>>(
|
||||
&commandlineArgumentPlaceholders.sgctConfigurationName, "-sgct", "-s",
|
||||
"Provides the path to the SGCT configuration file, overriding the value set in "
|
||||
@@ -439,27 +444,27 @@ bool OpenSpaceEngine::gatherCommandlineArguments() {
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::loadSpiceKernels() {
|
||||
// Load time kernel
|
||||
std::string timeKernel;
|
||||
bool success = configurationManager().getValue(ConfigurationManager::KeySpiceTimeKernel, timeKernel);
|
||||
// Load time kernel
|
||||
std::string timeKernel;
|
||||
bool success = configurationManager().getValue(ConfigurationManager::KeySpiceTimeKernel, timeKernel);
|
||||
// Move this to configurationmanager::completenesscheck ---abock
|
||||
if (!success) {
|
||||
LERROR("Configuration file does not contain a '" << ConfigurationManager::KeySpiceTimeKernel << "'");
|
||||
return false;
|
||||
}
|
||||
SpiceManager::KernelHandle id =
|
||||
SpiceManager::ref().loadKernel(timeKernel);
|
||||
if (!success) {
|
||||
LERROR("Configuration file does not contain a '" << ConfigurationManager::KeySpiceTimeKernel << "'");
|
||||
return false;
|
||||
}
|
||||
SpiceManager::KernelHandle id =
|
||||
SpiceManager::ref().loadKernel(timeKernel);
|
||||
|
||||
// Load SPICE leap second kernel
|
||||
std::string leapSecondKernel;
|
||||
success = configurationManager().getValue(ConfigurationManager::KeySpiceLeapsecondKernel, leapSecondKernel);
|
||||
if (!success) {
|
||||
// Load SPICE leap second kernel
|
||||
std::string leapSecondKernel;
|
||||
success = configurationManager().getValue(ConfigurationManager::KeySpiceLeapsecondKernel, leapSecondKernel);
|
||||
if (!success) {
|
||||
// Move this to configurationmanager::completenesscheck ---abock
|
||||
LERROR("Configuration file does not have a '" << ConfigurationManager::KeySpiceLeapsecondKernel << "'");
|
||||
return false;
|
||||
}
|
||||
id = SpiceManager::ref().loadKernel(std::move(leapSecondKernel));
|
||||
return true;
|
||||
LERROR("Configuration file does not have a '" << ConfigurationManager::KeySpiceLeapsecondKernel << "'");
|
||||
return false;
|
||||
}
|
||||
id = SpiceManager::ref().loadKernel(std::move(leapSecondKernel));
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) {
|
||||
@@ -500,9 +505,9 @@ void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) {
|
||||
|
||||
|
||||
void OpenSpaceEngine::runStartupScripts() {
|
||||
ghoul::Dictionary scripts;
|
||||
configurationManager().getValue(
|
||||
ConfigurationManager::KeyStartupScript, scripts);
|
||||
ghoul::Dictionary scripts;
|
||||
configurationManager().getValue(
|
||||
ConfigurationManager::KeyStartupScript, scripts);
|
||||
runScripts(scripts);
|
||||
}
|
||||
|
||||
@@ -546,30 +551,30 @@ void OpenSpaceEngine::loadFonts() {
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::configureLogging() {
|
||||
if (configurationManager().hasKeyAndValue<std::string>(ConfigurationManager::KeyLogLevel)) {
|
||||
std::string logLevel;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLogLevel, logLevel);
|
||||
if (configurationManager().hasKeyAndValue<std::string>(ConfigurationManager::KeyLogLevel)) {
|
||||
std::string logLevel;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLogLevel, logLevel);
|
||||
|
||||
bool immediateFlush = false;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLogImmediateFlush, immediateFlush);
|
||||
bool immediateFlush = false;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLogImmediateFlush, immediateFlush);
|
||||
|
||||
LogManager::LogLevel level = LogManager::levelFromString(logLevel);
|
||||
LogManager::deinitialize();
|
||||
LogManager::LogLevel level = LogManager::levelFromString(logLevel);
|
||||
LogManager::deinitialize();
|
||||
using ImmediateFlush = ghoul::logging::LogManager::ImmediateFlush;
|
||||
LogManager::initialize(
|
||||
level,
|
||||
immediateFlush ? ImmediateFlush::Yes : ImmediateFlush::No
|
||||
);
|
||||
LogMgr.addLog(std::make_unique<ConsoleLog>());
|
||||
}
|
||||
LogMgr.addLog(std::make_unique<ConsoleLog>());
|
||||
}
|
||||
|
||||
if (configurationManager().hasKeyAndValue<ghoul::Dictionary>(ConfigurationManager::KeyLogs)) {
|
||||
ghoul::Dictionary logs;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLogs, logs);
|
||||
if (configurationManager().hasKeyAndValue<ghoul::Dictionary>(ConfigurationManager::KeyLogs)) {
|
||||
ghoul::Dictionary logs;
|
||||
configurationManager().getValue(ConfigurationManager::KeyLogs, logs);
|
||||
|
||||
for (size_t i = 1; i <= logs.size(); ++i) {
|
||||
ghoul::Dictionary logInfo;
|
||||
logs.getValue(std::to_string(i), logInfo);
|
||||
for (size_t i = 1; i <= logs.size(); ++i) {
|
||||
ghoul::Dictionary logInfo;
|
||||
logs.getValue(std::to_string(i), logInfo);
|
||||
|
||||
try {
|
||||
LogMgr.addLog(createLog(logInfo));
|
||||
@@ -577,8 +582,14 @@ void OpenSpaceEngine::configureLogging() {
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
if (IsDebuggerPresent()) {
|
||||
LogMgr.addLog(std::make_unique<VisualStudioOutputLog>());
|
||||
}
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::initializeGL() {
|
||||
@@ -592,15 +603,15 @@ bool OpenSpaceEngine::initializeGL() {
|
||||
LERROR(e.what());
|
||||
}
|
||||
LINFO("Finished initializing OpenGL");
|
||||
return success;
|
||||
return success;
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::isMaster(){
|
||||
return _isMaster;
|
||||
return _isMaster;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::setMaster(bool master){
|
||||
_isMaster = master;
|
||||
_isMaster = master;
|
||||
}
|
||||
|
||||
double OpenSpaceEngine::runTime(){
|
||||
@@ -612,24 +623,24 @@ void OpenSpaceEngine::setRunTime(double d){
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::preSynchronization() {
|
||||
FileSys.triggerFilesystemEvents();
|
||||
FileSys.triggerFilesystemEvents();
|
||||
if (_isMaster) {
|
||||
double dt = _windowWrapper->averageDeltaTime();
|
||||
|
||||
Time::ref().advanceTime(dt);
|
||||
Time::ref().preSynchronization();
|
||||
|
||||
Time::ref().advanceTime(dt);
|
||||
Time::ref().preSynchronization();
|
||||
|
||||
_interactionHandler->update(dt);
|
||||
_scriptEngine->preSynchronization();
|
||||
_scriptEngine->preSynchronization();
|
||||
_renderEngine->preSynchronization();
|
||||
_parallelConnection->preSynchronization();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
Time::ref().postSynchronizationPreDraw();
|
||||
Time::ref().postSynchronizationPreDraw();
|
||||
|
||||
_scriptEngine->postSynchronizationPreDraw();
|
||||
_scriptEngine->postSynchronizationPreDraw();
|
||||
_renderEngine->postSynchronizationPreDraw();
|
||||
|
||||
if (_isMaster && _gui->isEnabled() && _windowWrapper->isRegularRendering()) {
|
||||
@@ -639,116 +650,116 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
|
||||
double dt = _windowWrapper->averageDeltaTime();
|
||||
|
||||
_gui->startFrame(static_cast<float>(dt), glm::vec2(drawBufferResolution), mousePosition, mouseButtons);
|
||||
}
|
||||
_gui->startFrame(static_cast<float>(dt), glm::vec2(drawBufferResolution), mousePosition, mouseButtons);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) {
|
||||
_renderEngine->render(projectionMatrix, viewMatrix);
|
||||
|
||||
if (_isMaster && _windowWrapper->isRegularRendering()) {
|
||||
if (_isMaster && _windowWrapper->isRegularRendering()) {
|
||||
if (_console->isVisible())
|
||||
_console->render();
|
||||
if (_gui->isEnabled())
|
||||
_gui->endFrame();
|
||||
}
|
||||
_console->render();
|
||||
if (_gui->isEnabled())
|
||||
_gui->endFrame();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postDraw() {
|
||||
_renderEngine->postDraw();
|
||||
_renderEngine->postDraw();
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction action) {
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
bool isConsumed = _gui->keyCallback(key, mod, action);
|
||||
if (isConsumed)
|
||||
return;
|
||||
}
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
bool isConsumed = _gui->keyCallback(key, mod, action);
|
||||
if (isConsumed)
|
||||
return;
|
||||
}
|
||||
|
||||
if (key == _console->commandInputButton() && (action == KeyAction::Press || action == KeyAction::Repeat))
|
||||
_console->toggleVisibility();
|
||||
_console->toggleVisibility();
|
||||
|
||||
if (!_console->isVisible()) {
|
||||
_interactionHandler->keyboardCallback(key, mod, action);
|
||||
}
|
||||
else {
|
||||
_console->keyboardCallback(key, mod, action);
|
||||
}
|
||||
}
|
||||
if (!_console->isVisible()) {
|
||||
_interactionHandler->keyboardCallback(key, mod, action);
|
||||
}
|
||||
else {
|
||||
_console->keyboardCallback(key, mod, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::charCallback(unsigned int codepoint, KeyModifier modifier) {
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->charCallback(codepoint, modifier);
|
||||
if (isConsumed)
|
||||
return;
|
||||
}
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->charCallback(codepoint, modifier);
|
||||
if (isConsumed)
|
||||
return;
|
||||
}
|
||||
|
||||
if (_console->isVisible()) {
|
||||
_console->charCallback(codepoint, modifier);
|
||||
}
|
||||
}
|
||||
if (_console->isVisible()) {
|
||||
_console->charCallback(codepoint, modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mouseButtonCallback(MouseButton button, MouseAction action) {
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->mouseButtonCallback(button, action);
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->mouseButtonCallback(button, action);
|
||||
if (isConsumed && action != MouseAction::Release)
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_interactionHandler->mouseButtonCallback(button, action);
|
||||
}
|
||||
_interactionHandler->mouseButtonCallback(button, action);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mousePositionCallback(double x, double y) {
|
||||
if (_isMaster) {
|
||||
_interactionHandler->mousePositionCallback(x, y);
|
||||
}
|
||||
if (_isMaster) {
|
||||
_interactionHandler->mousePositionCallback(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mouseScrollWheelCallback(double pos) {
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->mouseWheelCallback(pos);
|
||||
if (isConsumed)
|
||||
return;
|
||||
}
|
||||
if (_isMaster) {
|
||||
if (_gui->isEnabled()) {
|
||||
const bool isConsumed = _gui->mouseWheelCallback(pos);
|
||||
if (isConsumed)
|
||||
return;
|
||||
}
|
||||
|
||||
_interactionHandler->mouseScrollWheelCallback(pos);
|
||||
}
|
||||
_interactionHandler->mouseScrollWheelCallback(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::encode() {
|
||||
if (_syncBuffer) {
|
||||
Time::ref().serialize(_syncBuffer.get());
|
||||
_scriptEngine->serialize(_syncBuffer.get());
|
||||
_renderEngine->serialize(_syncBuffer.get());
|
||||
|
||||
_syncBuffer->write();
|
||||
}
|
||||
if (_syncBuffer) {
|
||||
Time::ref().serialize(_syncBuffer.get());
|
||||
_scriptEngine->serialize(_syncBuffer.get());
|
||||
_renderEngine->serialize(_syncBuffer.get());
|
||||
|
||||
_syncBuffer->write();
|
||||
}
|
||||
_networkEngine->publishStatusMessage();
|
||||
_networkEngine->sendMessages();
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::decode() {
|
||||
if (_syncBuffer) {
|
||||
_syncBuffer->read();
|
||||
if (_syncBuffer) {
|
||||
_syncBuffer->read();
|
||||
|
||||
Time::ref().deserialize(_syncBuffer.get());
|
||||
_scriptEngine->deserialize(_syncBuffer.get());
|
||||
_renderEngine->deserialize(_syncBuffer.get());
|
||||
}
|
||||
Time::ref().deserialize(_syncBuffer.get());
|
||||
_scriptEngine->deserialize(_syncBuffer.get());
|
||||
_renderEngine->deserialize(_syncBuffer.get());
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::externalControlCallback(const char* receivedChars, int size,
|
||||
int clientId)
|
||||
{
|
||||
if (size == 0)
|
||||
return;
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
_networkEngine->handleMessage(std::string(receivedChars, size));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user