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

Comparing libgender/util.h (file contents):
Revision 1.53 by root, Fri Oct 29 17:21:54 2004 UTC vs.
Revision 1.54 by root, Fri Oct 29 22:32:49 2004 UTC

395 void clear () { diagonal (0.F); }; 395 void clear () { diagonal (0.F); };
396 void identity () { diagonal (1.F); }; 396 void identity () { diagonal (1.F); };
397 397
398 void print (); // ugly 398 void print (); // ugly
399 399
400 static const matrix translation (const vec3 &v); 400 static matrix translation (const vec3 &v);
401 static const matrix rotation (GLfloat degrees, const vec3 &axis); 401 static matrix rotation (GLfloat degrees, const vec3 &axis);
402 static matrix scaling (GLfloat sx, GLfloat sy, GLfloat sz, GLfloat w = 1.F);
402 403
403 matrix () { }; 404 matrix () { };
404 matrix (GLfloat diag) { diagonal (diag); }; 405 matrix (GLfloat diag) { diagonal (diag); };
405 }; 406 };
406 407
407 const matrix operator *(const matrix &a, const matrix &b); 408 matrix operator *(const matrix &a, const matrix &b);
408 const vec3 operator *(const matrix &a, const vec3 &v); 409 vec3 operator *(const matrix &a, const vec3 &v);
409 410
410 template<GLenum target> 411 template<GLenum target>
411 struct vertex_buffer_object_base { 412 struct vertex_buffer_object {
412 GLuint buffer; 413 GLuint buffer;
413 GLenum format; 414 GLenum format;
414 GLsizei count; 415 GLsizei count;
415 416
416 bool alloc () 417 bool alloc ()
441 void set (const vector<data> &d, GLenum usage = GL_STATIC_DRAW_ARB) 442 void set (const vector<data> &d, GLenum usage = GL_STATIC_DRAW_ARB)
442 { 443 {
443 set (&d[0], d.size (), usage); 444 set (&d[0], d.size (), usage);
444 } 445 }
445 446
446 vertex_buffer_object_base () 447 vertex_buffer_object ()
447 : buffer(0) 448 : buffer(0)
448 { 449 {
449 } 450 }
450 451
451 ~vertex_buffer_object_base () 452 ~vertex_buffer_object ()
452 { 453 {
453 if (buffer) 454 if (buffer)
454 glDeleteBuffersARB (1, &buffer); 455 glDeleteBuffersARB (1, &buffer);
455 } 456 }
456 457
458 { 459 {
459 return buffer; 460 return buffer;
460 } 461 }
461 }; 462 };
462 463
463 struct vertex_buffer_object : vertex_buffer_object_base<GL_ARRAY_BUFFER_ARB> { 464 struct vertex_buffer : vertex_buffer_object<GL_ARRAY_BUFFER_ARB> {
464 void bind () 465 void bind ()
465 { 466 {
466 vertex_buffer_object_base<GL_ARRAY_BUFFER_ARB>::bind (); 467 vertex_buffer_object<GL_ARRAY_BUFFER_ARB>::bind ();
467 glInterleavedArrays (format, 0, 0); 468 glInterleavedArrays (format, 0, 0);
468 } 469 }
469 470
470 void draw (GLenum mode, GLint first, GLsizei count) 471 void draw (GLenum mode, GLint first, GLsizei count)
471 { 472 {
472 bind (); 473 bind ();
473 glDrawArrays (mode, first, count); 474 glDrawArrays (mode, first, count);
474 } 475 }
475 }; 476 };
476 477
477 struct index_buffer_object : vertex_buffer_object_base<GL_ELEMENT_ARRAY_BUFFER_ARB> { 478 struct index_buffer : vertex_buffer_object<GL_ELEMENT_ARRAY_BUFFER_ARB> {
478 void draw (GLenum mode, GLint first, GLsizei count) 479 void draw (GLenum mode, GLint first, GLsizei count)
479 { 480 {
480 bind (); 481 bind ();
481 glDrawElements (mode, count, format, (GLushort*)0 + first); // only SHORT supported :( // first //D//TODO 482 glDrawElements (mode, count, format, (GLushort*)0 + first); // only SHORT supported :( // first //D//TODO
482 } 483 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines