bloboland

diff src/game.cc @ 3:a39c301cdcce

terrain raytracing pretty much done
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 16 Dec 2012 14:24:16 +0200
parents 1757973feaed
children 9021a906c5d3
line diff
     1.1 --- a/src/game.cc	Sun Dec 16 00:37:35 2012 +0200
     1.2 +++ b/src/game.cc	Sun Dec 16 14:24:16 2012 +0200
     1.3 @@ -31,14 +31,16 @@
     1.4  	float lpos[] = {-1, 1, 1, 0};
     1.5  	glLightfv(GL_LIGHT0, GL_POSITION, lpos);
     1.6  
     1.7 -	printf("initializing renderer\n");
     1.8 -	rend = new Renderer;
     1.9 -	rend->init();
    1.10 -
    1.11  	printf("generating level\n");
    1.12  	level = new Level;
    1.13  	level->generate();
    1.14  
    1.15 +	printf("initializing renderer\n");
    1.16 +	rend = new Renderer;
    1.17 +	if(!rend->init(level)) {
    1.18 +		return false;
    1.19 +	}
    1.20 +
    1.21  	cam.input_move(0, 2, 2);
    1.22  	cam.input_rotate(0, M_PI / 5, 0);
    1.23  
    1.24 @@ -75,6 +77,8 @@
    1.25  
    1.26  void game_render()
    1.27  {
    1.28 +	rend->set_aspect((float)win_xsz / (float)win_ysz);
    1.29 +
    1.30  	if(opt.stereo) {
    1.31  		glDrawBuffer(GL_BACK_LEFT);
    1.32  
    1.33 @@ -85,7 +89,7 @@
    1.34  		glLoadIdentity();
    1.35  		view_matrix(-1);
    1.36  
    1.37 -		rend->render(level);
    1.38 +		rend->render();
    1.39  
    1.40  		glDrawBuffer(GL_BACK_RIGHT);
    1.41  
    1.42 @@ -96,7 +100,7 @@
    1.43  		glLoadIdentity();
    1.44  		view_matrix(1);
    1.45  
    1.46 -		rend->render(level);
    1.47 +		rend->render();
    1.48  	} else {
    1.49  		glMatrixMode(GL_PROJECTION);
    1.50  		glLoadIdentity();
    1.51 @@ -105,7 +109,7 @@
    1.52  		glLoadIdentity();
    1.53  		view_matrix(0);
    1.54  
    1.55 -		rend->render(level);
    1.56 +		rend->render();
    1.57  	}
    1.58  }
    1.59  
    1.60 @@ -128,7 +132,7 @@
    1.61  {
    1.62  	float offs = stereo_eye_sep * eye * 0.5;
    1.63  	glTranslatef(-offs, 0, 0);
    1.64 -	cam.use_inverse();
    1.65 +	cam.use();
    1.66  }
    1.67  
    1.68  static void proj_matrix(int eye)