mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Remove runTime from OpenSpaceEngine and place in WindowWrapper instead
This commit is contained in:
@@ -313,7 +313,6 @@ void mainInitFunc() {
|
||||
|
||||
void mainPreSyncFunc() {
|
||||
LTRACE("main::mainPreSyncFunc(begin)");
|
||||
OsEng.setRunTime(sgct::Engine::getTime());
|
||||
OsEng.preSynchronization();
|
||||
LTRACE("main::mainPreSyncFunc(end)");
|
||||
}
|
||||
|
||||
@@ -79,9 +79,6 @@ public:
|
||||
static OpenSpaceEngine& ref();
|
||||
static bool isCreated();
|
||||
|
||||
double runTime();
|
||||
void setRunTime(double t);
|
||||
|
||||
// callbacks
|
||||
void initialize();
|
||||
void initializeGL();
|
||||
@@ -234,8 +231,6 @@ private:
|
||||
std::vector<std::function<bool (double, double)>> mouseScrollWheel;
|
||||
} _moduleCallbacks;
|
||||
|
||||
double _runTime;
|
||||
|
||||
// Structure that is responsible for the delayed shutdown of the application
|
||||
struct {
|
||||
// Whether the application is currently in shutdown mode (i.e. counting down the
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
|
||||
double averageDeltaTime() const override;
|
||||
double deltaTime() const override;
|
||||
double applicationTime() const override;
|
||||
glm::vec2 mousePosition() const override;
|
||||
uint32_t mouseButtons(int maxNumber) const override;
|
||||
glm::ivec2 currentWindowSize() const override;
|
||||
|
||||
@@ -106,6 +106,13 @@ public:
|
||||
*/
|
||||
virtual double deltaTime() const;
|
||||
|
||||
/**
|
||||
* Returns the time that has passed (in seconds) since application start
|
||||
* \return The time that has passed (in seconds) since application start
|
||||
* @return [description]
|
||||
*/
|
||||
virtual double applicationTime() const;
|
||||
|
||||
/**
|
||||
* Returns the location of the mouse cursor in pixel screen coordinates. On default,
|
||||
* this method returns <code>0,0</code>.
|
||||
|
||||
@@ -165,7 +165,6 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
|
||||
}
|
||||
, _scheduledSceneSwitch(false)
|
||||
, _scenePath("")
|
||||
, _runTime(0.0)
|
||||
, _shutdown({false, 0.f, 0.f})
|
||||
, _isFirstRenderingFirstFrame(true)
|
||||
{
|
||||
@@ -321,23 +320,17 @@ void OpenSpaceEngine::create(int argc, char** argv,
|
||||
ConfigurationManager::KeyPerSceneCache
|
||||
);
|
||||
std::string cacheFolder = absPath("${CACHE}");
|
||||
if (hasCacheCommandline) {
|
||||
cacheFolder = commandlineArgumentPlaceholders.cacheFolder;
|
||||
// @CLEANUP: Why is this commented out? ---abock
|
||||
//FileSys.registerPathToken(
|
||||
// "${CACHE}",
|
||||
// commandlineArgumentPlaceholders.cacheFolder,
|
||||
// ghoul::filesystem::FileSystem::Override::Yes
|
||||
//);
|
||||
}
|
||||
if (hasCacheConfiguration) {
|
||||
std::string scene = _engine->configurationManager().value<std::string>(
|
||||
ConfigurationManager::KeyConfigScene
|
||||
);
|
||||
cacheFolder += "-" + ghoul::filesystem::File(scene).baseName();
|
||||
}
|
||||
|
||||
if (hasCacheCommandline || hasCacheConfiguration) {
|
||||
if (hasCacheCommandline) {
|
||||
cacheFolder = commandlineArgumentPlaceholders.cacheFolder;
|
||||
}
|
||||
if (hasCacheConfiguration) {
|
||||
std::string scene = _engine->configurationManager().value<std::string>(
|
||||
ConfigurationManager::KeyConfigScene
|
||||
);
|
||||
cacheFolder += "-" + ghoul::filesystem::File(scene).baseName();
|
||||
}
|
||||
|
||||
LINFO("Old cache: " << absPath("${CACHE}"));
|
||||
LINFO("New cache: " << cacheFolder);
|
||||
FileSys.registerPathToken(
|
||||
@@ -348,8 +341,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
|
||||
}
|
||||
|
||||
// Create directories that doesn't exist
|
||||
auto tokens = FileSys.tokens();
|
||||
for (const std::string& token : tokens) {
|
||||
for (const std::string& token : FileSys.tokens()) {
|
||||
if (!FileSys.directoryExists(token)) {
|
||||
std::string p = absPath(token);
|
||||
FileSys.createDirectory(p, ghoul::filesystem::FileSystem::Recursive::Yes);
|
||||
@@ -378,9 +370,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
|
||||
}
|
||||
|
||||
// Create the cachemanager
|
||||
FileSys.createCacheManager(
|
||||
absPath("${" + ConfigurationManager::KeyCache + "}"), CacheVersion
|
||||
);
|
||||
FileSys.createCacheManager(cacheFolder, CacheVersion);
|
||||
|
||||
// Register the provided shader directories
|
||||
ghoul::opengl::ShaderPreprocessor::addIncludePath(absPath("${SHADERS}"));
|
||||
@@ -446,7 +436,7 @@ void OpenSpaceEngine::initialize() {
|
||||
glbinding::Binding::useCurrentContext();
|
||||
glbinding::Binding::initialize();
|
||||
|
||||
// clear the screen so the user don't have to see old buffer contents from the
|
||||
// clear the screen so the user doesn't have to see old buffer contents from the
|
||||
// graphics card
|
||||
LDEBUG("Clearing all Windows");
|
||||
_windowWrapper->clearAllWindows(glm::vec4(0.f, 0.f, 0.f, 1.f));
|
||||
@@ -912,10 +902,11 @@ void OpenSpaceEngine::initializeGL() {
|
||||
}
|
||||
LTRACE("OpenSpaceEngine::initializeGL::Console::initialize(end)");
|
||||
|
||||
const std::string key = ConfigurationManager::KeyOpenGLDebugContext;
|
||||
if (_configurationManager->hasKey(key)) {
|
||||
if (_configurationManager->hasKey(ConfigurationManager::KeyOpenGLDebugContext)) {
|
||||
LTRACE("OpenSpaceEngine::initializeGL::DebugContext(begin)");
|
||||
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(key);
|
||||
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(
|
||||
ConfigurationManager::KeyOpenGLDebugContext
|
||||
);
|
||||
bool debug = dict.value<bool>(ConfigurationManager::PartActivate);
|
||||
|
||||
// Debug output is not available before 4.3
|
||||
@@ -935,7 +926,6 @@ void OpenSpaceEngine::initializeGL() {
|
||||
|
||||
setDebugOutput(DebugOutput(debug), SynchronousOutput(synchronous));
|
||||
|
||||
|
||||
if (dict.hasKey(ConfigurationManager::PartFilterIdentifier)) {
|
||||
ghoul::Dictionary filterDict = dict.value<ghoul::Dictionary>(
|
||||
ConfigurationManager::PartFilterIdentifier
|
||||
@@ -1112,20 +1102,9 @@ void OpenSpaceEngine::initializeGL() {
|
||||
|
||||
LINFO("Finished initializing OpenGL");
|
||||
|
||||
LINFO("IsUsingSwapGroups: " << _windowWrapper->isUsingSwapGroups());
|
||||
LINFO("IsSwapGroupMaster: " << _windowWrapper->isSwapGroupMaster());
|
||||
|
||||
LTRACE("OpenSpaceEngine::initializeGL(end)");
|
||||
}
|
||||
|
||||
double OpenSpaceEngine::runTime() {
|
||||
return _runTime;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::setRunTime(double d) {
|
||||
_runTime = d;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::preSynchronization() {
|
||||
LTRACE("OpenSpaceEngine::preSynchronization(begin)");
|
||||
FileSys.triggerFilesystemEvents();
|
||||
|
||||
@@ -64,7 +64,7 @@ SGCTWindowWrapper::SGCTWindowWrapper()
|
||||
setEyeSeparationDistance(_eyeSeparation);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void SGCTWindowWrapper::terminate() {
|
||||
sgct::Engine::instance()->terminate();
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void SGCTWindowWrapper::terminate() {
|
||||
void SGCTWindowWrapper::setBarrier(bool enabled) {
|
||||
sgct::SGCTWindow::setBarrier(enabled);
|
||||
}
|
||||
|
||||
|
||||
void SGCTWindowWrapper::setSynchronization(bool enabled) {
|
||||
sgct_core::ClusterManager::instance()->setUseIgnoreSync(enabled);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ void SGCTWindowWrapper::clearAllWindows(const glm::vec4& clearColor) {
|
||||
bool SGCTWindowWrapper::windowHasResized() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->isWindowResized();
|
||||
}
|
||||
|
||||
|
||||
double SGCTWindowWrapper::averageDeltaTime() const {
|
||||
return sgct::Engine::instance()->getAvgDt();
|
||||
}
|
||||
@@ -98,7 +98,11 @@ double SGCTWindowWrapper::averageDeltaTime() const {
|
||||
double SGCTWindowWrapper::deltaTime() const {
|
||||
return sgct::Engine::instance()->getDt();
|
||||
}
|
||||
|
||||
|
||||
double SGCTWindowWrapper::applicationTime() const {
|
||||
return sgct::Engine::getTime();
|
||||
}
|
||||
|
||||
glm::vec2 SGCTWindowWrapper::mousePosition() const {
|
||||
int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId();
|
||||
double posX, posY;
|
||||
@@ -157,7 +161,7 @@ glm::ivec2 SGCTWindowWrapper::currentDrawBufferResolution() const {
|
||||
}
|
||||
throw WindowWrapperException("No viewport available");
|
||||
}
|
||||
|
||||
|
||||
glm::vec2 SGCTWindowWrapper::dpiScaling() const {
|
||||
return glm::vec2(
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getXScale(),
|
||||
@@ -168,7 +172,7 @@ glm::vec2 SGCTWindowWrapper::dpiScaling() const {
|
||||
int SGCTWindowWrapper::currentNumberOfAaSamples() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfAASamples();
|
||||
}
|
||||
|
||||
|
||||
bool SGCTWindowWrapper::isRegularRendering() const {
|
||||
sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr();
|
||||
std::size_t nViewports = w->getNumberOfViewports();
|
||||
@@ -194,7 +198,7 @@ bool SGCTWindowWrapper::isGuiWindow() const {
|
||||
GuiWindowTag
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool SGCTWindowWrapper::isMaster() const {
|
||||
return sgct::Engine::instance()->isMaster();
|
||||
}
|
||||
@@ -206,7 +210,7 @@ bool SGCTWindowWrapper::isSwapGroupMaster() const {
|
||||
bool SGCTWindowWrapper::isUsingSwapGroups() const {
|
||||
return sgct::Engine::instance()->getCurrentWindowPtr()->isUsingSwapGroups();
|
||||
}
|
||||
|
||||
|
||||
glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
|
||||
return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix();
|
||||
}
|
||||
@@ -214,7 +218,7 @@ glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
|
||||
glm::mat4 SGCTWindowWrapper::modelMatrix() const {
|
||||
return sgct::Engine::instance()->getModelMatrix();
|
||||
}
|
||||
|
||||
|
||||
void SGCTWindowWrapper::setNearFarClippingPlane(float nearPlane, float farPlane) {
|
||||
sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane);
|
||||
}
|
||||
@@ -225,39 +229,33 @@ void SGCTWindowWrapper::setEyeSeparationDistance(float distance) {
|
||||
|
||||
glm::ivec4 SGCTWindowWrapper::viewportPixelCoordinates() const {
|
||||
int x1, xSize, y1, ySize;
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1,
|
||||
y1,
|
||||
xSize,
|
||||
ySize);
|
||||
sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(
|
||||
x1,
|
||||
y1,
|
||||
xSize,
|
||||
ySize
|
||||
);
|
||||
return glm::ivec4(x1, xSize, y1, ySize);
|
||||
}
|
||||
|
||||
|
||||
bool SGCTWindowWrapper::isExternalControlConnected() const {
|
||||
return sgct::Engine::instance()->isExternalControlConnected();
|
||||
}
|
||||
|
||||
|
||||
void SGCTWindowWrapper::sendMessageToExternalControl(const std::vector<char>& message) const {
|
||||
sgct::Engine::instance()->sendMessageToExternalControl(
|
||||
message.data(),
|
||||
static_cast<int>(message.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool SGCTWindowWrapper::isSimpleRendering() const {
|
||||
return (sgct::Engine::instance()->getCurrentRenderTarget() != sgct::Engine::NonLinearBuffer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SGCTWindowWrapper::takeScreenshot(bool applyWarping) const {
|
||||
sgct::SGCTSettings::instance()->setCaptureFromBackBuffer(applyWarping);
|
||||
sgct::Engine::instance()->takeScreenshot();
|
||||
}
|
||||
|
||||
//void forEachWindow(std::function<void (void)> function) {
|
||||
// size_t n = sgct::Engine::instance()->getNumberOfWindows();
|
||||
// for (size_t i = 0; i < n; ++i)
|
||||
// function();
|
||||
//}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -92,19 +92,23 @@ double WindowWrapper::averageDeltaTime() const {
|
||||
double WindowWrapper::deltaTime() const {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
double WindowWrapper::applicationTime() const {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
glm::vec2 WindowWrapper::mousePosition() const {
|
||||
return glm::vec2(0.f);
|
||||
}
|
||||
|
||||
|
||||
uint32_t WindowWrapper::mouseButtons(int) const {
|
||||
return uint32_t(0);
|
||||
}
|
||||
|
||||
|
||||
glm::ivec2 WindowWrapper::currentWindowSize() const {
|
||||
return glm::ivec2(0);
|
||||
}
|
||||
|
||||
|
||||
glm::ivec2 WindowWrapper::currentWindowResolution() const {
|
||||
return currentWindowSize();
|
||||
}
|
||||
@@ -153,11 +157,11 @@ glm::mat4 WindowWrapper::viewProjectionMatrix() const {
|
||||
glm::mat4 WindowWrapper::modelMatrix() const {
|
||||
return glm::mat4(1.f);
|
||||
}
|
||||
|
||||
|
||||
void WindowWrapper::setNearFarClippingPlane(float, float) {}
|
||||
|
||||
void WindowWrapper::setEyeSeparationDistance(float) {}
|
||||
|
||||
|
||||
glm::ivec4 WindowWrapper::viewportPixelCoordinates() const {
|
||||
return glm::ivec4(
|
||||
0,
|
||||
@@ -166,19 +170,19 @@ glm::ivec4 WindowWrapper::viewportPixelCoordinates() const {
|
||||
currentWindowResolution().y
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool WindowWrapper::isExternalControlConnected() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void WindowWrapper::sendMessageToExternalControl(const std::vector<char>&) const {
|
||||
}
|
||||
|
||||
|
||||
bool WindowWrapper::isSimpleRendering() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void WindowWrapper::takeScreenshot(bool) const {}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <openspace/interaction/keyframenavigator.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/util/camera.h>
|
||||
@@ -37,7 +38,7 @@
|
||||
namespace openspace::interaction {
|
||||
|
||||
void KeyframeNavigator::updateCamera(Camera& camera) {
|
||||
double now = OsEng.runTime();
|
||||
double now = OsEng.windowWrapper().applicationTime();
|
||||
|
||||
if (_cameraPoseTimeline.nKeyframes() == 0) {
|
||||
return;
|
||||
|
||||
@@ -587,7 +587,7 @@ void ParallelConnection::initializationMessageReceived(){
|
||||
double ParallelConnection::calculateBufferedKeyframeTime(double originalTime) {
|
||||
std::lock_guard<std::mutex> latencyLock(_latencyMutex);
|
||||
|
||||
double timeDiff = OsEng.runTime() - originalTime;
|
||||
double timeDiff = OsEng.windowWrapper().applicationTime() - originalTime;
|
||||
if (_latencyDiffs.size() == 0) {
|
||||
_initialTimeDiff = timeDiff;
|
||||
}
|
||||
@@ -1084,7 +1084,7 @@ void ParallelConnection::preSynchronization() {
|
||||
if (OsEng.timeManager().time().timeJumped()) {
|
||||
_timeJumped = true;
|
||||
}
|
||||
double now = OsEng.runTime();
|
||||
double now = OsEng.windowWrapper().applicationTime();
|
||||
|
||||
if (_lastCameraKeyframeTimestamp + _cameraKeyframeInterval < now) {
|
||||
sendCameraKeyframe();
|
||||
@@ -1156,7 +1156,7 @@ void ParallelConnection::sendCameraKeyframe() {
|
||||
kf._focusNode = focusNode->name();
|
||||
|
||||
// Timestamp as current runtime of OpenSpace instance
|
||||
kf._timestamp = OsEng.runTime();
|
||||
kf._timestamp = OsEng.windowWrapper().applicationTime();
|
||||
|
||||
// Create a buffer for the keyframe
|
||||
std::vector<char> buffer;
|
||||
@@ -1180,7 +1180,7 @@ void ParallelConnection::sendTimeKeyframe() {
|
||||
kf._time = time.j2000Seconds();
|
||||
|
||||
// Timestamp as current runtime of OpenSpace instance
|
||||
kf._timestamp = OsEng.runTime();
|
||||
kf._timestamp = OsEng.windowWrapper().applicationTime();
|
||||
|
||||
// Create a buffer for the keyframe
|
||||
std::vector<char> buffer;
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/util/timemanager.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/network/parallelconnection.h>
|
||||
#include <openspace/util/timeline.h>
|
||||
|
||||
@@ -45,7 +47,7 @@ void TimeManager::preSynchronization(double dt) {
|
||||
}
|
||||
|
||||
void TimeManager::consumeKeyframes(double dt) {
|
||||
double now = OsEng.runTime();
|
||||
double now = OsEng.windowWrapper().applicationTime();
|
||||
|
||||
const std::deque<Keyframe<Time>>& keyframes = _timeline.keyframes();
|
||||
auto firstFutureKeyframe = std::lower_bound(keyframes.begin(), keyframes.end(), now, &compareKeyframeTimeWithTime);
|
||||
|
||||
Reference in New Issue
Block a user