-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
60 lines (45 loc) · 1.04 KB
/
main.cpp
File metadata and controls
60 lines (45 loc) · 1.04 KB
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
#include "defs.h"
#include <iostream>
#include "Vector2.h"
#include "Vector3.h"
#include "Vector4.h"
#include "Rasterizer.h"
#include "Matrix44.h"
#include "GenMath.h"
float angle = 0;
Rasterizer* rasterizer = nullptr;
bool renderCB(){
angle += .002f;
Matrix44 transformation;
transformation.rotate(Vector3(0, 1, 1), angle);
Vector4 v1(-1, 1, 0, 1);
Vector4 v2(1, 1, 0, 1);
Vector4 v3(0, -1, 0, 1);
v1 = transformation * v1;
v2 = transformation * v2;
v3 = transformation * v3;
rasterizer->clearFrame();
rasterizer->rasterizeTriangle(Vector2(v1.x, v1.y), Vector2(v2.x, v2.y), Vector2(v3.x, v3.y));
return true;
}
int main(void){
initscr();
raw();
noecho();
start_color();
cbreak();
curs_set(0);
rasterizer = new Rasterizer(WW, WH);
rasterizer->setRenderCB(renderCB);
while(true){
rasterizer->presentFrame();
rasterizer->swapBuffers();
refresh();
erase();
}
getch();
clear();
endwin();
delete rasterizer;
return 0;
}