gameui

diff test.cc @ 0:3aa12cdb9925

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 24 Feb 2014 22:25:49 +0200
parents
children f1014234dece
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test.cc	Mon Feb 24 22:25:49 2014 +0200
     1.3 @@ -0,0 +1,94 @@
     1.4 +#include <stdio.h>
     1.5 +#include <stdlib.h>
     1.6 +#include <assert.h>
     1.7 +#include <GL/glut.h>
     1.8 +
     1.9 +static bool init();
    1.10 +static void cleanup();
    1.11 +static void disp();
    1.12 +static void reshape(int x, int y);
    1.13 +static void keypress(unsigned char key, int x, int y);
    1.14 +static void keyrelease(unsigned char key, int x, int y);
    1.15 +static void skeypress(int key, int x, int y);
    1.16 +static void skeyrelease(int key, int x, int y);
    1.17 +static void mouse(int bn, int st, int x, int y);
    1.18 +static void motion(int x, int y);
    1.19 +
    1.20 +int main(int argc, char **argv)
    1.21 +{
    1.22 +	glutInitWindowSize(800, 600);
    1.23 +	glutInit(&argc, argv);
    1.24 +	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    1.25 +	glutCreateWindow("gameui test");
    1.26 +
    1.27 +	glutDisplayFunc(disp);
    1.28 +	glutReshapeFunc(reshape);
    1.29 +	glutKeyboardFunc(keypress);
    1.30 +	glutKeyboardUpFunc(keyrelease);
    1.31 +	glutSpecialFunc(skeypress);
    1.32 +	glutSpecialUpFunc(skeyrelease);
    1.33 +	glutMouseFunc(mouse);
    1.34 +	glutMotionFunc(motion);
    1.35 +	glutPassiveMotionFunc(motion);
    1.36 +
    1.37 +	if(!init()) {
    1.38 +		return 1;
    1.39 +	}
    1.40 +	atexit(cleanup);
    1.41 +
    1.42 +	glutMainLoop();
    1.43 +	return 0;
    1.44 +}
    1.45 +
    1.46 +
    1.47 +static bool init()
    1.48 +{
    1.49 +	return true;
    1.50 +}
    1.51 +
    1.52 +static void cleanup()
    1.53 +{
    1.54 +}
    1.55 +
    1.56 +static void disp()
    1.57 +{
    1.58 +	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    1.59 +
    1.60 +	glutSwapBuffers();
    1.61 +	assert(glGetError() == GL_NO_ERROR);
    1.62 +}
    1.63 +
    1.64 +static void reshape(int x, int y)
    1.65 +{
    1.66 +	glViewport(0, 0, x, y);
    1.67 +	glMatrixMode(GL_PROJECTION);
    1.68 +	glLoadIdentity();
    1.69 +	glOrtho(0, x, y, 0, -1, 1);
    1.70 +}
    1.71 +
    1.72 +static void keypress(unsigned char key, int x, int y)
    1.73 +{
    1.74 +	if(key == 27) {
    1.75 +		exit(0);
    1.76 +	}
    1.77 +}
    1.78 +
    1.79 +static void keyrelease(unsigned char key, int x, int y)
    1.80 +{
    1.81 +}
    1.82 +
    1.83 +static void skeypress(int key, int x, int y)
    1.84 +{
    1.85 +}
    1.86 +
    1.87 +static void skeyrelease(int key, int x, int y)
    1.88 +{
    1.89 +}
    1.90 +
    1.91 +static void mouse(int bn, int st, int x, int y)
    1.92 +{
    1.93 +}
    1.94 +
    1.95 +static void motion(int x, int y)
    1.96 +{
    1.97 +}