tavli

diff src/board.cc @ 19:37dead56f01e

fixed shadows
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 29 Jun 2015 06:18:45 +0300
parents 986c0b76513f
children c3fbf9616dbd
line diff
     1.1 --- a/src/board.cc	Mon Jun 29 01:29:36 2015 +0300
     1.2 +++ b/src/board.cc	Mon Jun 29 06:18:45 2015 +0300
     1.3 @@ -172,11 +172,16 @@
     1.4  
     1.5  void Board::draw() const
     1.6  {
     1.7 +	bool use_shadows = opt.shadows && sdr_shadow;
     1.8 +	unsigned int board_sdr = use_shadows ? sdr_shadow : sdr_phong;
     1.9 +	unsigned int piece_sdr = use_shadows ? sdr_shadow_notex : sdr_phong_notex;
    1.10 +
    1.11  	for(size_t i=0; i<obj.size(); i++) {
    1.12  		if(wireframe) {
    1.13  			obj[i]->draw_wire();
    1.14  			obj[i]->draw_normals(0.075);
    1.15  		} else {
    1.16 +			obj[i]->set_shader(board_sdr);
    1.17  			obj[i]->draw();
    1.18  		}
    1.19  	}
    1.20 @@ -185,6 +190,7 @@
    1.21  		Vector3 pos = piece_pos(pieces[i].slot, pieces[i].level);
    1.22  		piece_obj->xform().set_translation(pos);
    1.23  		piece_obj->mtl.diffuse = opt.piece_color[pieces[i].owner];
    1.24 +		piece_obj->set_shader(piece_sdr);
    1.25  		piece_obj->draw();
    1.26  	}
    1.27  }
    1.28 @@ -193,9 +199,6 @@
    1.29  bool Board::generate()
    1.30  {
    1.31  	static const float board_spec = 0.4;
    1.32 -	bool use_shadows = opt.shadows && sdr_shadow;
    1.33 -	unsigned int board_sdr = use_shadows ? sdr_shadow : sdr_phong;
    1.34 -	unsigned int piece_sdr = use_shadows ? sdr_shadow_notex : sdr_phong_notex;
    1.35  
    1.36  	Mesh tmp;
    1.37  	Matrix4x4 xform;
    1.38 @@ -215,7 +218,6 @@
    1.39  		obottom->set_mesh(bottom);
    1.40  		obottom->xform().set_translation(Vector3(sign * BOARD_OFFSET, 0, 0));
    1.41  		obottom->set_texture(img_field.texture());
    1.42 -		obottom->set_shader(board_sdr);
    1.43  		obottom->mtl.specular = Vector3(board_spec, board_spec, board_spec);
    1.44  		obj.push_back(obottom);
    1.45  
    1.46 @@ -258,7 +260,6 @@
    1.47  		osides->tex_xform().set_scaling(Vector3(2, 2, 2));
    1.48  		osides->tex_xform().rotate(-Vector3(1, 0, 0.5), M_PI / 4.0);
    1.49  		osides->mtl.specular = Vector3(board_spec, board_spec, board_spec);
    1.50 -		osides->set_shader(board_sdr);
    1.51  		obj.push_back(osides);
    1.52  
    1.53  	}
    1.54 @@ -332,7 +333,6 @@
    1.55  	opiece->mtl.diffuse = Vector3(0.6, 0.6, 0.6);
    1.56  	opiece->mtl.specular = Vector3(0.8, 0.8, 0.8);
    1.57  	opiece->xform().set_translation(Vector3(0, 0.2, 0));
    1.58 -	opiece->set_shader(piece_sdr);
    1.59  	//obj.push_back(opiece);
    1.60  
    1.61  	piece_obj = opiece;