-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender_balls.cpp
More file actions
54 lines (43 loc) · 1.26 KB
/
Copy pathrender_balls.cpp
File metadata and controls
54 lines (43 loc) · 1.26 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
#include <iostream>
#include <sys/ioctl.h>
#include <stdio.h>
#include <memory>
#include <unistd.h>
#include <thread>
#include "renderer.hpp"
#include "lin_alg.hpp"
using namespace lin_alg;
using namespace renderer;
int main()
{
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
size_t rows = w.ws_row - 1;
size_t cols = w.ws_col - 1;
std::cout << "lines " << rows << std::endl;
std::cout << "columns " << cols << std::endl;
World world(cols, rows, 3, 500);
std::shared_ptr<TerminalDisplay> t = std::make_shared<TerminalDisplay>(cols, rows, 2);
auto z= 50;
auto sphere = std::make_shared<Sphere>(
40,
Coordinate(5000, 0, z));
// auto y = -50;
auto depth = 1500;
auto sphere2 = std::make_shared<Sphere>(
5,
Coordinate(depth, 5, 0));
world.add_object(sphere);
world.add_object(sphere2);
for (size_t i = 0; i < 100; i++)
{
t->clear();
sphere->set_origin(Coordinate(5000, 0, ++z));
sphere2->set_origin(Coordinate(depth, 5, 0));
depth -= 25;
world.render_perspective(t);
std::cout << t->render_to_str().str();
std::this_thread::sleep_for(std::chrono::milliseconds(20));
}
return 0; // make sure your main returns int
}