-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (51 loc) · 1.49 KB
/
main.cpp
File metadata and controls
59 lines (51 loc) · 1.49 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
#include <GL/glut.h>
#include <cmath>
#include <iostream>
#include "MyGL/MyGL.h"
#include "MyGL/Examples/Examples.hpp"
#include "MyGL/Readers/ReadSTL.h"
using namespace std;
using namespace MyGL;
vector<vector<Color>> pixels;
void Display() {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
for (int i = 0; i < 700; ++i) {
for (int j = 0; j < 700; ++j) {
glColor3f(pixels[i][j].mRed / 255.0, pixels[i][j].mGreen / 255.0, pixels[i][j].mBlue / 255.0);
glVertex2d(i, j);
}
}
glEnd();
glFlush();
}
void Initialize() {
glClearColor(0, 0, 0, 0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 700.0, 0.0, 700.0, -1.0, 1.0);
}
int main(int argc, char **argv) {
auto scene = Readers::ReadSTL::read("MyGL/Examples/xBowl.stl");
//auto scene = Readers::ReadSTL::read("MyGL/Examples/monster.stl");
//auto scene = Examples().redTriangle;
//auto scene = Examples().greenSphere;
scene.rayTrace(pixels);
/*
auto pic = Examples::readBMP("MyGL/Examples/water.bmp");
for (int i = 0; i < 700; ++i) {
for (int j = 0; j < 700; ++j) {
pixels[i][j] = pic[i * 0.7][j * 0.7];
}
} */
//return 0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(700, 700);
glutInitWindowPosition(0, 0);
glutCreateWindow("My super elite graphic library!!1337");
Initialize();
glutDisplayFunc(Display);
glutMainLoop();
return 0;
}