osg::GeoVBO Class Reference

#include <OSGGeoPumpFactory.h>

List of all members.

Public Member Functions

 GeoVBO (Window *win, Geometry *geo)
 ~GeoVBO ()
void clear (void)
void update (void)
void draw (void)
GLuint getPositions (void) const
GLuint getNormals (void) const
GLuint getColors (void) const
GLuint getSecColors (void) const
GLuint getTexCoords (void) const
GLuint getTexCoords1 (void) const
GLuint getTexCoords2 (void) const
GLuint getTexCoords3 (void) const
GLuint getTexCoords4 (void) const
GLuint getTexCoords5 (void) const
GLuint getTexCoords6 (void) const
GLuint getTexCoords7 (void) const
GLuint getIndices (void) const
void setDrawPropertiesMask (UInt16 draw_properties_mask)
UInt16 getDrawPropertiesMask (void) const

Private Attributes

GLuint _positions
GLuint _normals
GLuint _colors
GLuint _secColors
GLuint _texCoords
GLuint _texCoords1
GLuint _texCoords2
GLuint _texCoords3
GLuint _texCoords4
GLuint _texCoords5
GLuint _texCoords6
GLuint _texCoords7
GLuint _indices
UInt16 _draw_properties_mask
Window_win
Geometry_geo
bool _cleared

Detailed Description

Definition at line 242 of file OSGGeoPumpFactory.h.


Constructor & Destructor Documentation

GeoVBO::GeoVBO ( Window win,
Geometry geo 
)

Definition at line 2418 of file OSGGeoPumpFactory.cpp.

References update().

02418                                          :
02419     _positions(0),
02420     _normals(0),
02421     _colors(0),
02422     _secColors(0),
02423     _texCoords(0),
02424     _texCoords1(0),
02425     _texCoords2(0),
02426     _texCoords3(0),
02427     _texCoords4(0),
02428     _texCoords5(0),
02429     _texCoords6(0),
02430     _texCoords7(0),
02431     _indices(0),
02432     _draw_properties_mask(0xffff),
02433     _win(win),
02434     _geo(geo),
02435     _cleared(true)
02436 {
02437     update();
02438 }

GeoVBO::~GeoVBO (  ) 

Definition at line 2440 of file OSGGeoPumpFactory.cpp.

References clear().

02441 {
02442     clear();
02443 }


Member Function Documentation

void GeoVBO::clear ( void   ) 

Definition at line 2445 of file OSGGeoPumpFactory.cpp.

References _cleared, _colors, osg::GeoPumpFactory::_funcglDeleteBuffers, osg::GeoPumpFactory::_funcglDeleteBuffersARB, _indices, _normals, _positions, _secColors, _texCoords, _texCoords1, _texCoords2, _texCoords3, _texCoords4, _texCoords5, _texCoords6, _texCoords7, _win, osg::Window::getFunction(), GLuint(), and OSG_APIENTRY.

Referenced by ~GeoVBO().

02446 {
02447     // well ATI supports the GL_ARB_vertex_buffer_object extension but
02448     // not the ARB functions ...
02449     void (OSG_APIENTRY*_glDeleteBuffersARB)(GLsizei, const GLuint *)=
02450         reinterpret_cast<void (OSG_APIENTRY*)(GLsizei, const GLuint *)>(
02451             _win->getFunction(GeoPumpFactory::_funcglDeleteBuffers));
02452 
02453     if(_glDeleteBuffersARB == NULL)
02454     {
02455         _glDeleteBuffersARB = 
02456             reinterpret_cast<void (OSG_APIENTRY*)(GLsizei, const GLuint *)>(
02457                 _win->getFunction(GeoPumpFactory::_funcglDeleteBuffersARB));
02458     }
02459 
02460     if(_positions != 0)
02461     {
02462         _glDeleteBuffersARB(1, &_positions);
02463         _positions = 0;
02464     }
02465 
02466     if(_normals != 0)
02467     {
02468         _glDeleteBuffersARB(1, &_normals);
02469         _normals = 0;
02470     }
02471 
02472     if(_colors != 0)
02473     {
02474         _glDeleteBuffersARB(1, &_colors);
02475         _colors = 0;
02476     }
02477 
02478     if(_secColors != 0)
02479     {
02480         _glDeleteBuffersARB(1, &_secColors);
02481         _secColors = 0;
02482     }
02483 
02484     if(_texCoords != 0)
02485     {
02486         _glDeleteBuffersARB(1, &_texCoords);
02487         _texCoords = 0;
02488     }
02489 
02490     if(_texCoords1 != 0)
02491     {
02492         _glDeleteBuffersARB(1, &_texCoords1);
02493         _texCoords1 = 0;
02494     }
02495 
02496     if(_texCoords2 != 0)
02497     {
02498         _glDeleteBuffersARB(1, &_texCoords2);
02499         _texCoords2 = 0;
02500     }
02501 
02502     if(_texCoords3 != 0)
02503     {
02504         _glDeleteBuffersARB(1, &_texCoords3);
02505         _texCoords3 = 0;
02506     }
02507 
02508     if(_texCoords4 != 0)
02509     {
02510         _glDeleteBuffersARB(1, &_texCoords4);
02511         _texCoords4 = 0;
02512     }
02513 
02514     if(_texCoords5 != 0)
02515     {
02516         _glDeleteBuffersARB(1, &_texCoords5);
02517         _texCoords5 = 0;
02518     }
02519 
02520     if(_texCoords6 != 0)
02521     {
02522         _glDeleteBuffersARB(1, &_texCoords6);
02523         _texCoords6 = 0;
02524     }
02525 
02526     if(_texCoords7 != 0)
02527     {
02528         _glDeleteBuffersARB(1, &_texCoords7);
02529         _texCoords7 = 0;
02530     }
02531 
02532     if(_indices != 0)
02533     {
02534         _glDeleteBuffersARB(1, &_indices);
02535         _indices = 0;
02536     }
02537 
02538     _cleared = true;
02539 }

