Added an initial loading screen
This commit is contained in:
parent
84cb69e127
commit
20c03f84b7
11 changed files with 64 additions and 8 deletions
|
@ -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();
|
||||
|
|
|
@ -32,6 +32,7 @@ private:
|
|||
double getSpeedFactor(QInputEvent *event);
|
||||
|
||||
private:
|
||||
int delayed;
|
||||
bool initialized;
|
||||
bool resized;
|
||||
MainModelerWindow *window;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue