paysages : Waiting message when explorer loads the scene.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@513 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2013-01-31 14:02:17 +00:00 committed by ThunderK
parent e1514fae78
commit cc46102f9f
4 changed files with 44 additions and 29 deletions

1
TODO
View file

@ -24,7 +24,6 @@ Technology Preview 2 :
- Fix rendering when inside a cloud layer, with other upper or lower layers.
- Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)).
- Top-down previews and explorer renderings should be camera independant.
- Explorer should have a waiting message while init.
- Sun radius is too small.
Technlogy Preview 3 :

View file

@ -20,7 +20,7 @@ DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool c
panel = new QWidget(this);
panel->setLayout(new QVBoxLayout());
panel->setMaximumWidth(230);
panel->layout()->addWidget(new QLabel(tr("COMMANDS\n\nLeft click : Look around\nRight click : Pan (adjust framing)\nWheel : Move forward/backward\nHold SHIFT : Faster\nHold CTRL : Slower"), panel));
button = new QPushButton(tr("Reset camera"), panel);

View file

@ -73,8 +73,31 @@ WidgetExplorer::WidgetExplorer(QWidget *parent, CameraDefinition* camera):
_renderer->customData[3] = &_water;
_renderer->applyTextures = _applyTextures;
_inited = false;
_updated = false;
_average_frame_time = 0.05;
_quality = 3;
_last_mouse_x = 0;
_last_mouse_y = 0;
startTimer(500);
}
WidgetExplorer::~WidgetExplorer()
{
stopRendering();
for (int i = 0; i < _chunks.count(); i++)
{
delete _chunks[i];
}
waterDeleteDefinition(&_water);
rendererDelete(_renderer);
}
void WidgetExplorer::startRendering()
{
// Add terrain
int chunks = 20;
double size = 200.0;
@ -98,31 +121,8 @@ WidgetExplorer::WidgetExplorer(QWidget *parent, CameraDefinition* camera):
_updateQueue.append(chunk);
}
startThreads();
startTimer(500);
_average_frame_time = 0.05;
_quality = 3;
_last_mouse_x = 0;
_last_mouse_y = 0;
}
WidgetExplorer::~WidgetExplorer()
{
stopThreads();
for (int i = 0; i < _chunks.count(); i++)
{
delete _chunks[i];
}
waterDeleteDefinition(&_water);
rendererDelete(_renderer);
}
void WidgetExplorer::startThreads()
{
// Start rendering workers
int nbcore;
_alive = true;
nbcore = QThread::idealThreadCount();
@ -141,7 +141,7 @@ void WidgetExplorer::startThreads()
}
}
void WidgetExplorer::stopThreads()
void WidgetExplorer::stopRendering()
{
for (int i = 0; i < _threads.count(); i++)
{
@ -333,6 +333,12 @@ void WidgetExplorer::wheelEvent(QWheelEvent* event)
void WidgetExplorer::timerEvent(QTimerEvent*)
{
if (!_inited)
{
_inited = true;
startRendering();
}
if (_updated)
{
_updated = false;
@ -435,6 +441,15 @@ void WidgetExplorer::paintGL()
_quality++;
}
// Messages
if (!_inited)
{
glColor3f(0.0, 0.0, 0.0);
renderText(6, height() - 10, tr("Please wait while loading scene..."));
glColor3f(1.0, 1.0, 1.0);
renderText(5, height() - 9, tr("Please wait while loading scene..."));
}
while ((error_code = glGetError()) != GL_NO_ERROR)
{
logDebug(QString("[OpenGL] ERROR : ") + (const char*)gluErrorString(error_code));

View file

@ -33,13 +33,14 @@ protected:
void paintGL();
private:
void startThreads();
void stopThreads();
void startRendering();
void stopRendering();
CameraDefinition _current_camera;
CameraDefinition* _base_camera;
Renderer* _renderer;
bool _inited;
bool _updated;
QVector<BaseExplorerChunk*> _chunks;