void GeoVBO::update ( void   ) 

Definition at line 2541 of file OSGGeoPumpFactory.cpp.

References _cleared, _colors, osg::GeoPumpFactory::_funcglBindBuffer, osg::GeoPumpFactory::_funcglBindBufferARB, osg::GeoPumpFactory::_funcglBufferData, osg::GeoPumpFactory::_funcglBufferDataARB, osg::GeoPumpFactory::_funcglBufferSubDataARB, osg::GeoPumpFactory::_funcglDeleteBuffers, osg::GeoPumpFactory::_funcglDeleteBuffersARB, osg::GeoPumpFactory::_funcglGenBuffers, osg::GeoPumpFactory::_funcglGenBuffersARB, _geo, _indices, _normals, _positions, _secColors, _texCoords, _texCoords1, _texCoords2, _texCoords3, _texCoords4, _texCoords5, _texCoords6, _texCoords7, _win, getColors(), osg::Window::getFunction(), getIndices(), getNormals(), getPositions(), getTexCoords(), getTexCoords1(), getTexCoords2(), getTexCoords3(), getTexCoords4(), getTexCoords5(), getTexCoords6(), getTexCoords7(), GL_ARRAY_BUFFER_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB, GL_STATIC_DRAW_ARB, GLuint(), OSG_APIENTRY, and pumpSetup2.

Referenced by GeoVBO(), and osg::Geometry::updateVBO().

02542 {
02543     GLenum usage = GL_STATIC_DRAW_ARB;
02544 
02545     Geometry *geo = _geo;
02546 
02547     pumpSetup2(Positions  , GeoPositionsPtr , getPositions );
02548     pumpSetup2(Colors     , GeoColorsPtr    , getColors    );
02549     pumpSetup2(SecColors  , GeoColorsPtr    , getSecondaryColors );
02550     pumpSetup2(TexCoords  , GeoTexCoordsPtr , getTexCoords  );
02551     pumpSetup2(TexCoords1 , GeoTexCoordsPtr , getTexCoords1 );
02552     pumpSetup2(TexCoords2 , GeoTexCoordsPtr , getTexCoords2 );
02553     pumpSetup2(TexCoords3 , GeoTexCoordsPtr , getTexCoords3 );
02554     pumpSetup2(TexCoords4 , GeoTexCoordsPtr , getTexCoords4 );
02555     pumpSetup2(TexCoords5 , GeoTexCoordsPtr , getTexCoords5 );
02556     pumpSetup2(TexCoords6 , GeoTexCoordsPtr , getTexCoords6 );
02557     pumpSetup2(TexCoords7 , GeoTexCoordsPtr , getTexCoords7 );
02558     pumpSetup2(Normals    , GeoNormalsPtr   , getNormals    );
02559 
02560     pumpSetup2(Indices    , GeoIndicesPtr   , getIndices    );
02561 
02562     void (OSG_APIENTRY*_glGenBuffersARB)(GLsizei, GLuint *)=
02563         reinterpret_cast<void (OSG_APIENTRY*)(GLsizei, GLuint *)>(
02564             _win->getFunction(GeoPumpFactory::_funcglGenBuffers));
02565 
02566     if(_glGenBuffersARB == NULL)
02567     {
02568         _glGenBuffersARB = 
02569             reinterpret_cast<void (OSG_APIENTRY*)(GLsizei, GLuint *)>(
02570                 _win->getFunction(GeoPumpFactory::_funcglGenBuffersARB));
02571     }
02572 
02573     void (OSG_APIENTRY*_glDeleteBuffersARB)(GLsizei, const GLuint *)=
02574         reinterpret_cast<void (OSG_APIENTRY*)(GLsizei, const GLuint *)>(
02575             _win->getFunction(GeoPumpFactory::_funcglDeleteBuffers));
02576 
02577     if(_glDeleteBuffersARB == NULL)
02578     {
02579         _glDeleteBuffersARB = 
02580             reinterpret_cast<void (OSG_APIENTRY*)(GLsizei, const GLuint *)>(
02581                 _win->getFunction(GeoPumpFactory::_funcglDeleteBuffersARB));
02582     }
02583 
02584     void (OSG_APIENTRY*_glBindBufferARB)(GLenum, GLuint)=
02585         reinterpret_cast<void (OSG_APIENTRY*)(GLenum, GLuint)>(
02586             _win->getFunction(GeoPumpFactory::_funcglBindBuffer));
02587 
02588     if(_glBindBufferARB == NULL)
02589     {
02590         _glBindBufferARB = 
02591             reinterpret_cast<void (OSG_APIENTRY*)(GLenum, GLuint)>(
02592                 _win->getFunction(GeoPumpFactory::_funcglBindBufferARB));
02593     }
02594 
02595     // typedef ptrdiff_t GLsizeiptrARB;
02596     void (OSG_APIENTRY*_glBufferDataARB)(GLenum, 
02597                                          ptrdiff_t, 
02598                                          const GLvoid *, 
02599                                          GLenum)=
02600         reinterpret_cast<void (OSG_APIENTRY*)(GLenum, 
02601                                               ptrdiff_t, 
02602                                               const GLvoid *, 
02603                                               GLenum)>(
02604            _win->getFunction(GeoPumpFactory::_funcglBufferData));
02605 
02606     if(_glBufferDataARB == NULL)
02607     {
02608         _glBufferDataARB = 
02609             reinterpret_cast<void (OSG_APIENTRY*)(GLenum, 
02610                                                   ptrdiff_t, 
02611                                                   const GLvoid *, 
02612                                                   GLenum)>(
02613                 _win->getFunction(GeoPumpFactory::_funcglBufferDataARB));
02614     }
02615 
02616 #if 0
02617     // typedef ptrdiff_t GLsizeiptrARB;
02618     // typedef ptrdiff_t GLintptrARB;
02619     void (OSG_APIENTRY*_glBufferSubDataARB)
02620                   (GLenum, ptrdiff_t, ptrdiff_t, const GLvoid *)=
02621             (void (OSG_APIENTRY*)(GLenum, ptrdiff_t, ptrdiff_t, const GLvoid *))
02622              _win->getFunction(GeoPumpFactory::_funcglBufferSubDataARB);
02623 #endif
02624 
02625     if(PositionsData)
02626     {
02627         if(_positions != 0)
02628             _glDeleteBuffersARB(1, &_positions);
02629 
02630         // calling _glBufferSubDataARB for changed data increases the
02631         // memory usage! why?
02632         _glGenBuffersARB(1, &_positions);
02633         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _positions);
02634         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, PositionsSize, PositionsData, usage);
02635     }
02636     else
02637     {
02638         if(_positions != 0)
02639         {
02640             _glDeleteBuffersARB(1, &_positions);
02641             _positions = 0;
02642         }
02643     }
02644 
02645     if(NormalsData)
02646     {
02647         if(_normals != 0)
02648             _glDeleteBuffersARB(1, &_normals);
02649     
02650         _glGenBuffersARB(1, &_normals);
02651         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _normals);
02652         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, NormalsSize, NormalsData, usage);
02653     }
02654     else
02655     {
02656         if(_normals != 0)
02657         {
02658             _glDeleteBuffersARB(1, &_normals);
02659             _normals = 0;
02660         }
02661     }
02662 
02663     if(ColorsData)
02664     {
02665         if(_colors != 0)
02666             _glDeleteBuffersARB(1, &_colors);
02667 
02668         _glGenBuffersARB(1, &_colors);
02669         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _colors);
02670         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, ColorsSize, ColorsData, usage);
02671     }
02672     else
02673     {
02674         if(_colors != 0)
02675         {
02676             _glDeleteBuffersARB(1, &_colors);
02677             _colors = 0;
02678         }
02679     }
02680 
02681     if(SecColorsData)
02682     {
02683         if(_secColors != 0)
02684             _glDeleteBuffersARB(1, &_secColors);
02685 
02686         _glGenBuffersARB(1, &_secColors);
02687         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _secColors);
02688         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, SecColorsSize, SecColorsData, usage);
02689     }
02690     else
02691     {
02692         if(_secColors != 0)
02693         {
02694             _glDeleteBuffersARB(1, &_secColors);
02695             _secColors = 0;
02696         }
02697     }
02698 
02699     if(TexCoordsData)
02700     {
02701         if(_texCoords != 0)
02702             _glDeleteBuffersARB(1, &_texCoords);
02703 
02704         _glGenBuffersARB(1, &_texCoords);
02705         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords);
02706         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoordsSize, TexCoordsData, usage);
02707     }
02708     else
02709     {
02710         if(_texCoords != 0)
02711         {
02712             _glDeleteBuffersARB(1, &_texCoords);
02713             _texCoords = 0;
02714         }
02715     }
02716 
02717     if(TexCoords1Data)
02718     {
02719         if(_texCoords1 != 0)
02720             _glDeleteBuffersARB(1, &_texCoords1);
02721 
02722         _glGenBuffersARB(1, &_texCoords1);
02723         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords1);
02724         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords1Size, TexCoords1Data, usage);
02725     }
02726     else
02727     {
02728         if(_texCoords1 != 0)
02729         {
02730             _glDeleteBuffersARB(1, &_texCoords1);
02731             _texCoords1 = 0;
02732         }
02733     }
02734 
02735     if(TexCoords2Data)
02736     {
02737         if(_texCoords2 != 0)
02738             _glDeleteBuffersARB(1, &_texCoords2);
02739 
02740         _glGenBuffersARB(1, &_texCoords2);
02741         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords2);
02742         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords2Size, TexCoords2Data, usage);
02743     }
02744     else
02745     {
02746         if(_texCoords2 != 0)
02747         {
02748             _glDeleteBuffersARB(1, &_texCoords2);
02749             _texCoords2 = 0;
02750         }
02751     }
02752 
02753     if(TexCoords3Data)
02754     {
02755         if(_texCoords3 != 0)
02756             _glDeleteBuffersARB(1, &_texCoords3);
02757 
02758         _glGenBuffersARB(1, &_texCoords3);
02759         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords3);
02760         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords3Size, TexCoords3Data, usage);
02761     }
02762     else
02763     {
02764         if(_texCoords3 != 0)
02765         {
02766             _glDeleteBuffersARB(1, &_texCoords3);
02767             _texCoords3 = 0;
02768         }
02769     }
02770 
02771     if(TexCoords4Data)
02772     {
02773         if(_texCoords4 != 0)
02774             _glDeleteBuffersARB(1, &_texCoords4);
02775 
02776         _glGenBuffersARB(1, &_texCoords4);
02777         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords4);
02778         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords4Size, TexCoords4Data, usage);
02779     }
02780     else
02781     {
02782         if(_texCoords4 != 0)
02783         {
02784             _glDeleteBuffersARB(1, &_texCoords4);
02785             _texCoords4 = 0;
02786         }
02787     }
02788 
02789     if(TexCoords5Data)
02790     {
02791         if(_texCoords5 != 0)
02792             _glDeleteBuffersARB(1, &_texCoords5);
02793 
02794         _glGenBuffersARB(1, &_texCoords5);
02795         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords5);
02796         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords5Size, TexCoords5Data, usage);
02797     }
02798     else
02799     {
02800         if(_texCoords5 != 0)
02801         {
02802             _glDeleteBuffersARB(1, &_texCoords5);
02803             _texCoords5 = 0;
02804         }
02805     }
02806 
02807     if(TexCoords6Data)
02808     {
02809         if(_texCoords6 != 0)
02810             _glDeleteBuffersARB(1, &_texCoords6);
02811 
02812         _glGenBuffersARB(1, &_texCoords6);
02813         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords6);
02814         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords6Size, TexCoords6Data, usage);
02815     }
02816     else
02817     {
02818         if(_texCoords6 != 0)
02819         {
02820             _glDeleteBuffersARB(1, &_texCoords6);
02821             _texCoords6 = 0;
02822         }
02823     }
02824 
02825     if(TexCoords7Data)
02826     {
02827         if(_texCoords7 != 0)
02828             _glDeleteBuffersARB(1, &_texCoords7);
02829 
02830         _glGenBuffersARB(1, &_texCoords7);
02831         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords7);
02832         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords7Size, TexCoords7Data, usage);
02833     }
02834     else
02835     {
02836         if(_texCoords7 != 0)
02837         {
02838             _glDeleteBuffersARB(1, &_texCoords7);
02839             _texCoords7 = 0;
02840         }
02841     }
02842 
02843     if(IndicesData)
02844     {
02845         if(_indices != 0)
02846             _glDeleteBuffersARB(1, &_indices);
02847 
02848         _glGenBuffersARB(1, &_indices);
02849         _glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, _indices);
02850         _glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, IndicesSize, IndicesData, usage);
02851     }
02852     else
02853     {
02854         if(_indices != 0)
02855         {
02856             _glDeleteBuffersARB(1, &_indices);
02857             _indices = 0;
02858         }
02859     }
02860 
02861     _glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
02862     _glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
02863 
02864     _cleared = false;
02865 }

