diff --git a/src/interface/modeler/quickapp/OpenGLView.cpp b/src/interface/modeler/quickapp/OpenGLView.cpp index 04f47a5..fa38e4d 100644 --- a/src/interface/modeler/quickapp/OpenGLView.cpp +++ b/src/interface/modeler/quickapp/OpenGLView.cpp @@ -12,6 +12,7 @@ OpenGLView::OpenGLView(QQuickItem *parent) : initialized = false; window = NULL; renderer = NULL; + delayed = 10; setAcceptedMouseButtons(Qt::AllButtons); setAcceptHoverEvents(true); @@ -44,6 +45,11 @@ void OpenGLView::handleWindowChanged(QQuickWindow *win) void OpenGLView::paint() { + if (delayed > 1) + { + return; + } + if (not initialized or not renderer) { renderer->initialize(); @@ -132,6 +138,19 @@ void OpenGLView::hoverMoveEvent(QHoverEvent *event) void OpenGLView::timerEvent(QTimerEvent *) { + if (delayed > 1) + { + delayed--; + } + else if (delayed == 1) + { + if (renderer->isDisplayed()) + { + delayed = 0; + window->setState("Init"); + } + } + if (window) { window->update(); diff --git a/src/interface/modeler/quickapp/OpenGLView.h b/src/interface/modeler/quickapp/OpenGLView.h index f007004..8c8197b 100644 --- a/src/interface/modeler/quickapp/OpenGLView.h +++ b/src/interface/modeler/quickapp/OpenGLView.h @@ -32,6 +32,7 @@ private: double getSpeedFactor(QInputEvent *event); private: + int delayed; bool initialized; bool resized; MainModelerWindow *window; diff --git a/src/interface/modeler/quickapp/qml/main.qml b/src/interface/modeler/quickapp/qml/main.qml index 2338c5c..969f138 100644 --- a/src/interface/modeler/quickapp/qml/main.qml +++ b/src/interface/modeler/quickapp/qml/main.qml @@ -3,7 +3,7 @@ import Paysages 1.0 OpenGLView { id: main_ui - state: "Init" + state: "Loading" property string previous_state width: 1280 @@ -157,6 +157,19 @@ OpenGLView { anchors.fill: parent } + BaseRectangle { + id: loader + enabled: false + anchors.fill: parent + color: "#222429" + + Text { + color: "#dddddd" + text: "Welcome to Paysages 3D..." + anchors.centerIn: parent + } + } + onStateChanged: { if (state != "Render Dialog") { @@ -165,6 +178,14 @@ OpenGLView { } states: [ + State { + name: "Loading" + + PropertyChanges { + target: loader + enabled: true + } + }, State { name: "Water Mode" when: primary_toolbar.current === tool_water diff --git a/src/render/opengl/OpenGLPart.cpp b/src/render/opengl/OpenGLPart.cpp index fad4347..dd86727 100644 --- a/src/render/opengl/OpenGLPart.cpp +++ b/src/render/opengl/OpenGLPart.cpp @@ -30,7 +30,7 @@ void OpenGLPart::interrupt() OpenGLShaderProgram* OpenGLPart::createShader(QString name) { - OpenGLShaderProgram* program = new OpenGLShaderProgram(name, renderer); + OpenGLShaderProgram* program = new OpenGLShaderProgram(name.toStdString(), renderer); if (!shaders.contains(name)) { diff --git a/src/render/opengl/OpenGLRenderer.cpp b/src/render/opengl/OpenGLRenderer.cpp index 78a5f33..93a9b67 100644 --- a/src/render/opengl/OpenGLRenderer.cpp +++ b/src/render/opengl/OpenGLRenderer.cpp @@ -17,6 +17,7 @@ OpenGLRenderer::OpenGLRenderer(Scenery* scenery): { ready = false; paused = false; + displayed = false; vp_width = 1; vp_height = 1; @@ -160,6 +161,8 @@ void OpenGLRenderer::paint() { Logs::warning() << "[OpenGL] ERROR : " << error_code << std::endl; } + + displayed = true; } } diff --git a/src/render/opengl/OpenGLRenderer.h b/src/render/opengl/OpenGLRenderer.h index 265cca6..d40a4b4 100644 --- a/src/render/opengl/OpenGLRenderer.h +++ b/src/render/opengl/OpenGLRenderer.h @@ -22,6 +22,7 @@ public: inline OpenGLSkybox *getSkybox() const {return skybox;} inline OpenGLWater *getWater() const {return water;} inline OpenGLTerrain *getTerrain() const {return terrain;} + inline bool isDisplayed() const {return displayed;} void initialize(); void prepareOpenGLState(); @@ -75,6 +76,7 @@ private: private: bool ready; bool paused; + bool displayed; int vp_width; int vp_height; diff --git a/src/render/opengl/OpenGLShaderProgram.cpp b/src/render/opengl/OpenGLShaderProgram.cpp index a445207..014a885 100644 --- a/src/render/opengl/OpenGLShaderProgram.cpp +++ b/src/render/opengl/OpenGLShaderProgram.cpp @@ -11,7 +11,7 @@ #include "Color.h" #include "Logs.h" -OpenGLShaderProgram::OpenGLShaderProgram(QString name, OpenGLRenderer* renderer): +OpenGLShaderProgram::OpenGLShaderProgram(const std::string &name, OpenGLRenderer* renderer): renderer(renderer), name(name) { program = new QOpenGLShaderProgram(); @@ -57,11 +57,11 @@ void OpenGLShaderProgram::compile() if (not program->link()) { - qWarning() << "Error while compiling shader " << name << "\n" << program->log() << "\n"; + Logs::warning() << "Error while compiling shader " << name << std::endl << program->log().toStdString() << std::endl; } else if (program->log().length() > 0) { - qDebug() << "Shader " << name << " compilation output:\n" << program->log() << "\n"; + Logs::debug() << "Shader " << name << " compilation output:" << std::endl << program->log().toStdString() << std::endl; } } diff --git a/src/render/opengl/OpenGLShaderProgram.h b/src/render/opengl/OpenGLShaderProgram.h index 5caabf5..4ae814a 100644 --- a/src/render/opengl/OpenGLShaderProgram.h +++ b/src/render/opengl/OpenGLShaderProgram.h @@ -13,7 +13,7 @@ namespace opengl { class OPENGLSHARED_EXPORT OpenGLShaderProgram { public: - OpenGLShaderProgram(QString name, OpenGLRenderer* renderer); + OpenGLShaderProgram(const std::string &name, OpenGLRenderer* renderer); ~OpenGLShaderProgram(); void addVertexSource(QString path); @@ -38,7 +38,7 @@ private: OpenGLRenderer* renderer; - QString name; + std::string name; QOpenGLShaderProgram* program; OpenGLFunctions* functions; diff --git a/src/render/opengl/OpenGLSkybox.cpp b/src/render/opengl/OpenGLSkybox.cpp index 454e584..a510f8a 100644 --- a/src/render/opengl/OpenGLSkybox.cpp +++ b/src/render/opengl/OpenGLSkybox.cpp @@ -67,7 +67,7 @@ void OpenGLSkybox::render() { program->drawTriangleStrip(vertices, 14); } -#include "Logs.h" + void OpenGLSkybox::nodeChanged(const DefinitionNode *node, const DefinitionDiff *) { if (node->getPath() == "/atmosphere/daytime") diff --git a/src/system/Logs.cpp b/src/system/Logs.cpp index 8da1973..097bd2e 100644 --- a/src/system/Logs.cpp +++ b/src/system/Logs.cpp @@ -1,5 +1,7 @@ #include "Logs.h" +#include "Time.h" + static std::ostream NULL_STREAM(0); static bool enabled = true; @@ -46,6 +48,11 @@ std::ostream &Logs::error() } } +void Logs::debugTimestamp(const std::string &message) +{ + debug() << Time::getRelativeTimeMs() << " - " << message << std::endl; +} + void Logs::disable() { enabled = false; diff --git a/src/system/Logs.h b/src/system/Logs.h index 3c5efd0..bae7355 100644 --- a/src/system/Logs.h +++ b/src/system/Logs.h @@ -18,6 +18,9 @@ public: static std::ostream &warning(); static std::ostream &error(); + // Log a timestamp on the debug output + static void debugTimestamp(const std::string &message); + // Disable all logs from now on static void disable(); };