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

Comparing libgender/shader.C (file contents):
Revision 1.11 by root, Sun Oct 24 01:55:00 2004 UTC vs.
Revision 1.15 by root, Sun Oct 24 20:01:08 2004 UTC

1#include <cassert>
2
1#include "shader.h" 3#include "shader.h"
2#include "shader_vars.h" 4#include "shader_vars.h"
3 5
4namespace shader { 6namespace shader {
5 7
155 157
156 shader_object_i::shader_object_i (GLenum type) 158 shader_object_i::shader_object_i (GLenum type)
157 : type (type) 159 : type (type)
158 { 160 {
159 id = glCreateShaderObjectARB (type); 161 id = glCreateShaderObjectARB (type);
162 assert (id);
160 } 163 }
161 164
162 shader_object_i::~shader_object_i () 165 shader_object_i::~shader_object_i ()
163 { 166 {
164 glDeleteObjectARB (id); 167 glDeleteObjectARB (id);
232 printf ("INFOLOG<%s>\n", infolog); 235 printf ("INFOLOG<%s>\n", infolog);
233 abort (); 236 abort ();
234 } 237 }
235 } 238 }
236 239
240 program_object::program_object ()
241 {
242 id = glCreateProgramObjectARB ();
243 assert (id);
244
245 glAttachObjectARB (id, vsh->id);
246 glAttachObjectARB (id, fsh->id);
247 }
248
249 program_object::~program_object ()
250 {
251 glDeleteProgramsARB (1, &id);
252 }
253
254 void program_object::link ()
255 {
256 glLinkProgramARB (id);
257
258 GLint linked;
259 glGetObjectParameterivARB (id, GL_OBJECT_LINK_STATUS_ARB, &linked);
260
261 if (!linked)
262 {
263 char infolog[8192];
264 glGetInfoLogARB (id, 8192, NULL, infolog);
265 printf ("LINK-INFOLOG<%s>\n", infolog);
266 abort ();
267 }
268 }
269
237 void sl_func0::begin () const 270 void sl_func0::begin () const
238 { 271 {
239 cur->append_string (name_par); 272 cur->append_string (name_par);
240 } 273 }
241 274
320 vsh->start (); 353 vsh->start ();
321 354
322 temp_4f lightpos; 355 temp_4f lightpos;
323 temp_3f wpos; 356 temp_3f wpos;
324 357
325 lightpos = vec4 (10, -10, 0, 1); 358 lightpos = vec4 (0, 10, 0, 1);
326 wpos = xyz (gl.model_view_matrix * vin.vertex); 359 wpos = xyz (gl.model_view_matrix * vin.vertex);
327 vout.position = gl.model_view_matrix_inverse_transpose * vin.vertex; 360 vout.position = gl.model_view_matrix_inverse_transpose * vin.vertex;
328 vout.tex_coord[0] = vin.tex_coord[0]; 361 vout.tex_coord[0] = vin.tex_coord[0];
329 vout.tex_coord[1] = normalize (lightpos - wpos); 362 vout.tex_coord[1] = normalize (xyz (lightpos) - wpos);
330 vout.tex_coord[2] = normalize (wpos); 363 vout.tex_coord[2] = normalize (xyzx (wpos));
331 vout.tex_coord[3] = normalize (xyz (gl.model_view_matrix_inverse_transpose) * vin.normal); 364 //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); 365 //vout.tex_coord[4] = normalize (xyz (gl.projection_matrix_inverse_transpose) - wpos);
333 366
334 vsh->end (); 367 vsh->end ();
335 //vsh->compile (); 368 vsh->compile ();
336 369
337 fragment_shader fsh; 370 fragment_shader fsh;
338 371
339 fsh->start (); 372 fsh->start ();
340 373

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines