gameui

annotate 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
rev   line source
nuclear@0 1 #include <stdio.h>
nuclear@0 2 #include <stdlib.h>
nuclear@0 3 #include <assert.h>
nuclear@0 4 #include <GL/glut.h>
nuclear@0 5
nuclear@0 6 static bool init();
nuclear@0 7 static void cleanup();
nuclear@0 8 static void disp();
nuclear@0 9 static void reshape(int x, int y);
nuclear@0 10 static void keypress(unsigned char key, int x, int y);
nuclear@0 11 static void keyrelease(unsigned char key, int x, int y);
nuclear@0 12 static void skeypress(int key, int x, int y);
nuclear@0 13 static void skeyrelease(int key, int x, int y);
nuclear@0 14 static void mouse(int bn, int st, int x, int y);
nuclear@0 15 static void motion(int x, int y);
nuclear@0 16
nuclear@0 17 int main(int argc, char **argv)
nuclear@0 18 {
nuclear@0 19 glutInitWindowSize(800, 600);
nuclear@0 20 glutInit(&argc, argv);
nuclear@0 21 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
nuclear@0 22 glutCreateWindow("gameui test");
nuclear@0 23
nuclear@0 24 glutDisplayFunc(disp);
nuclear@0 25 glutReshapeFunc(reshape);
nuclear@0 26 glutKeyboardFunc(keypress);
nuclear@0 27 glutKeyboardUpFunc(keyrelease);
nuclear@0 28 glutSpecialFunc(skeypress);
nuclear@0 29 glutSpecialUpFunc(skeyrelease);
nuclear@0 30 glutMouseFunc(mouse);
nuclear@0 31 glutMotionFunc(motion);
nuclear@0 32 glutPassiveMotionFunc(motion);
nuclear@0 33
nuclear@0 34 if(!init()) {
nuclear@0 35 return 1;
nuclear@0 36 }
nuclear@0 37 atexit(cleanup);
nuclear@0 38
nuclear@0 39 glutMainLoop();
nuclear@0 40 return 0;
nuclear@0 41 }
nuclear@0 42
nuclear@0 43
nuclear@0 44 static bool init()
nuclear@0 45 {
nuclear@0 46 return true;
nuclear@0 47 }
nuclear@0 48
nuclear@0 49 static void cleanup()
nuclear@0 50 {
nuclear@0 51 }
nuclear@0 52
nuclear@0 53 static void disp()
nuclear@0 54 {
nuclear@0 55 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
nuclear@0 56
nuclear@0 57 glutSwapBuffers();
nuclear@0 58 assert(glGetError() == GL_NO_ERROR);
nuclear@0 59 }
nuclear@0 60
nuclear@0 61 static void reshape(int x, int y)
nuclear@0 62 {
nuclear@0 63 glViewport(0, 0, x, y);
nuclear@0 64 glMatrixMode(GL_PROJECTION);
nuclear@0 65 glLoadIdentity();
nuclear@0 66 glOrtho(0, x, y, 0, -1, 1);
nuclear@0 67 }
nuclear@0 68
nuclear@0 69 static void keypress(unsigned char key, int x, int y)
nuclear@0 70 {
nuclear@0 71 if(key == 27) {
nuclear@0 72 exit(0);
nuclear@0 73 }
nuclear@0 74 }
nuclear@0 75
nuclear@0 76 static void keyrelease(unsigned char key, int x, int y)
nuclear@0 77 {
nuclear@0 78 }
nuclear@0 79
nuclear@0 80 static void skeypress(int key, int x, int y)
nuclear@0 81 {
nuclear@0 82 }
nuclear@0 83
nuclear@0 84 static void skeyrelease(int key, int x, int y)
nuclear@0 85 {
nuclear@0 86 }
nuclear@0 87
nuclear@0 88 static void mouse(int bn, int st, int x, int y)
nuclear@0 89 {
nuclear@0 90 }
nuclear@0 91
nuclear@0 92 static void motion(int x, int y)
nuclear@0 93 {
nuclear@0 94 }