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