From 893176a0b18a2281abe09def716ccc3db5583c3f Mon Sep 17 00:00:00 2001 From: Julian T Date: Sun, 26 Jul 2020 12:56:27 +0200 Subject: Implemented object intersection and startet work on render gui --- app/draw.cpp | 24 ++++++++++++++++++++++++ app/draw.hpp | 21 +++++++++++++++++++++ app/main.cpp | 17 +++++++++++++++++ app/mainwindow.cpp | 8 ++++++++ app/mainwindow.hpp | 19 +++++++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 app/draw.cpp create mode 100644 app/draw.hpp create mode 100644 app/main.cpp create mode 100644 app/mainwindow.cpp create mode 100644 app/mainwindow.hpp (limited to 'app') 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 +#include +#include +#include +#include +#include + +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 +#include + +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 +#include +#include + +#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 + +#include "draw.hpp" + +class MainWindow : public QMainWindow { + Q_OBJECT + + public: + MainWindow(); + + private: + DrawWidget drawer; + +}; + +#endif -- cgit v1.2.3