dungeon_crawler

diff prototype/src/mesh.cc @ 35:d0e93b4d9ec9

normal mapping
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 28 Aug 2012 06:28:22 +0300
parents cbf86e5198a9
children 84a56fb24850
line diff
     1.1 --- a/prototype/src/mesh.cc	Tue Aug 28 03:34:56 2012 +0300
     1.2 +++ b/prototype/src/mesh.cc	Tue Aug 28 06:28:22 2012 +0300
     1.3 @@ -177,7 +177,7 @@
     1.4  	glGetIntegerv(GL_CURRENT_PROGRAM, &prog);
     1.5  	glUseProgram(0);
     1.6  
     1.7 -	Vector3 *varr, *narr;
     1.8 +	Vector3 *varr, *narr, *tarr;
     1.9  
    1.10  	glBindBuffer(GL_ARRAY_BUFFER, vbo[MESH_ATTR_VERTEX]);
    1.11  	varr = (Vector3*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
    1.12 @@ -185,17 +185,27 @@
    1.13  	glBindBuffer(GL_ARRAY_BUFFER, vbo[MESH_ATTR_NORMAL]);
    1.14  	narr = (Vector3*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
    1.15  
    1.16 +	glBindBuffer(GL_ARRAY_BUFFER, vbo[MESH_ATTR_TANGENT]);
    1.17 +	tarr = (Vector3*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
    1.18 +
    1.19  	glBegin(GL_LINES);
    1.20  	for(unsigned int i=0; i<nverts; i++) {
    1.21  		glColor3f(0, 1, 0);
    1.22  		glVertex3f(varr->x, varr->y, varr->z);
    1.23  		glVertex3f(varr->x + narr->x * NSZ, varr->y + narr->y * NSZ, varr->z + narr->z * NSZ);
    1.24 +
    1.25 +		glColor3f(1, 1, 0);
    1.26 +		glVertex3f(varr->x, varr->y, varr->z);
    1.27 +		glVertex3f(varr->x + tarr->x * NSZ, varr->y + tarr->y * NSZ, varr->z + tarr->z * NSZ);
    1.28  		varr++;
    1.29  		narr++;
    1.30 +		tarr++;
    1.31  	}
    1.32  	glEnd();
    1.33  
    1.34  	glUnmapBuffer(GL_ARRAY_BUFFER);
    1.35 +	glBindBuffer(GL_ARRAY_BUFFER, vbo[MESH_ATTR_NORMAL]);
    1.36 +	glUnmapBuffer(GL_ARRAY_BUFFER);
    1.37  	glBindBuffer(GL_ARRAY_BUFFER, vbo[MESH_ATTR_VERTEX]);
    1.38  	glUnmapBuffer(GL_ARRAY_BUFFER);
    1.39