aboutsummaryrefslogtreecommitdiff
path: root/app/draw.cpp
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-08-13 20:06:29 +0200
committerJulian T <julian@jtle.dk>2020-08-13 20:06:29 +0200
commit5b0b916c561f602723b9ae80f5462a7939b652a1 (patch)
tree6ee419f0dd1649b2c329585551f06a555a631db8 /app/draw.cpp
parent690b72664ca8d471f5c117f6ed87aeae2de0a208 (diff)
Pathtracing working with defuse and emissive lighting
Diffstat (limited to 'app/draw.cpp')
-rw-r--r--app/draw.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/draw.cpp b/app/draw.cpp
index 2f3a947..469b469 100644
--- a/app/draw.cpp
+++ b/app/draw.cpp
@@ -3,15 +3,20 @@
#include <qglobal.h>
#include <qimage.h>
#include <qrgb.h>
+#include <qtimer.h>
#include <qwindowdefs.h>
#include <iostream>
-DrawWidget::DrawWidget(unsigned width, unsigned height) : QWidget() {
+DrawWidget::DrawWidget(unsigned width, unsigned height) : QWidget(), m_timer(this) {
m_width = width;
m_height = height;
m_drawbuffer = new QRgb[width * height];
m_img = QImage((uchar*)m_drawbuffer, width, height, QImage::Format_ARGB32);
+
+ QObject::connect(&m_timer, &QTimer::timeout, this, &DrawWidget::redraw);
+
+ m_timer.start(500);
}
void DrawWidget::paintEvent(QPaintEvent*) {
@@ -19,6 +24,10 @@ void DrawWidget::paintEvent(QPaintEvent*) {
painter.drawImage(0, 0, m_img);
}
+void DrawWidget::redraw() {
+ repaint();
+}
+
DrawWidget::~DrawWidget() {
delete[] m_drawbuffer;
}