intravenous

view src/game.cc @ 0:2b30f261f641

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Apr 2012 06:56:33 +0300
parents
children 3ea290d35984
line source
1 #include <stdlib.h>
2 #include "opengl.h"
3 #include "game.h"
5 static unsigned long tmsec, start_time = -1;
7 bool game_init()
8 {
9 glEnable(GL_DEPTH_TEST);
10 glEnable(GL_CULL_FACE);
11 glEnable(GL_LIGHTING);
12 glEnable(GL_LIGHT0);
14 float lpos[] = {-1, 1, 1, 0};
15 glLightfv(GL_LIGHT0, GL_POSITION, lpos);
17 return true;
18 }
20 void game_shutdown()
21 {
22 exit(0);
23 }
25 void game_update(unsigned long msec)
26 {
27 if(start_time == 0) {
28 start_time = msec;
29 }
30 tmsec = msec - start_time;
31 }
33 void game_draw()
34 {
35 glMatrixMode(GL_MODELVIEW);
36 glLoadIdentity();
37 glTranslatef(0, 0, -8);
38 glRotatef(20, 1, 0, 0);
40 glFrontFace(GL_CW);
41 glutSolidTeapot(1.0);
42 glFrontFace(GL_CCW);
43 }
45 void game_input_keyb(int key, int state)
46 {
47 if(state) {
48 switch(key) {
49 case 27:
50 game_shutdown();
52 default:
53 break;
54 }
55 }
56 }