curvedraw

view src/main.cc @ 16:7f795f7fecd6

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