-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
79 lines (60 loc) · 1.35 KB
/
main.cpp
File metadata and controls
79 lines (60 loc) · 1.35 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <GL/freeglut_std.h>
#include <stdio.h>
#include <GL/freeglut.h>
unsigned char prevKey;
// #include "math.cpp"
// #include "renderer.cpp"
// import user script
// #include "sketches/basics.cpp"
// #include "sketches/transform.cpp"
#include "sketches/dvd.cpp"
// #include "sketches/pong.cpp"
void display(void)
{
// printf("DisplayFunction: \n");
loop();
glutSwapBuffers();
glFlush();
glutPostRedisplay();
}
void reshape(int w, int h)
{
// printf("ReshapeFunction \n");
glViewport(0,0,(GLsizei) w, (GLsizei) h);
}
void keyboard(unsigned char key, int x, int y)
{
// printf("keyboard event \n");
// printf("key pressed: %c \n", key);
if (key == 27)
exit(0);
// printf("mouse pos: x%d y%d \n", x, y);
keyPressed(key, x, y);
}
void mouse(int button, int state, int x, int y)
{
printf("mouse %d \n", state);
if(state == 0)
keyPressed(button + '0', x, y);
// if (state == 1)
// keyReleased(button + '0', x, y);
}
void glutSetup()
{
glutInitWindowSize(480, 480); // 480x640
glutInitWindowPosition(0,0);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutCreateWindow("Canvas");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
}
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutSetup();
setup();
glutMainLoop();
return 0;
}