curvedraw

view src/main.cc @ 15:37ab3a4c02f8

merged
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 20 Dec 2015 09:06:04 +0200
parents 8e524989c904
children 7f795f7fecd6
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #ifdef __APPLE__
4 #include <GLUT/glut.h>
5 #else
6 #include <GL/glut.h>
7 #endif
8 #include "app.h"
10 static void display();
11 static void keydown(unsigned char key, int x, int y);
12 static void keyup(unsigned char key, int x, int y);
13 static void mouse(int bn, int st, int x, int y);
15 int main(int argc, char **argv)
16 {
17 glutInit(&argc, argv);
18 glutInitWindowSize(1280, 720);
19 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
20 glutCreateWindow("Curve Draw");
22 glutDisplayFunc(display);
23 glutReshapeFunc(app_reshape);
24 glutKeyboardFunc(keydown);
25 glutKeyboardUpFunc(keyup);
26 glutMouseFunc(mouse);
27 glutMotionFunc(app_mouse_motion);
28 glutPassiveMotionFunc(app_mouse_motion);
30 if(!app_init(argc, argv)) {
31 return 1;
32 }
33 atexit(app_cleanup);
35 glutMainLoop();
36 return 0;
37 }
39 void post_redisplay()
40 {
41 glutPostRedisplay();
42 }
44 static void display()
45 {
46 app_draw();
47 glutSwapBuffers();
48 }
50 static void keydown(unsigned char key, int x, int y)
51 {
52 app_keyboard(key, true);
53 }
55 static void keyup(unsigned char key, int x, int y)
56 {
57 app_keyboard(key, false);
58 }
60 static void mouse(int bn, int st, int x, int y)
61 {
62 app_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
63 }