paysages : Fixed some crash when starting renders.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@487 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-12-24 14:13:19 +00:00 committed by ThunderK
parent a50b0a25c2
commit 67eadf9048
5 changed files with 37 additions and 28 deletions

View file

@ -3,10 +3,10 @@
BaseExplorerChunk::BaseExplorerChunk(Renderer* renderer)
{
_renderer = renderer;
priority = 0.0;
_reset_needed = false;
_texture = new QImage(1, 1, QImage::Format_ARGB32);
_texture_id = 0;
_texture_changed = false;
@ -24,7 +24,7 @@ BaseExplorerChunk::~BaseExplorerChunk()
bool BaseExplorerChunk::maintain()
{
bool subchanged;
_lock_data.lock();
if (_reset_needed)
{
@ -33,9 +33,9 @@ bool BaseExplorerChunk::maintain()
onResetEvent();
}
_lock_data.unlock();
subchanged = onMaintainEvent();
// Improve texture resolution
if (_texture_current_size < _texture_max_size)
{
@ -60,7 +60,7 @@ bool BaseExplorerChunk::maintain()
_texture_current_size = new_texture_size;
_texture_changed = true;
_lock_data.unlock();
return true;
}
else
@ -108,7 +108,7 @@ void BaseExplorerChunk::render(QGLWidget* widget)
glBindTexture(GL_TEXTURE_2D, _texture_id);
}
_lock_data.unlock();
// Delegate poly rendering to subclass
onRenderEvent(widget);
}
@ -123,7 +123,7 @@ void BaseExplorerChunk::setMaxTextureSize(int size)
_texture_max_size = size;
}
void BaseExplorerChunk::onCameraEvent(CameraDefinition* camera)
void BaseExplorerChunk::onCameraEvent(CameraDefinition*)
{
}
@ -136,16 +136,16 @@ bool BaseExplorerChunk::onMaintainEvent()
return false;
}
void BaseExplorerChunk::onRenderEvent(QGLWidget* widget)
void BaseExplorerChunk::onRenderEvent(QGLWidget*)
{
}
double BaseExplorerChunk::getDisplayedSizeHint(CameraDefinition* camera)
double BaseExplorerChunk::getDisplayedSizeHint(CameraDefinition*)
{
return 0.0;
}
Color BaseExplorerChunk::getTextureColor(double x, double y)
Color BaseExplorerChunk::getTextureColor(double, double)
{
return COLOR_TRANSPARENT;
}

View file

@ -21,18 +21,18 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad
QWidget* form;
QGridLayout* form_layout;
QLabel* label;
_base = gradation;
_current = colorGradationCreate();
colorGradationCopy(_base, _current);
setLayout(new QVBoxLayout());
form = new QWidget(this);
form_layout = new QGridLayout();
form->setLayout(form_layout);
layout()->addWidget(form);
label = new QLabel(tr("This is the curve editor for color components.\nClick on a component preview below to edit it.\nClick on points and drag them to move them.\nDouble click to add a new point.\nRight click on a point to delete it."), form);
label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
label->setMinimumWidth(150);
@ -94,11 +94,11 @@ DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* grad
_preview_final->setMaximumHeight(60);
_preview_final->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
form_layout->addWidget(_preview_final, 4, 0);
buttons = new QWidget(this);
layout()->addWidget(buttons);
buttons->setLayout(new QHBoxLayout());
_button_accept = new QPushButton(tr("Validate"), buttons);
buttons->layout()->addWidget(_button_accept);
QObject::connect(_button_accept, SIGNAL(clicked()), this, SLOT(accept()));
@ -137,7 +137,7 @@ bool DialogColorGradation::getGradation(QWidget* parent, ColorGradation* gradati
return (result != 0) ? true : false;
}
void DialogColorGradation::closeEvent(QCloseEvent* e)
void DialogColorGradation::closeEvent(QCloseEvent*)
{
reject();
}
@ -182,10 +182,10 @@ void DialogColorGradation::selectBlue()
void DialogColorGradation::updateColors()
{
Curve* curve;
curve = curveCreate();
_curve_editor->getCurve(curve);
switch (_selected)
{
case 0:
@ -209,7 +209,7 @@ void DialogColorGradation::updateColors()
;
}
_preview_final->update();
curveDelete(curve);
}