void GeoVBO::draw ( void   ) 

Definition at line 2867 of file OSGGeoPumpFactory.cpp.

References _cleared, _colors, _draw_properties_mask, osg::GeoPumpFactory::_funcglBindBuffer, osg::GeoPumpFactory::_funcglBindBufferARB, osg::GeoPumpFactory::_funcglClientActiveTextureARB, osg::GeoPumpFactory::_funcglDrawRangeElementsEXT, osg::GeoPumpFactory::_funcglSecondaryColorPointer, _geo, _indices, _normals, _positions, _secColors, _texCoords, _texCoords1, _texCoords2, _texCoords3, _texCoords4, _texCoords5, _texCoords6, _texCoords7, _win, FWARNING, osg::GeometryBase::getColors(), osg::Window::getFunction(), osg::GeometryBase::getHighindices(), getIndices(), osg::GeometryBase::getLowindices(), osg::GeometryBase::getNormals(), osg::GeometryBase::getPositions(), osg::GeometryBase::getSecondaryColors(), osg::GeometryBase::getTexCoords(), osg::GeometryBase::getTexCoords1(), osg::GeometryBase::getTexCoords2(), osg::GeometryBase::getTexCoords3(), osg::GeometryBase::getTexCoords4(), osg::GeometryBase::getTexCoords5(), osg::GeometryBase::getTexCoords6(), osg::GeometryBase::getTexCoords7(), GL_ARRAY_BUFFER_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB, GL_SECONDARY_COLOR_ARRAY_EXT, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, GL_TEXTURE2_ARB, GL_TEXTURE3_ARB, GL_TEXTURE4_ARB, GL_TEXTURE5_ARB, GL_TEXTURE6_ARB, GL_TEXTURE7_ARB, GLuint(), osg::Geometry::MapColor, osg::Geometry::MapNormal, osg::Geometry::MapPosition, osg::Geometry::MapSecondaryColor, osg::Geometry::MapTexCoords, osg::Geometry::MapTexCoords1, osg::Geometry::MapTexCoords2, osg::Geometry::MapTexCoords3, osg::Geometry::MapTexCoords4, osg::Geometry::MapTexCoords5, osg::Geometry::MapTexCoords6, osg::Geometry::MapTexCoords7, osg::NullFC, OSG_APIENTRY, and pumpSetup.

Referenced by osg::Geometry::drawVBO().

02868 {
02869     if(_cleared)
02870         return;
02871 
02872     void (OSG_APIENTRY*_glBindBufferARB)(GLenum, GLuint)=
02873         reinterpret_cast<void (OSG_APIENTRY*)(GLenum, GLuint)>(
02874             _win->getFunction(GeoPumpFactory::_funcglBindBuffer));
02875 
02876     if(_glBindBufferARB == NULL)
02877     {
02878         _glBindBufferARB = 
02879             reinterpret_cast<void (OSG_APIENTRY*)(GLenum, GLuint)>(
02880                 _win->getFunction(GeoPumpFactory::_funcglBindBufferARB));
02881     }
02882 
02883     // removed the hasExtension(GeoPumpFactory::_extDrawRangeElements) and
02884     // hasExtension(GeoPumpFactory::_extMultitexture) calls with VBO support
02885     // this extensions are also supported!
02886 
02887     Geometry *geo = _geo;
02888     Int16 modified=0;
02889 
02890     GeoPositionsPtr PositionsPtr = geo->getPositions();
02891     if (PositionsPtr != NullFC &&
02892         (_draw_properties_mask & Geometry::MapPosition))
02893     {
02894         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _positions);
02895         glVertexPointer(PositionsPtr->getDimension(), PositionsPtr->getFormat(),
02896                         0, NULL);
02897         glEnableClientState(GL_VERTEX_ARRAY);
02898         modified|=(1<<0);
02899     }
02900 
02901     GeoNormalsPtr NormalsPtr = geo->getNormals();
02902     if (NormalsPtr != NullFC &&
02903         (_draw_properties_mask & Geometry::MapNormal))
02904     {
02905         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _normals);
02906         glNormalPointer(NormalsPtr->getFormat(), 0, NULL);
02907         glEnableClientState(GL_NORMAL_ARRAY);
02908         modified|=(1<<3);
02909     }
02910 
02911     GeoColorsPtr ColorsPtr = geo->getColors();
02912     if (ColorsPtr != NullFC &&
02913         (_draw_properties_mask & Geometry::MapColor))
02914     {
02915         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _colors);
02916         glColorPointer(ColorsPtr->getDimension(), ColorsPtr->getFormat(), 0,
02917                        NULL);
02918         glEnableClientState(GL_COLOR_ARRAY);
02919         modified|=(1<<1);
02920     }
02921 
02922     GeoColorsPtr SecColorsPtr = geo->getSecondaryColors();
02923     if (SecColorsPtr != NullFC &&
02924         (_draw_properties_mask & Geometry::MapSecondaryColor))
02925     {
02926         void (OSG_APIENTRY*_glSecondaryColorPointerEXT)
02927               (GLint size,GLenum type,GLsizei stride,const GLvoid *pointer)=
02928             reinterpret_cast<void (OSG_APIENTRY*)(GLint size,
02929                                                   GLenum type,
02930                                                   GLsizei stride,
02931                                                   const GLvoid *pointer)>(
02932                _win->getFunction(GeoPumpFactory::_funcglSecondaryColorPointer));
02933 
02934         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _secColors);
02935         _glSecondaryColorPointerEXT(SecColorsPtr->getDimension(),
02936                                    SecColorsPtr->getFormat(),
02937                                    0, NULL);
02938         glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
02939         modified|=(1<<2);
02940     }
02941 
02942     GeoTexCoordsPtr TexCoordsPtr = geo->getTexCoords();
02943     if (TexCoordsPtr != NullFC &&
02944         (_draw_properties_mask & Geometry::MapTexCoords))
02945     {
02946         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02947             reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(
02948                 _win->getFunction(
02949                     GeoPumpFactory::_funcglClientActiveTextureARB));
02950 
02951         _glClientActiveTextureARB(GL_TEXTURE0_ARB);
02952 
02953         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords);
02954         glTexCoordPointer (TexCoordsPtr->getDimension(), 
02955                            TexCoordsPtr->getFormat(),
02956                            0, NULL);
02957         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02958         modified|=(1<<4);
02959     }
02960 
02961     GeoTexCoordsPtr TexCoords1Ptr = geo->getTexCoords1();
02962     if (TexCoords1Ptr != NullFC &&
02963         (_draw_properties_mask & Geometry::MapTexCoords1))
02964     {
02965         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02966             reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(
02967                 _win->getFunction(
02968                     GeoPumpFactory::_funcglClientActiveTextureARB));
02969 
02970         _glClientActiveTextureARB(GL_TEXTURE1_ARB);
02971         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords1);
02972         glTexCoordPointer (TexCoords1Ptr->getDimension(), 
02973                            TexCoords1Ptr->getFormat(),
02974                            0, NULL);
02975         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02976         modified|=(1<<5);
02977     }
02978 
02979     GeoTexCoordsPtr TexCoords2Ptr = geo->getTexCoords2();
02980     if (TexCoords2Ptr != NullFC &&
02981         (_draw_properties_mask & Geometry::MapTexCoords2))
02982     {
02983         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02984             reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(
02985                 _win->getFunction(
02986                     GeoPumpFactory::_funcglClientActiveTextureARB));
02987 
02988         _glClientActiveTextureARB(GL_TEXTURE2_ARB);
02989 
02990         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords2);
02991         glTexCoordPointer (TexCoords2Ptr->getDimension(), 
02992                            TexCoords2Ptr->getFormat(),
02993                            0, NULL);
02994         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02995         modified|=(1<<6);
02996     }
02997 
02998     GeoTexCoordsPtr TexCoords3Ptr = geo->getTexCoords3();
02999     if (TexCoords3Ptr != NullFC &&
03000         (_draw_properties_mask & Geometry::MapTexCoords3))
03001     {
03002         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
03003             reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(
03004                 _win->getFunction(
03005                     GeoPumpFactory::_funcglClientActiveTextureARB));
03006 
03007         _glClientActiveTextureARB(GL_TEXTURE3_ARB);
03008 
03009         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords3);
03010         glTexCoordPointer (TexCoords3Ptr->getDimension(), 
03011                            TexCoords3Ptr->getFormat(),
03012                            0, NULL);
03013         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
03014         modified|=(1<<7);
03015     }
03016 
03017     GeoTexCoordsPtr TexCoords4Ptr = geo->getTexCoords4();
03018     if (TexCoords4Ptr != NullFC &&
03019         (_draw_properties_mask & Geometry::MapTexCoords4))
03020     {
03021         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
03022             reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(
03023                 _win->getFunction(
03024                     GeoPumpFactory::_funcglClientActiveTextureARB));
03025 
03026         _glClientActiveTextureARB(GL_TEXTURE4_ARB);
03027 
03028         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords4);
03029         glTexCoordPointer (TexCoords4Ptr->getDimension(), 
03030                            TexCoords4Ptr->getFormat(),
03031                            0, NULL);
03032         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
03033         modified|=(1<<8);
03034     }
03035 
03036     GeoTexCoordsPtr TexCoords5Ptr = geo->getTexCoords5();
03037     if (TexCoords5Ptr != NullFC &&
03038         (_draw_properties_mask & Geometry::MapTexCoords5))
03039     {
03040         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
03041             reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(
03042                 _win->getFunction(
03043                     GeoPumpFactory::_funcglClientActiveTextureARB));
03044 
03045         _glClientActiveTextureARB(GL_TEXTURE5_ARB);
03046 
03047         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords5);
03048         glTexCoordPointer (TexCoords5Ptr->getDimension(), 
03049                            TexCoords5Ptr->getFormat(),
03050                            0, NULL);
03051         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
03052         modified|=(1<<9);
03053     }
03054 
03055     GeoTexCoordsPtr TexCoords6Ptr = geo->getTexCoords6();
03056     if (TexCoords6Ptr != NullFC &&
03057         (_draw_properties_mask & Geometry::MapTexCoords6))
03058     {
03059         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
03060             reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(
03061                 _win->getFunction(
03062                     GeoPumpFactory::_funcglClientActiveTextureARB));
03063 
03064         _glClientActiveTextureARB(GL_TEXTURE6_ARB);
03065 
03066         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords6);
03067         glTexCoordPointer (TexCoords6Ptr->getDimension(), 
03068                            TexCoords6Ptr->getFormat(),
03069                            0, NULL);
03070         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
03071         modified|=(1<<10);
03072     }
03073 
03074     GeoTexCoordsPtr TexCoords7Ptr = geo->getTexCoords7();
03075     if (TexCoords7Ptr != NullFC &&
03076         (_draw_properties_mask & Geometry::MapTexCoords7))
03077     {
03078         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
03079             reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(
03080                 _win->getFunction(
03081                     GeoPumpFactory::_funcglClientActiveTextureARB));
03082 
03083         _glClientActiveTextureARB(GL_TEXTURE7_ARB);
03084 
03085         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords7);
03086         glTexCoordPointer (TexCoords7Ptr->getDimension(), TexCoords7Ptr->getFormat(),
03087                            0, NULL);
03088         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
03089         modified|=(1<<11);
03090     }
03091 
03092     pumpSetup(Lengths    , GeoPLengthsPtr  , getLengths    );
03093     pumpSetup(Types      , GeoPTypesPtr    , getTypes      );
03094     pumpSetup(Indices    , GeoIndicesPtr   , getIndices    );
03095     IndicesData = IndicesData; // workaround for irix compiler.
03096     
03097     UInt32 lendummy;
03098     UInt32 LengthsSize;
03099     bool   len16 = false;
03100 
03101     if(LengthsPtr != NullFC && LengthsData != NULL)
03102     {
03103         LengthsSize = LengthsPtr->getSize();
03104         len16 = (LengthsPtr->getFormatSize() == 2);
03105     }
03106     else
03107     {
03108         LengthsSize = 1;
03109         LengthsData = reinterpret_cast<GLubyte *>(&lendummy);
03110         lendummy = PositionsPtr->getSize();
03111     }
03112 
03113     UInt32 LengthsInd = 0, TypesInd = 0, IndicesInd = 0, 
03114            IndicesSize = IndicesPtr->getSize();
03115 
03116     void (OSG_APIENTRY *osgGLDrawRangeElementsEXT)(GLenum mode, 
03117                                                    GLuint start,
03118                                                    GLuint end, 
03119                                                    GLsizei count, 
03120                                                    GLenum type, 
03121                                                    const GLvoid*indices) =
03122         reinterpret_cast<void (OSG_APIENTRY *)(GLenum mode, 
03123                                                GLuint start,
03124                                                GLuint end, 
03125                                                GLsizei count, 
03126                                                GLenum type, 
03127                                                const GLvoid*indices)>(
03128             _win->getFunction(GeoPumpFactory::_funcglDrawRangeElementsEXT));
03129 
03130     _glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, _indices);
03131 
03132     if(len16 == false)
03133     {
03134         for(LengthsInd = 0; LengthsInd < LengthsSize; LengthsInd++)
03135         {
03136             UInt32 count  = *reinterpret_cast<UInt32*>(LengthsData + LengthsInd * LengthsStride);
03137             // for vbo's we need only a offset!
03138             UInt8 *vind = static_cast<UInt8 *>(NULL) + IndicesStride * IndicesInd;
03139             IndicesInd += count;
03140 
03141             if(count != 0)
03142             {
03143                 osgGLDrawRangeElementsEXT(*(TypesData + TypesInd++ * TypesStride),
03144                                           geo->getLowindices(LengthsInd),
03145                                           geo->getHighindices(LengthsInd),
03146                                           count,
03147                                           IndicesPtr->getFormat(), 
03148                                           vind);
03149             }
03150         }
03151     }
03152     else if(len16 == true)
03153     {
03154         for(LengthsInd = 0; LengthsInd < LengthsSize; LengthsInd++)
03155         {
03156             UInt16 count  = *reinterpret_cast<UInt16*>(LengthsData + LengthsInd * LengthsStride);
03157             // for vbo's we need only a offset!
03158             UInt8 *vind = static_cast<UInt8 *>(NULL) + IndicesStride * IndicesInd;
03159             IndicesInd += count;
03160 
03161             if(count != 0)
03162             {
03163                 osgGLDrawRangeElementsEXT(*(TypesData + TypesInd++ * TypesStride),
03164                                           geo->getLowindices(LengthsInd),
03165                                           geo->getHighindices(LengthsInd),
03166                                           count,
03167                                           IndicesPtr->getFormat(),
03168                                           vind);
03169             }
03170         }
03171     }
03172     else
03173     {
03174         FWARNING(("VBO::draw: unknown Lengths format size\n"));
03175     }
03176 
03177     if(modified&(1<<0)) glDisableClientState(GL_VERTEX_ARRAY);
03178     if(modified&(1<<1)) glDisableClientState(GL_COLOR_ARRAY);
03179     if(modified&(1<<2)) glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
03180     if(modified&(1<<3)) glDisableClientState(GL_NORMAL_ARRAY);
03181 
03182     void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
03183         reinterpret_cast<void (OSG_APIENTRY*) (GLenum type)>(_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB));
03184 
03185     if(modified&(1<<4))
03186     {
03187         _glClientActiveTextureARB(GL_TEXTURE0_ARB);
03188         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03189     }
03190     
03191     if(modified&(1<<5))
03192     {
03193         _glClientActiveTextureARB(GL_TEXTURE1_ARB);
03194         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03195     }
03196     
03197     if(modified&(1<<6))
03198     {
03199         _glClientActiveTextureARB(GL_TEXTURE2_ARB);
03200         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03201     }
03202     
03203     if(modified&(1<<7))
03204     {
03205         _glClientActiveTextureARB(GL_TEXTURE3_ARB);
03206         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03207     }
03208 
03209     if(modified&(1<<8))
03210     {
03211         _glClientActiveTextureARB(GL_TEXTURE4_ARB);
03212         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03213     }
03214 
03215     if(modified&(1<<9))
03216     {
03217         _glClientActiveTextureARB(GL_TEXTURE5_ARB);
03218         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03219     }
03220 
03221     if(modified&(1<<10))
03222     {
03223         _glClientActiveTextureARB(GL_TEXTURE6_ARB);
03224         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03225     }
03226 
03227     if(modified&(1<<11))
03228     {
03229         _glClientActiveTextureARB(GL_TEXTURE7_ARB);
03230         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03231     }
03232 
03233     _glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
03234     _glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
03235 }

