tavli

changeset 24:0aadb519b5ee tip

correct highlighting
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 08 Jul 2015 15:11:58 +0300
parents 3e6430028d54
children
files src/board.cc
diffstat 1 files changed, 22 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/src/board.cc	Wed Jul 08 02:31:36 2015 +0300
     1.2 +++ b/src/board.cc	Wed Jul 08 15:11:58 2015 +0300
     1.3 @@ -6,6 +6,7 @@
     1.4  #include "pnoise.h"
     1.5  #include "revol.h"
     1.6  #include "opt.h"
     1.7 +#include "shadow.h"
     1.8  
     1.9  
    1.10  #define HSIZE			1.0
    1.11 @@ -243,6 +244,11 @@
    1.12  		piece_obj->draw();
    1.13  	}
    1.14  
    1.15 +	// don't draw any UI stuff and highlighting polygons if we're doing
    1.16 +	// the shadow buffer pass
    1.17 +	if(shadow_pass)
    1.18 +		return;
    1.19 +
    1.20  	/*static const float pal[][3] = {
    1.21  		{1, 0, 0},
    1.22  		{0, 1, 0},
    1.23 @@ -262,13 +268,13 @@
    1.24  		glEnable(GL_TEXTURE_2D);
    1.25  		glBindTexture(GL_TEXTURE_2D, img_highlight.texture());
    1.26  		glEnable(GL_BLEND);
    1.27 -		glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    1.28 +		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    1.29  
    1.30  		glDepthMask(0);
    1.31  
    1.32  		glBegin(GL_TRIANGLES);
    1.33  		//glColor3fv(pal[idx % (sizeof pal / sizeof *pal)]);
    1.34 -		glColor4f(1, 1, 1, 0.5);
    1.35 +		glColor4f(1, 1, 1, 0.6);
    1.36  		glTexCoord2f(0, 0);
    1.37  		glVertex3f(slotbb[idx].tri0.v[0].x, slotbb[idx].tri0.v[0].y, slotbb[idx].tri0.v[0].z);
    1.38  		glTexCoord2f(1, 0);
    1.39 @@ -285,9 +291,22 @@
    1.40  
    1.41  		glDepthMask(1);
    1.42  
    1.43 +		glColor4f(0, 1, 0, 0.6);
    1.44 +		glEnable(GL_CULL_FACE);
    1.45 +		glCullFace(GL_FRONT);
    1.46 +		for(int i=0; i<MAX_PIECES; i++) {
    1.47 +			if(pieces[i].slot == idx) {
    1.48 +				Vector3 pos = piece_pos(pieces[i].slot, pieces[i].level);
    1.49 +				piece_obj->xform().set_translation(pos);
    1.50 +				piece_obj->xform().scale(Vector3(1.05, 1.05, 1.05));
    1.51 +				piece_obj->set_shader(0);
    1.52 +				piece_obj->draw();
    1.53 +			}
    1.54 +		}
    1.55 +		glCullFace(GL_BACK);
    1.56 +
    1.57  		glPopAttrib();
    1.58  	}
    1.59 -	// TODO slot highlighting
    1.60  }
    1.61  
    1.62