rev |
line source |
nuclear@16
|
1 /*
|
nuclear@16
|
2 curvedraw - a simple program to draw curves
|
nuclear@16
|
3 Copyright (C) 2015 John Tsiombikas <nuclear@member.fsf.org>
|
nuclear@16
|
4
|
nuclear@16
|
5 This program is free software: you can redistribute it and/or modify
|
nuclear@16
|
6 it under the terms of the GNU General Public License as published by
|
nuclear@16
|
7 the Free Software Foundation, either version 3 of the License, or
|
nuclear@16
|
8 (at your option) any later version.
|
nuclear@16
|
9
|
nuclear@16
|
10 This program is distributed in the hope that it will be useful,
|
nuclear@16
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
nuclear@16
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
nuclear@16
|
13 GNU General Public License for more details.
|
nuclear@16
|
14
|
nuclear@16
|
15 You should have received a copy of the GNU General Public License
|
nuclear@16
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
nuclear@16
|
17 */
|
nuclear@0
|
18 #include <stdio.h>
|
nuclear@0
|
19 #include <stdlib.h>
|
nuclear@0
|
20 #ifdef __APPLE__
|
nuclear@0
|
21 #include <GLUT/glut.h>
|
nuclear@0
|
22 #else
|
nuclear@0
|
23 #include <GL/glut.h>
|
nuclear@0
|
24 #endif
|
nuclear@0
|
25 #include "app.h"
|
nuclear@0
|
26
|
nuclear@0
|
27 static void display();
|
nuclear@0
|
28 static void keydown(unsigned char key, int x, int y);
|
nuclear@0
|
29 static void keyup(unsigned char key, int x, int y);
|
nuclear@0
|
30 static void mouse(int bn, int st, int x, int y);
|
nuclear@0
|
31
|
nuclear@0
|
32 int main(int argc, char **argv)
|
nuclear@0
|
33 {
|
nuclear@0
|
34 glutInit(&argc, argv);
|
nuclear@0
|
35 glutInitWindowSize(1280, 720);
|
nuclear@0
|
36 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
|
nuclear@0
|
37 glutCreateWindow("Curve Draw");
|
nuclear@0
|
38
|
nuclear@0
|
39 glutDisplayFunc(display);
|
nuclear@0
|
40 glutReshapeFunc(app_reshape);
|
nuclear@0
|
41 glutKeyboardFunc(keydown);
|
nuclear@0
|
42 glutKeyboardUpFunc(keyup);
|
nuclear@0
|
43 glutMouseFunc(mouse);
|
nuclear@0
|
44 glutMotionFunc(app_mouse_motion);
|
nuclear@0
|
45 glutPassiveMotionFunc(app_mouse_motion);
|
nuclear@0
|
46
|
nuclear@0
|
47 if(!app_init(argc, argv)) {
|
nuclear@0
|
48 return 1;
|
nuclear@0
|
49 }
|
nuclear@0
|
50 atexit(app_cleanup);
|
nuclear@0
|
51
|
nuclear@0
|
52 glutMainLoop();
|
nuclear@0
|
53 return 0;
|
nuclear@0
|
54 }
|
nuclear@0
|
55
|
nuclear@0
|
56 void post_redisplay()
|
nuclear@0
|
57 {
|
nuclear@0
|
58 glutPostRedisplay();
|
nuclear@0
|
59 }
|
nuclear@0
|
60
|
nuclear@0
|
61 static void display()
|
nuclear@0
|
62 {
|
nuclear@0
|
63 app_draw();
|
nuclear@0
|
64 glutSwapBuffers();
|
nuclear@0
|
65 }
|
nuclear@0
|
66
|
nuclear@0
|
67 static void keydown(unsigned char key, int x, int y)
|
nuclear@0
|
68 {
|
nuclear@0
|
69 app_keyboard(key, true);
|
nuclear@0
|
70 }
|
nuclear@0
|
71
|
nuclear@0
|
72 static void keyup(unsigned char key, int x, int y)
|
nuclear@0
|
73 {
|
nuclear@0
|
74 app_keyboard(key, false);
|
nuclear@0
|
75 }
|
nuclear@0
|
76
|
nuclear@0
|
77 static void mouse(int bn, int st, int x, int y)
|
nuclear@0
|
78 {
|
nuclear@0
|
79 app_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
|
nuclear@0
|
80 }
|