GLuint osg::GeoVBO::getPositions ( void   )  const [inline]

Definition at line 65 of file OSGGeoPumpFactory.inl.

References _positions.

Referenced by update().

00066 {
00067     return _positions;
00068 }

GLuint osg::GeoVBO::getNormals ( void   )  const [inline]

Definition at line 71 of file OSGGeoPumpFactory.inl.

References _normals.

Referenced by update().

00072 { 
00073     return _normals;
00074 }

GLuint osg::GeoVBO::getColors ( void   )  const [inline]

Definition at line 77 of file OSGGeoPumpFactory.inl.

References _colors.

Referenced by update().

00078 {
00079     return _colors;
00080 }

GLuint osg::GeoVBO::getSecColors ( void   )  const [inline]

Definition at line 83 of file OSGGeoPumpFactory.inl.

References _secColors.

00084 {
00085     return _secColors;
00086 }

GLuint osg::GeoVBO::getTexCoords ( void   )  const [inline]

Definition at line 89 of file OSGGeoPumpFactory.inl.

References _texCoords.

Referenced by update().

00090 {
00091     return _texCoords;
00092 }

GLuint osg::GeoVBO::getTexCoords1 ( void   )  const [inline]

Definition at line 95 of file OSGGeoPumpFactory.inl.

