-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
50 lines (41 loc) · 1.16 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "jsonscenereader.h"
#include "mainwindow.h"
#include "raytracer.h"
#include "scene.h"
#include "ui_mainwindow.h"
#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_TARGET_OPENCL_VERSION 200
#include <OpenCL/opencl.h>
#include <openclraytracerharness.h>
#include <iostream>
#include <QImage>
#include <QMessageBox>
#include <glm/glm.hpp>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
const int width = 512, height = 512;
JsonSceneReader reader;
// TODO: Configure.
QFile file("/Users/nathankorzekwa/Projects/opencl-raytracer/scene_files/PT_cornellBox.json");
Scene s = reader.load_scene(file);
Raytracer rt(width, height, ":/main.cl", 200);
try {
rt.set_scene(s);
auto render = rt.render(20);
m_gfx_scene.clear();
m_gfx_scene.addPixmap(QPixmap::fromImage(render));
ui->preview->setScene(&m_gfx_scene);
} catch (std::domain_error &ex) {
std::cerr << "Error!" << std::endl;
QMessageBox box;
box.setText("Error setting up OpenCL!");
box.show();
}
}
MainWindow::~MainWindow()
{
delete ui;
}