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.13 by root, Sun Oct 24 16:06:56 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
246 program_object::~program_object ()
247 {
248 glDeleteProgramsARB (1, &id);
249 }
250
251 void program_object::link ()
252 {
253 glAttachObjectARB (id, vsh->id);
254 glAttachObjectARB (id, fsh->id);
255 glLinkProgramARB (id);
256
257 GLint linked;
258 glGetObjectParameterivARB (id, GL_OBJECT_LINK_STATUS_ARB, &linked);
259
260 if (!linked)
261 {
262 char infolog[8192];
263 glGetInfoLogARB (id, 8192, NULL, infolog);
264 printf ("LINK-INFOLOG<%s>\n", infolog);
265 abort ();
266 }
267 }
268
237 void sl_func0::begin () const 269 void sl_func0::begin () const
238 { 270 {
239 cur->append_string (name_par); 271 cur->append_string (name_par);
240 } 272 }
241 273
320 vsh->start (); 352 vsh->start ();
321 353
322 temp_4f lightpos; 354 temp_4f lightpos;
323 temp_3f wpos; 355 temp_3f wpos;
324 356
325 lightpos = vec4 (10, -10, 0, 1); 357 lightpos = vec4 (0, 10, 0, 1);
326 wpos = xyz (gl.model_view_matrix * vin.vertex); 358 wpos = xyz (gl.model_view_matrix * vin.vertex);
327 vout.position = gl.model_view_matrix_inverse_transpose * vin.vertex; 359 vout.position = gl.model_view_matrix_inverse_transpose * vin.vertex;
328 vout.tex_coord[0] = vin.tex_coord[0]; 360 vout.tex_coord[0] = vin.tex_coord[0];
329 vout.tex_coord[1] = normalize (lightpos - wpos); 361 vout.tex_coord[1] = normalize (lightpos - wpos);
330 vout.tex_coord[2] = normalize (wpos); 362 vout.tex_coord[2] = normalize (wpos);
331 vout.tex_coord[3] = normalize (xyz (gl.model_view_matrix_inverse_transpose) * vin.normal); 363 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); 364 vout.tex_coord[4] = normalize (xyz (gl.projection_matrix_inverse_transpose) - wpos);
333 365
334 vsh->end (); 366 vsh->end ();
335 //vsh->compile (); 367 vsh->compile ();
336 368
337 fragment_shader fsh; 369 fragment_shader fsh;
338 370
339 fsh->start (); 371 fsh->start ();
340 372

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines