curvedraw
view src/main.cc @ 0:8e524989c904
getting there
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 15 Dec 2015 07:15:53 +0200 |
parents | |
children | 37ab3a4c02f8 |
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 reshape(int x, int y)
51 {
52 app_reshape(x, y);
53 }
55 static void keydown(unsigned char key, int x, int y)
56 {
57 app_keyboard(key, true);
58 }
60 static void keyup(unsigned char key, int x, int y)
61 {
62 app_keyboard(key, false);
63 }
65 static void mouse(int bn, int st, int x, int y)
66 {
67 app_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
68 }