intravenous
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/game.cc Sat Apr 21 06:56:33 2012 +0300 1.3 @@ -0,0 +1,56 @@ 1.4 +#include <stdlib.h> 1.5 +#include "opengl.h" 1.6 +#include "game.h" 1.7 + 1.8 +static unsigned long tmsec, start_time = -1; 1.9 + 1.10 +bool game_init() 1.11 +{ 1.12 + glEnable(GL_DEPTH_TEST); 1.13 + glEnable(GL_CULL_FACE); 1.14 + glEnable(GL_LIGHTING); 1.15 + glEnable(GL_LIGHT0); 1.16 + 1.17 + float lpos[] = {-1, 1, 1, 0}; 1.18 + glLightfv(GL_LIGHT0, GL_POSITION, lpos); 1.19 + 1.20 + return true; 1.21 +} 1.22 + 1.23 +void game_shutdown() 1.24 +{ 1.25 + exit(0); 1.26 +} 1.27 + 1.28 +void game_update(unsigned long msec) 1.29 +{ 1.30 + if(start_time == 0) { 1.31 + start_time = msec; 1.32 + } 1.33 + tmsec = msec - start_time; 1.34 +} 1.35 + 1.36 +void game_draw() 1.37 +{ 1.38 + glMatrixMode(GL_MODELVIEW); 1.39 + glLoadIdentity(); 1.40 + glTranslatef(0, 0, -8); 1.41 + glRotatef(20, 1, 0, 0); 1.42 + 1.43 + glFrontFace(GL_CW); 1.44 + glutSolidTeapot(1.0); 1.45 + glFrontFace(GL_CCW); 1.46 +} 1.47 + 1.48 +void game_input_keyb(int key, int state) 1.49 +{ 1.50 + if(state) { 1.51 + switch(key) { 1.52 + case 27: 1.53 + game_shutdown(); 1.54 + 1.55 + default: 1.56 + break; 1.57 + } 1.58 + } 1.59 +}