View file

@ -15,9 +15,12 @@ static DialogRender* _current_dialog;
static void _renderStart(int width, int height, Color background)
{
_current_dialog->pixbuf_lock->lock();
delete _current_dialog->pixbuf;
_current_dialog->pixbuf = new QImage(width, height, QImage::Format_ARGB32);
_current_dialog->pixbuf->fill(colorToQColor(background).rgb());
_current_dialog->pixbuf_lock->unlock();
_current_dialog->tellRenderSize(width, height);
}
@ -61,18 +64,21 @@ public:
void paintEvent(QPaintEvent*)
{
QPainter painter(this);
_current_dialog->pixbuf_lock->lock();
painter.drawImage(0, 0, *_current_dialog->pixbuf);
_current_dialog->pixbuf_lock->unlock();
}
};
DialogRender::DialogRender(QWidget *parent, Renderer* renderer):
QDialog(parent, Qt::WindowTitleHint | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint)
{
pixbuf_lock = new QMutex();
pixbuf = new QImage(1, 1, QImage::Format_ARGB32);
_current_dialog = this;
_render_thread = NULL;
_renderer = renderer;
setModal(true);
setWindowTitle(tr("Paysages 3D - Render"));
setLayout(new QVBoxLayout());
@ -82,21 +88,21 @@ DialogRender::DialogRender(QWidget *parent, Renderer* renderer):
area = new RenderArea(_scroll);
_scroll->setWidget(area);
layout()->addWidget(_scroll);
_info = new QWidget(this);
_info->setLayout(new QHBoxLayout());
layout()->addWidget(_info);
_timer = new QLabel(QString("0:00.00"), _info);
_info->layout()->addWidget(_timer);
_progress = new QProgressBar(_info);
_progress->setMaximumHeight(12);
_progress->setMinimum(0);
_progress->setMaximum(1000);
_progress->setValue(0);
_info->layout()->addWidget(_progress);
connect(this, SIGNAL(renderSizeChanged(int, int)), this, SLOT(applyRenderSize(int, int)));
connect(this, SIGNAL(progressChanged(double)), this, SLOT(applyProgress(double)));
}
@ -111,6 +117,7 @@ DialogRender::~DialogRender()
delete _render_thread;
}
delete pixbuf;
delete pixbuf_lock;
}
void DialogRender::tellRenderSize(int width, int height)
@ -126,7 +133,7 @@ void DialogRender::tellProgressChange(double value)
void DialogRender::startRender(RenderParams params)
{
_started = time(NULL);
//applyRenderSize(params.width, params.height);
rendererSetPreviewCallbacks(_renderer, _renderStart, _renderDraw, _renderUpdate);

View file

@ -7,6 +7,7 @@
#include <QProgressBar>
#include <QScrollArea>
#include <QLabel>
#include <QMutex>
#include "../lib_paysages/renderer.h"
class DialogRender : public QDialog
@ -22,12 +23,13 @@ public:
void loadLastRender();
QImage* pixbuf;
QMutex* pixbuf_lock;
QWidget* area;
private slots:
void applyRenderSize(int width, int height);
void applyProgress(double value);
signals:
void renderSizeChanged(int width, int height);
void progressChanged(double value);

View file

@ -91,7 +91,7 @@ private:
lightingGetStatus((LightingDefinition*)renderer->customData[2], renderer, location, status);
}
static Color _applyAerialPerspective(Renderer* renderer, Vector3 location, Color base)
static Color _applyAerialPerspective(Renderer*, Vector3, Color base)
{
return base;
}