diff options
author | Julian T <julian@jtle.dk> | 2020-07-26 12:56:27 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-07-26 12:56:27 +0200 |
commit | 893176a0b18a2281abe09def716ccc3db5583c3f (patch) | |
tree | a34da79b7dc0fcdbdd39e2a3f4000cc6a1c0a896 /app | |
parent | 18960c4b88ce912e08b12182b835a7de75388b78 (diff) |
Implemented object intersection and startet work on render gui
Diffstat (limited to 'app')
-rw-r--r-- | app/draw.cpp | 24 | ||||
-rw-r--r-- | app/draw.hpp | 21 | ||||
-rw-r--r-- | app/main.cpp | 17 | ||||
-rw-r--r-- | app/mainwindow.cpp | 8 | ||||
-rw-r--r-- | app/mainwindow.hpp | 19 |
5 files changed, 89 insertions, 0 deletions
diff --git a/app/draw.cpp b/app/draw.cpp new file mode 100644 index 0000000..2f3a947 --- /dev/null +++ b/app/draw.cpp @@ -0,0 +1,24 @@ +#include "draw.hpp" +#include <qpainter.h> +#include <qglobal.h> +#include <qimage.h> +#include <qrgb.h> +#include <qwindowdefs.h> +#include <iostream> + +DrawWidget::DrawWidget(unsigned width, unsigned height) : QWidget() { + m_width = width; + m_height = height; + m_drawbuffer = new QRgb[width * height]; + + m_img = QImage((uchar*)m_drawbuffer, width, height, QImage::Format_ARGB32); +} + +void DrawWidget::paintEvent(QPaintEvent*) { + QPainter painter(this); + painter.drawImage(0, 0, m_img); +} + +DrawWidget::~DrawWidget() { + delete[] m_drawbuffer; +} diff --git a/app/draw.hpp b/app/draw.hpp new file mode 100644 index 0000000..a00de79 --- /dev/null +++ b/app/draw.hpp @@ -0,0 +1,21 @@ +#ifndef DRAW_H +#define DRAW_H + +#include <qimage.h> +#include <qwidget.h> + +class DrawWidget : public QWidget { + public: + DrawWidget(unsigned width, unsigned height); + void paintEvent(QPaintEvent*); + + QRgb *m_drawbuffer; + unsigned m_width, m_height; + + ~DrawWidget(); + private: + QImage m_img; + unsigned char i; +}; + +#endif diff --git a/app/main.cpp b/app/main.cpp new file mode 100644 index 0000000..15262f2 --- /dev/null +++ b/app/main.cpp @@ -0,0 +1,17 @@ +#include <iostream> +#include <qapplication.h> +#include <qpushbutton.h> + +#include "mainwindow.hpp" + +using namespace std; + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + MainWindow main; + main.show(); + + return a.exec(); +} diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp new file mode 100644 index 0000000..e5f9bfb --- /dev/null +++ b/app/mainwindow.cpp @@ -0,0 +1,8 @@ +#include "mainwindow.hpp" + +MainWindow::MainWindow() + : drawer(500, 500) { + + setCentralWidget(&drawer); + +} diff --git a/app/mainwindow.hpp b/app/mainwindow.hpp new file mode 100644 index 0000000..a6c1be3 --- /dev/null +++ b/app/mainwindow.hpp @@ -0,0 +1,19 @@ +#ifndef MAIN_H +#define MAIN_H + +#include <QMainWindow> + +#include "draw.hpp" + +class MainWindow : public QMainWindow { + Q_OBJECT + + public: + MainWindow(); + + private: + DrawWidget drawer; + +}; + +#endif |