tavli

diff src/game.cc @ 15:b1a195c3ee16

added shaders
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 28 Jun 2015 08:34:24 +0300
parents 283eb6e9f0a3
children d6209903454b
line diff
     1.1 --- a/src/game.cc	Sun Jun 28 07:44:23 2015 +0300
     1.2 +++ b/src/game.cc	Sun Jun 28 08:34:24 2015 +0300
     1.3 @@ -3,10 +3,12 @@
     1.4  #include "game.h"
     1.5  #include "board.h"
     1.6  #include "scenery.h"
     1.7 +#include "sdr.h"
     1.8  
     1.9  static void draw_backdrop();
    1.10  
    1.11  int win_width, win_height;
    1.12 +unsigned int sdr_phong, sdr_phong_notex;
    1.13  bool wireframe;
    1.14  
    1.15  static Board board;
    1.16 @@ -15,6 +17,7 @@
    1.17  static bool bnstate[8];
    1.18  static int prev_x, prev_y;
    1.19  
    1.20 +static bool dbg_busyloop;
    1.21  
    1.22  bool game_init()
    1.23  {
    1.24 @@ -28,6 +31,15 @@
    1.25  		glEnable(GL_MULTISAMPLE);
    1.26  	}
    1.27  
    1.28 +	Mesh::use_custom_sdr_attr = false;
    1.29 +
    1.30 +	if(!(sdr_phong = create_program_load("sdr/phong.v.glsl", "sdr/phong.p.glsl"))) {
    1.31 +		return false;
    1.32 +	}
    1.33 +	if(!(sdr_phong_notex = create_program_load("sdr/phong.v.glsl", "sdr/phong-notex.p.glsl"))) {
    1.34 +		return false;
    1.35 +	}
    1.36 +
    1.37  	if(!board.init()) {
    1.38  		return false;
    1.39  	}
    1.40 @@ -59,12 +71,16 @@
    1.41  	glRotatef(cam_phi, 1, 0, 0);
    1.42  	glRotatef(cam_theta, 0, 1, 0);
    1.43  
    1.44 -	float ldir[] = {-1, 2, 1, 0};
    1.45 +	float ldir[] = {-10, 20, 10, 1};
    1.46  	glLightfv(GL_LIGHT0, GL_POSITION, ldir);
    1.47  
    1.48  	draw_backdrop();
    1.49  	draw_scenery();
    1.50  	board.draw();
    1.51 +
    1.52 +	if(dbg_busyloop) {
    1.53 +		redisplay();
    1.54 +	}
    1.55  }
    1.56  
    1.57  static void draw_backdrop()
    1.58 @@ -117,6 +133,11 @@
    1.59  			wireframe = !wireframe;
    1.60  			redisplay();
    1.61  			break;
    1.62 +
    1.63 +		case 'd':
    1.64 +			dbg_busyloop = !dbg_busyloop;
    1.65 +			redisplay();
    1.66 +			break;
    1.67  		}
    1.68  	}
    1.69  }