References _texCoords1.

Referenced by update().

00096 {
00097     return _texCoords1;
00098 }

GLuint osg::GeoVBO::getTexCoords2 ( void   )  const [inline]

Definition at line 101 of file OSGGeoPumpFactory.inl.

References _texCoords2.

Referenced by update().

00102 {
00103     return _texCoords2;
00104 }

GLuint osg::GeoVBO::getTexCoords3 ( void   )  const [inline]

Definition at line 107 of file OSGGeoPumpFactory.inl.

References _texCoords3.

Referenced by update().

00108 {
00109     return _texCoords3;
00110 }

GLuint osg::GeoVBO::getTexCoords4 ( void   )  const [inline]

Definition at line 113 of file OSGGeoPumpFactory.inl.

References _texCoords4.

Referenced by update().

00114 {
00115     return _texCoords4;
00116 }

GLuint osg::GeoVBO::getTexCoords5 ( void   )  const [inline]

Definition at line 119 of file OSGGeoPumpFactory.inl.

References _texCoords5.

Referenced by update().

00120 {
00121     return _texCoords5;
00122 }

GLuint osg::GeoVBO::getTexCoords6 ( void   )  const [inline]

Definition at line 125 of file OSGGeoPumpFactory.inl.

References _texCoords6.

Referenced by update().

