-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
executable file
·96 lines (80 loc) · 2.21 KB
/
main.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <ann_dataset.h>
#include <GL/freeglut.h>
#include "renderer.h"
size_t WindowsWidth = 800;
size_t WindowsHeight = 800;
Renderer2D renderer(WindowsWidth, WindowsHeight);
void display() {
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderer.render();
glutSwapBuffers();
}
void init_display() {
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glLineWidth(1.5);
}
void reshape(int w, int h) {
WindowsWidth = w;
WindowsHeight = h;
renderer.reshape(w, h);
glViewport(0, 0, w, h);
init_display();
display();
}
void mouse_wheel(int wheel, int direction, int x, int y) {
int y1 = WindowsHeight - y;
renderer.mouse_button(direction > 0 ? 3 : 4, GLUT_DOWN, x, y1);
}
void mouse_button(int button, int state, int x, int y) {
int y1 = WindowsHeight - y;
renderer.mouse_button(button, state, x, y1);
}
void mouse_active_motion(int x, int y) {
int y1 = WindowsHeight - y;
renderer.mouse_active_motion(x, y1);
}
void mouse_passive_motion(int x, int y) {
int y1 = WindowsHeight - y;
renderer.mouse_passive_motion(x, y1);
}
void normal_keys(unsigned char key, int x, int y) {
switch (key) {
case 'a':
break;
case 27:
glutLeaveMainLoop();
break;
default:
break;
}
}
void init_glut_window(int argc, char *argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(0, 0);
glutInitWindowSize(WindowsWidth, WindowsHeight);
glutCreateWindow("ANN MNIST");
glutDisplayFunc(display);
glutIdleFunc(display);
glutKeyboardFunc(normal_keys);
//glutSpecialFunc(special_keys);
glutMouseFunc(mouse_button);
glutMotionFunc(mouse_active_motion);
glutPassiveMotionFunc(mouse_passive_motion);
glutMouseWheelFunc(mouse_wheel);
glutReshapeFunc(reshape);
glutMainLoop();
}
int main(int argc, char *argv[]) {
init_glut_window(argc, argv);
printf("Testing\n");
ann::MNISTDataset dataset("./Data/MNIST/train-images.idx3-ubyte", "./Data/MNIST/train-labels.idx1-ubyte");
printf("Testing Ended\n");
getchar();
return 0;
}