curvedraw

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/main.cc	Tue Dec 15 07:15:53 2015 +0200
     1.3 @@ -0,0 +1,68 @@
     1.4 +#include <stdio.h>
     1.5 +#include <stdlib.h>
     1.6 +#ifdef __APPLE__
     1.7 +#include <GLUT/glut.h>
     1.8 +#else
     1.9 +#include <GL/glut.h>
    1.10 +#endif
    1.11 +#include "app.h"
    1.12 +
    1.13 +static void display();
    1.14 +static void keydown(unsigned char key, int x, int y);
    1.15 +static void keyup(unsigned char key, int x, int y);
    1.16 +static void mouse(int bn, int st, int x, int y);
    1.17 +
    1.18 +int main(int argc, char **argv)
    1.19 +{
    1.20 +	glutInit(&argc, argv);
    1.21 +	glutInitWindowSize(1280, 720);
    1.22 +	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
    1.23 +	glutCreateWindow("Curve Draw");
    1.24 +
    1.25 +	glutDisplayFunc(display);
    1.26 +	glutReshapeFunc(app_reshape);
    1.27 +	glutKeyboardFunc(keydown);
    1.28 +	glutKeyboardUpFunc(keyup);
    1.29 +	glutMouseFunc(mouse);
    1.30 +	glutMotionFunc(app_mouse_motion);
    1.31 +	glutPassiveMotionFunc(app_mouse_motion);
    1.32 +
    1.33 +	if(!app_init(argc, argv)) {
    1.34 +		return 1;
    1.35 +	}
    1.36 +	atexit(app_cleanup);
    1.37 +
    1.38 +	glutMainLoop();
    1.39 +	return 0;
    1.40 +}
    1.41 +
    1.42 +void post_redisplay()
    1.43 +{
    1.44 +	glutPostRedisplay();
    1.45 +}
    1.46 +
    1.47 +static void display()
    1.48 +{
    1.49 +	app_draw();
    1.50 +	glutSwapBuffers();
    1.51 +}
    1.52 +
    1.53 +static void reshape(int x, int y)
    1.54 +{
    1.55 +	app_reshape(x, y);
    1.56 +}
    1.57 +
    1.58 +static void keydown(unsigned char key, int x, int y)
    1.59 +{
    1.60 +	app_keyboard(key, true);
    1.61 +}
    1.62 +
    1.63 +static void keyup(unsigned char key, int x, int y)
    1.64 +{
    1.65 +	app_keyboard(key, false);
    1.66 +}
    1.67 +
    1.68 +static void mouse(int bn, int st, int x, int y)
    1.69 +{
    1.70 +	app_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
    1.71 +}