00126 {
00127     return _texCoords6;
00128 }

GLuint osg::GeoVBO::getTexCoords7 ( void   )  const [inline]

Definition at line 131 of file OSGGeoPumpFactory.inl.

References _texCoords7.

Referenced by update().

00132 {
00133     return _texCoords7;
00134 }

GLuint osg::GeoVBO::getIndices ( void   )  const [inline]

Definition at line 137 of file OSGGeoPumpFactory.inl.

References _indices.

Referenced by draw(), and update().

00138 {
00139     return _indices;
00140 }

void osg::GeoVBO::setDrawPropertiesMask ( UInt16  draw_properties_mask  )  [inline]

Definition at line 143 of file OSGGeoPumpFactory.inl.

References _draw_properties_mask.

Referenced by osg::RenderAction::drawDepth().

00144 {
00145     _draw_properties_mask = draw_properties_mask;
00146 }

UInt16 osg::GeoVBO::getDrawPropertiesMask ( void   )  const [inline]

Definition at line 149 of file OSGGeoPumpFactory.inl.

References _draw_properties_mask.

Referenced by osg::RenderAction::drawDepth().

00150 {
00151     return _draw_properties_mask;
00152 }


Member Data Documentation

GLuint osg::GeoVBO::_positions [private]

Definition at line 272 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getPositions(), and update().

GLuint osg::GeoVBO::_normals [private]

Definition at line 273 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getNormals(), and update().

GLuint osg::GeoVBO::_colors [private]

Definition at line 274 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getColors(), and update().

GLuint osg::GeoVBO::_secColors [private]

Definition at line 275 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getSecColors(), and update().

GLuint osg::GeoVBO::_texCoords [private]

Definition at line 276 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getTexCoords(), and update().

GLuint osg::GeoVBO::_texCoords1 [private]

Definition at line 277 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getTexCoords1(), and update().

GLuint osg::GeoVBO::_texCoords2 [private]

Definition at line 278 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getTexCoords2(), and update().

GLuint osg::GeoVBO::_texCoords3 [private]

Definition at line 279 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getTexCoords3(), and update().

GLuint osg::GeoVBO::_texCoords4 [private]

Definition at line 280 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getTexCoords4(), and update().

GLuint osg::GeoVBO::_texCoords5 [private]

Definition at line 281 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getTexCoords5(), and update().

GLuint osg::GeoVBO::_texCoords6 [private]

Definition at line 282 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getTexCoords6(), and update().

GLuint osg::GeoVBO::_texCoords7 [private]

Definition at line 283 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getTexCoords7(), and update().

GLuint osg::GeoVBO::_indices [private]

Definition at line 284 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), getIndices(), and update().

Definition at line 286 of file OSGGeoPumpFactory.h.

Referenced by draw(), getDrawPropertiesMask(), and setDrawPropertiesMask().

Definition at line 288 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), and update().

Definition at line 289 of file OSGGeoPumpFactory.h.

Referenced by draw(), and update().

bool osg::GeoVBO::_cleared [private]

Definition at line 290 of file OSGGeoPumpFactory.h.

Referenced by clear(), draw(), and update().


The documentation for this class was generated from the following files:

Generated on 8 Feb 2010 for OpenSG by  doxygen 1.6.1