rev |
line source |
nuclear@0
|
1 #include <stdio.h>
|
nuclear@0
|
2 #include <stdlib.h>
|
nuclear@0
|
3 #ifdef __APPLE__
|
nuclear@0
|
4 #include <GLUT/glut.h>
|
nuclear@0
|
5 #else
|
nuclear@0
|
6 #include <GL/glut.h>
|
nuclear@0
|
7 #endif
|
nuclear@0
|
8 #include "app.h"
|
nuclear@0
|
9
|
nuclear@0
|
10 static void display();
|
nuclear@0
|
11 static void keydown(unsigned char key, int x, int y);
|
nuclear@0
|
12 static void keyup(unsigned char key, int x, int y);
|
nuclear@0
|
13 static void mouse(int bn, int st, int x, int y);
|
nuclear@0
|
14
|
nuclear@0
|
15 int main(int argc, char **argv)
|
nuclear@0
|
16 {
|
nuclear@0
|
17 glutInit(&argc, argv);
|
nuclear@0
|
18 glutInitWindowSize(1280, 720);
|
nuclear@0
|
19 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
|
nuclear@0
|
20 glutCreateWindow("Curve Draw");
|
nuclear@0
|
21
|
nuclear@0
|
22 glutDisplayFunc(display);
|
nuclear@0
|
23 glutReshapeFunc(app_reshape);
|
nuclear@0
|
24 glutKeyboardFunc(keydown);
|
nuclear@0
|
25 glutKeyboardUpFunc(keyup);
|
nuclear@0
|
26 glutMouseFunc(mouse);
|
nuclear@0
|
27 glutMotionFunc(app_mouse_motion);
|
nuclear@0
|
28 glutPassiveMotionFunc(app_mouse_motion);
|
nuclear@0
|
29
|
nuclear@0
|
30 if(!app_init(argc, argv)) {
|
nuclear@0
|
31 return 1;
|
nuclear@0
|
32 }
|
nuclear@0
|
33 atexit(app_cleanup);
|
nuclear@0
|
34
|
nuclear@0
|
35 glutMainLoop();
|
nuclear@0
|
36 return 0;
|
nuclear@0
|
37 }
|
nuclear@0
|
38
|
nuclear@0
|
39 void post_redisplay()
|
nuclear@0
|
40 {
|
nuclear@0
|
41 glutPostRedisplay();
|
nuclear@0
|
42 }
|
nuclear@0
|
43
|
nuclear@0
|
44 static void display()
|
nuclear@0
|
45 {
|
nuclear@0
|
46 app_draw();
|
nuclear@0
|
47 glutSwapBuffers();
|
nuclear@0
|
48 }
|
nuclear@0
|
49
|
nuclear@0
|
50 static void reshape(int x, int y)
|
nuclear@0
|
51 {
|
nuclear@0
|
52 app_reshape(x, y);
|
nuclear@0
|
53 }
|
nuclear@0
|
54
|
nuclear@0
|
55 static void keydown(unsigned char key, int x, int y)
|
nuclear@0
|
56 {
|
nuclear@0
|
57 app_keyboard(key, true);
|
nuclear@0
|
58 }
|
nuclear@0
|
59
|
nuclear@0
|
60 static void keyup(unsigned char key, int x, int y)
|
nuclear@0
|
61 {
|
nuclear@0
|
62 app_keyboard(key, false);
|
nuclear@0
|
63 }
|
nuclear@0
|
64
|
nuclear@0
|
65 static void mouse(int bn, int st, int x, int y)
|
nuclear@0
|
66 {
|
nuclear@0
|
67 app_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
|
nuclear@0
|
68 }
|