-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathwindow.h
78 lines (59 loc) · 1.75 KB
/
window.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include <vector>
#include <QWidget>
#include <QImage>
#include <QResizeEvent>
#include <QKeyEvent>
#include <QTimer>
#include "mat4.h"
#include "vec3d.h"
#include "display.h"
#include "light.h"
#include "mesh.h"
#include "cubemesh.h"
#include "triangle.h"
#include "camera.h"
#include "clipping.h"
enum RENDER_MODE {
WIREFRAME, // draw only wireframe lines
WIREFRAME_DOTS, // draw wireframe lines with small colored dots on each triangle vertex
TRIANGLES, // fills triangles with a solid color
TRIANGLES_WIREFRAME, // fills triangles and adds wireframe lines
TEXTURED, // draw with textures
TEXTURED_WIREFRAME // draw with textures and adds wireframe lines
};
class Window : public QWidget
{
Q_OBJECT
public:
Window();
~Window();
void updt();
void render(QPainter& p);
void resizeEvent(QResizeEvent* event);
void paintEvent(QPaintEvent* e);
void keyPressEvent(QKeyEvent* event);
private slots:
void _tick();
private:
void _renderColorBuffer(QPainter& p);
void _initFrustumPlanes(const float& fovX, const float& fovY, const float& zNear, const float& zFar);
void _processGraphicsPipeline(Mesh* mesh);
int _width, _height;
QImage _framebuffer;
Display _gfx;
std::vector<Triangle> _triangles2render;
std::vector<Mesh> _meshObjects;
Camera _camera;
float _cameraOrbitAngle;
float _cameraOrbitDistance;
Mat4 _viewMatrix;
float _deltaTime;
QTimer* _timer;
qint64 _tick_ms;
qint64 _prevTime;
RENDER_MODE _renderMode;
Mat4 _projMatrix;
Light _lightSource;
Plane _frustumPlanes[6];
};