ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/shader.C
(Generate patch)

Comparing libgender/shader.C (file contents):
Revision 1.6 by root, Sat Oct 23 23:36:45 2004 UTC vs.
Revision 1.11 by root, Sun Oct 24 01:55:00 2004 UTC

3 3
4namespace shader { 4namespace shader {
5 5
6 refcounted::~refcounted () 6 refcounted::~refcounted ()
7 { 7 {
8#if 0 8#if 1
9 if (refcnt) 9 if (refcnt)
10 abort (); 10 abort ();
11#endif 11#endif
12 } 12 }
13 13
215 { 215 {
216 string src = source (); 216 string src = source ();
217 const char *sptr = src.data (); 217 const char *sptr = src.data ();
218 const int slen = src.size (); 218 const int slen = src.size ();
219 219
220 printf ("SOURCE<%s>\n", src.c_str ()); 220 printf ("SOURCE<%s>\n", src.c_str ());
221 abort ();
222 glShaderSourceARB (id, 1, &sptr, &slen); 221 glShaderSourceARB (id, 1, &sptr, &slen);
223 glCompileShaderARB (id); 222 glCompileShaderARB (id);
224 223
225 GLint compiled; 224 GLint compiled;
226 glGetObjectParameterivARB (id, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); 225 glGetObjectParameterivARB (id, GL_OBJECT_COMPILE_STATUS_ARB, &compiled);
233 printf ("INFOLOG<%s>\n", infolog); 232 printf ("INFOLOG<%s>\n", infolog);
234 abort (); 233 abort ();
235 } 234 }
236 } 235 }
237 236
237 void sl_func0::begin () const
238 {
239 cur->append_string (name_par);
240 }
241
242 void sl_func0::comma () const
243 {
244 cur->append (str_comma);
245 }
246
247 void sl_func0::end () const
248 {
249 str_rpar ();
250 }
251
238 void sl_float::operator ()() const 252 void sl_float::operator ()() const
239 { 253 {
240 char s[20]; 254 char s[20];
241 sprintf (s, "%g", c); 255 sprintf (s, "%g", c);
242 cur->append_string (s); 256 cur->append_string (s);
243 } 257 }
244 258
245 const sl_convert<vec2>::T sl_convert<vec2>::convert (const vec2 &v) 259 const sl_convert< ::vec2 >::T sl_convert< ::vec2 >::convert (const ::vec2 &v)
246 { 260 {
247 sl_string<60> s; 261 sl_string<60> s;
248 sprintf (s.str, "vec2 (%g, %g)", v.x, v.y); 262 sprintf (s.str, "vec2 (%g, %g)", v.x, v.y);
249 return s; 263 return s;
250 } 264 }
251 265
252 const sl_convert<vec3>::T sl_convert<vec3>::convert (const vec3 &v) 266 const sl_convert< ::vec3 >::T sl_convert< ::vec3 >::convert (const ::vec3 &v)
253 { 267 {
254 sl_string<80> s; 268 sl_string<80> s;
255 sprintf (s.str, "vec3 (%g, %g, %g)", v.x, v.y, v.z); 269 sprintf (s.str, "vec3 (%g, %g, %g)", v.x, v.y, v.z);
256 return s; 270 return s;
257 } 271 }
258 272
259 const sl_convert<vec4>::T sl_convert<vec4>::convert (const vec4 &v) 273 const sl_convert< ::vec4 >::T sl_convert< ::vec4 >::convert (const ::vec4 &v)
260 { 274 {
261 sl_string<100> s; 275 sl_string<100> s;
262 sprintf (s.str, "vec4 (%g, %g, %g, %g)", v.x, v.y, v.z, v.w); 276 sprintf (s.str, "vec4 (%g, %g, %g, %g)", v.x, v.y, v.z, v.w);
263 return s; 277 return s;
264 } 278 }
265 279
266 const fragment_const_string str_2sp (" "); 280 const fragment_const_string str_2sp (" ");
267 const fragment_const_string str_equal (" = "); 281 const fragment_const_string str_equal (" = ");
282 const fragment_const_string str_comma (", ");
268 const fragment_const_string str_endl (";\n"); 283 const fragment_const_string str_endl (";\n");
269 284
270 const sl_append_const_string str_plus (" + "); 285 const sl_append_const_string str_plus (" + ");
271 const sl_append_const_string str_minus (" - "); 286 const sl_append_const_string str_minus (" - ");
272 const sl_append_const_string str_mul (" * "); 287 const sl_append_const_string str_mul (" * ");
273 const sl_append_const_string str_div (" / "); 288 const sl_append_const_string str_div (" / ");
289 const sl_append_const_string str_mod (" % ");
274 290
275 const sl_append_const_string str_lpar ("("); 291 const sl_append_const_string str_lpar ("(");
276 const sl_append_const_string str_rpar (")"); 292 const sl_append_const_string str_rpar (")");
277 293
278 void swizzle_mask (sl_string<7> &s, int mask) 294 void swizzle_mask (sl_string<7> &s, int mask)
294 } 310 }
295 311
296 *str++ = 0; 312 *str++ = 0;
297 } 313 }
298 314
315
299 void debdebdebdebug ()//D 316 void debdebdebdebug ()//D
300 { 317 {
301 vertex_shader vsh; 318 vertex_shader vsh;
302 fragment_shader fsh;
303 temp_4f t1, t2;
304 sampler_2d s2d (1);
305 319
306 vsh->start (); 320 vsh->start ();
307 321
308 temp_4f lightpos; 322 temp_4f lightpos;
309 temp_3f wpos; 323 temp_3f wpos;
310 324
311 lightpos = vec4 (10, -10, 0, 1); 325 lightpos = vec4 (10, -10, 0, 1);
326 wpos = xyz (gl.model_view_matrix * vin.vertex);
312 vout.position = gl.model_view_matrix_inverse_transpose * vin.position; 327 vout.position = gl.model_view_matrix_inverse_transpose * vin.vertex;
313 328 vout.tex_coord[0] = vin.tex_coord[0];
314 z(wpos) = 5; 329 vout.tex_coord[1] = normalize (lightpos - wpos);
330 vout.tex_coord[2] = normalize (wpos);
331 vout.tex_coord[3] = normalize (xyz (gl.model_view_matrix_inverse_transpose) * vin.normal);
332 vout.tex_coord[4] = normalize (xyz (gl.projection_matrix_inverse_transpose) - wpos);
315 333
316 vsh->end (); 334 vsh->end ();
317 vsh->compile (); 335 //vsh->compile ();
336
337 fragment_shader fsh;
338
339 fsh->start ();
340
341 xyz (fout.frag_color) = noise3 (x (fin.frag_coord) * y (fin.frag_coord));
342
343 temp_1f spec_expon;
344 spec_expon = 200;
345
346 fsh->end ();
347 fsh->compile ();
348
349 //abort ();
318 } 350 }
319 351
320} 352}
321 353

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines