From df7041a82b260053fc4e34bf468c7bfc3830ed7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Mon, 2 Apr 2012 19:10:34 +0000 Subject: [PATCH] paysages: Restored "show last render" feature. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@282 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 1 - gui_qt/dialogrender.cpp | 38 +++++++++++++++++++++++++++++--------- gui_qt/dialogrender.h | 1 - i18n/paysages_fr.ts | 2 +- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index b1e840e..1a0682c 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ - Implement scaling and scrolling on previews. -- Improve color gradation dialog (with curve editor ?). - Replace FILE* by a custom type for Save and Load. - Water and terrain LOD moves with the camera, fix it like in the wanderer. - Restore render progress. diff --git a/gui_qt/dialogrender.cpp b/gui_qt/dialogrender.cpp index 53edaa8..dbf81af 100644 --- a/gui_qt/dialogrender.cpp +++ b/gui_qt/dialogrender.cpp @@ -10,6 +10,8 @@ #include "../lib_paysages/auto.h" static DialogRender* _current_dialog; +static Renderer _renderer; +static bool _renderer_inited = false; static void _renderStart(int width, int height, Color background) { @@ -72,7 +74,6 @@ DialogRender::DialogRender(QWidget *parent): pixbuf = new QImage(1, 1, QImage::Format_ARGB32); _current_dialog = this; render_thread = NULL; - renderer = sceneryCreateStandardRenderer(); setModal(true); setWindowTitle(tr("Paysages 3D - Render")); @@ -96,14 +97,11 @@ DialogRender::~DialogRender() { if (render_thread) { - rendererInterrupt(&renderer); + rendererInterrupt(&_renderer); render_thread->wait(); - rendererSetPreviewCallbacks(&renderer, NULL, NULL, NULL); - delete render_thread; } - rendererDelete(&renderer); delete pixbuf; } @@ -115,10 +113,17 @@ void DialogRender::startRender(int quality, int width, int height) area->setMaximumSize(width, height); area->resize(width, height); scroll->setMinimumSize(width > 800 ? 850 : width + 50, height > 600 ? 650 : height + 50); - - rendererSetPreviewCallbacks(&renderer, _renderStart, _renderDraw, _renderUpdate); - render_thread = new RenderThread(&renderer, width, height, quality); + if (_renderer_inited) + { + rendererDelete(&_renderer); + } + _renderer = sceneryCreateStandardRenderer(); + _renderer_inited = true; + + rendererSetPreviewCallbacks(&_renderer, _renderStart, _renderDraw, _renderUpdate); + + render_thread = new RenderThread(&_renderer, width, height, quality); render_thread->start(); exec(); @@ -126,8 +131,23 @@ void DialogRender::startRender(int quality, int width, int height) void DialogRender::loadLastRender() { + int width, height; + progress->hide(); - //renderSetPreviewCallbacks(_renderStart, _renderDraw, _renderUpdate); + if (_renderer_inited) + { + width = _renderer.render_width; + height = _renderer.render_height; + + delete pixbuf; + pixbuf = new QImage(width, height, QImage::Format_ARGB32); + area->setMinimumSize(width, height); + area->setMaximumSize(width, height); + area->resize(width, height); + scroll->setMinimumSize(width > 800 ? 850 : width + 50, height > 600 ? 650 : height + 50); + + rendererSetPreviewCallbacks(&_renderer, _renderStart, _renderDraw, _renderUpdate); + } exec(); } diff --git a/gui_qt/dialogrender.h b/gui_qt/dialogrender.h index cee80c0..9e48ab8 100644 --- a/gui_qt/dialogrender.h +++ b/gui_qt/dialogrender.h @@ -25,7 +25,6 @@ public: private: QThread* render_thread; - Renderer renderer; }; #endif // _PAYSAGES_QT_DIALOGRENDER_H_ diff --git a/i18n/paysages_fr.ts b/i18n/paysages_fr.ts index b10e705..4354a1d 100644 --- a/i18n/paysages_fr.ts +++ b/i18n/paysages_fr.ts @@ -156,7 +156,7 @@ Cliquez avec le bouton droit sur un point pour le supprimer. DialogRender - + Paysages 3D - Render Paysages 3D - Rendu