coeng

view src/test.cc @ 0:14e743b53289

component system test
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 04 Feb 2015 17:23:35 +0200
parents
children 4a1c9597f4d3
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <assert.h>
5 #ifndef __APPLE__
6 #include <GL/glut.h>
7 #else
8 #include <GLUT/glut.h>
9 #endif
11 static bool init();
12 static void cleanup();
13 static void display();
14 static void idle();
15 static void reshape(int x, int y);
16 static void keyb(unsigned char key, int x, int y);
17 static void mouse(int bn, int st, int x, int y);
18 static void motion(int x, int y);
21 int main(int argc, char **argv)
22 {
23 glutInit(&argc, argv);
24 glutInitWindowSize(800, 600);
25 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
26 glutCreateWindow("component system test");
28 glutDisplayFunc(display);
29 glutIdleFunc(idle);
30 glutReshapeFunc(reshape);
31 glutKeyboardFunc(keyb);
32 glutMouseFunc(mouse);
33 glutMotionFunc(motion);
35 if(!init()) {
36 return 1;
37 }
38 atexit(cleanup);
40 glutMainLoop();
41 return 0;
42 }
44 static bool init()
45 {
46 glEnable(GL_DEPTH_TEST);
47 glEnable(GL_CULL_FACE);
49 return true;
50 }
52 static void cleanup()
53 {
54 }
56 static void display()
57 {
58 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
60 glutSwapBuffers();
61 assert(glGetError() == GL_NO_ERROR);
62 }
64 static void idle()
65 {
66 glutPostRedisplay();
67 }
69 static void reshape(int x, int y)
70 {
71 glViewport(0, 0, x, y);
73 glMatrixMode(GL_PROJECION);
74 glLoadIdentity();
75 gluPerspective(50.0, (float)x / (float)y, 0.5, 500.0);
76 }
78 static void keyb(unsigned char key, int x, int y)
79 {
80 switch(key) {
81 case 27:
82 exit(0);
83 }
84 }
86 static int bnstate[16];
87 static int prev_x, prev_y;
89 static void mouse(int bn, int st, int x, int y)
90 {
91 }
93 static void motion(int x, int y)
94 {
95 }