intravenous

annotate 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
rev   line source
nuclear@0 1 #include <stdlib.h>
nuclear@0 2 #include "opengl.h"
nuclear@0 3 #include "game.h"
nuclear@0 4
nuclear@0 5 static unsigned long tmsec, start_time = -1;
nuclear@0 6
nuclear@0 7 bool game_init()
nuclear@0 8 {
nuclear@0 9 glEnable(GL_DEPTH_TEST);
nuclear@0 10 glEnable(GL_CULL_FACE);
nuclear@0 11 glEnable(GL_LIGHTING);
nuclear@0 12 glEnable(GL_LIGHT0);
nuclear@0 13
nuclear@0 14 float lpos[] = {-1, 1, 1, 0};
nuclear@0 15 glLightfv(GL_LIGHT0, GL_POSITION, lpos);
nuclear@0 16
nuclear@0 17 return true;
nuclear@0 18 }
nuclear@0 19
nuclear@0 20 void game_shutdown()
nuclear@0 21 {
nuclear@0 22 exit(0);
nuclear@0 23 }
nuclear@0 24
nuclear@0 25 void game_update(unsigned long msec)
nuclear@0 26 {
nuclear@0 27 if(start_time == 0) {
nuclear@0 28 start_time = msec;
nuclear@0 29 }
nuclear@0 30 tmsec = msec - start_time;
nuclear@0 31 }
nuclear@0 32
nuclear@0 33 void game_draw()
nuclear@0 34 {
nuclear@0 35 glMatrixMode(GL_MODELVIEW);
nuclear@0 36 glLoadIdentity();
nuclear@0 37 glTranslatef(0, 0, -8);
nuclear@0 38 glRotatef(20, 1, 0, 0);
nuclear@0 39
nuclear@0 40 glFrontFace(GL_CW);
nuclear@0 41 glutSolidTeapot(1.0);
nuclear@0 42 glFrontFace(GL_CCW);
nuclear@0 43 }
nuclear@0 44
nuclear@0 45 void game_input_keyb(int key, int state)
nuclear@0 46 {
nuclear@0 47 if(state) {
nuclear@0 48 switch(key) {
nuclear@0 49 case 27:
nuclear@0 50 game_shutdown();
nuclear@0 51
nuclear@0 52 default:
nuclear@0 53 break;
nuclear@0 54 }
nuclear@0 55 }
nuclear@0 56 }