… | |
… | |
4 | #include "shader_vars.h" |
4 | #include "shader_vars.h" |
5 | |
5 | |
6 | #include <sstream> |
6 | #include <sstream> |
7 | #include <iomanip> |
7 | #include <iomanip> |
8 | |
8 | |
9 | using namespace std; |
|
|
10 | |
|
|
11 | namespace shader { |
9 | namespace shader { |
12 | |
10 | |
|
|
11 | using namespace std; |
|
|
12 | |
13 | refcounted::~refcounted () |
13 | refcounted::~refcounted () |
14 | { |
14 | { |
15 | #if 1 |
|
|
16 | if (refcnt) |
15 | if (refcnt) |
17 | abort (); |
16 | abort (); |
18 | #endif |
|
|
19 | } |
17 | } |
20 | |
18 | |
21 | void refcounted::refcnt_dec () const |
19 | void refcounted::refcnt_dec () const |
22 | { |
20 | { |
23 | if (!--refcnt) |
21 | if (!--refcnt) |
… | |
… | |
376 | vertex_shader vsh; |
374 | vertex_shader vsh; |
377 | |
375 | |
378 | vsh->start (); |
376 | vsh->start (); |
379 | |
377 | |
380 | temp_4f lightpos; |
378 | temp_4f lightpos; |
381 | temp_3f wpos; |
379 | temp_4f wpos; |
382 | |
380 | |
383 | lightpos = vec4 (0, 10, 0, 1); |
381 | lightpos = vec4 (0, 10, 0, 1); |
384 | wpos = xyz (gl.model_view_matrix * vin.vertex); |
382 | wpos = gl.model_view_matrix * vin.vertex; |
385 | vout.position = vin.vertex * gl.model_view_matrix_inverse; |
383 | vout.position = vin.vertex * gl.model_view_matrix_inverse; |
386 | vout.tex_coord[0] = vin.tex_coord[0]; |
384 | vout.tex_coord[0] = vin.tex_coord[0]; |
387 | vout.tex_coord[1] = normalize (xyz (lightpos) - wpos); |
385 | vout.tex_coord[1] = normalize (lightpos - wpos); |
388 | vout.tex_coord[2] = normalize (xyzx (wpos)); |
386 | vout.tex_coord[2] = normalize (wpos); |
389 | //vout.tex_coord[3] = normalize (xyz (gl.model_view_matrix_inverse_transpose) * vin.normal); |
387 | //vout.tex_coord[3] = normalize (xyz (gl.model_view_matrix_inverse_transpose) * vin.normal); |
390 | //vout.tex_coord[4] = normalize (xyz (gl.projection_matrix_inverse_transpose) - wpos); |
388 | //vout.tex_coord[4] = normalize (xyz (gl.projection_matrix_inverse_transpose) - wpos); |
391 | |
389 | |
392 | vsh->end (); |
390 | vsh->end (); |
393 | vsh->compile (); |
391 | vsh->compile (); |