osg::GeoVBO Class Reference

#include <OSGGeoPumpFactory.h>

List of all members.

Public Member Functions

 GeoVBO (Window *win, Geometry *geo)
 ~GeoVBO ()
void update (void)
void draw (void)

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
Window_win
Geometry_geo


Detailed Description

Definition at line 242 of file OSGGeoPumpFactory.h.


Constructor & Destructor Documentation

GeoVBO::GeoVBO ( Window win,
Geometry geo 
)

Definition at line 2246 of file OSGGeoPumpFactory.cpp.

References update().

02246                                          :
02247     _win(win),
02248     _geo(geo),
02249     _positions(0),
02250     _normals(0),
02251     _colors(0),
02252     _secColors(0),
02253     _texCoords(0),
02254     _texCoords1(0),
02255     _texCoords2(0),
02256     _texCoords3(0),
02257     _texCoords4(0),
02258     _texCoords5(0),
02259     _texCoords6(0),
02260     _texCoords7(0),
02261     _indices(0)
02262 {
02263     update();
02264 }

GeoVBO::~GeoVBO (  ) 

Definition at line 2266 of file OSGGeoPumpFactory.cpp.

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

02267 {
02268     // well ATI supports the GL_ARB_vertex_buffer_object extension but
02269     // not the ARB functions ...
02270 
02271     void (OSG_APIENTRY*_glDeleteBuffersARB)
02272                   (GLsizei, const GLuint *)=
02273             (void (OSG_APIENTRY*)(GLsizei, const GLuint *))
02274              _win->getFunction(GeoPumpFactory::_funcglDeleteBuffers);
02275 
02276     if(_glDeleteBuffersARB == NULL)
02277     {
02278         _glDeleteBuffersARB = (void (OSG_APIENTRY*)(GLsizei, const GLuint *))
02279              _win->getFunction(GeoPumpFactory::_funcglDeleteBuffersARB);
02280     }
02281 
02282     if(_positions != 0)
02283         _glDeleteBuffersARB(1, &_positions);
02284 
02285     if(_normals != 0)
02286         _glDeleteBuffersARB(1, &_normals);
02287 
02288     if(_colors != 0)
02289         _glDeleteBuffersARB(1, &_colors);
02290 
02291     if(_secColors != 0)
02292         _glDeleteBuffersARB(1, &_secColors);
02293 
02294     if(_texCoords != 0)
02295         _glDeleteBuffersARB(1, &_texCoords);
02296 
02297     if(_texCoords1 != 0)
02298         _glDeleteBuffersARB(1, &_texCoords1);
02299 
02300     if(_texCoords2 != 0)
02301         _glDeleteBuffersARB(1, &_texCoords2);
02302 
02303     if(_texCoords3 != 0)
02304         _glDeleteBuffersARB(1, &_texCoords3);
02305 
02306     if(_texCoords4 != 0)
02307         _glDeleteBuffersARB(1, &_texCoords4);
02308 
02309     if(_texCoords5 != 0)
02310         _glDeleteBuffersARB(1, &_texCoords5);
02311 
02312     if(_texCoords6 != 0)
02313         _glDeleteBuffersARB(1, &_texCoords6);
02314 
02315     if(_texCoords7 != 0)
02316         _glDeleteBuffersARB(1, &_texCoords7);
02317 
02318     if(_indices != 0)
02319         _glDeleteBuffersARB(1, &_indices);
02320 }


Member Function Documentation

void GeoVBO::update ( void   ) 

Definition at line 2322 of file OSGGeoPumpFactory.cpp.

References _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, osg::Window::getFunction(), GL_ARRAY_BUFFER_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB, GL_STATIC_DRAW_ARB, GLenum, GLsizei, GLuint(), OSG_APIENTRY, and pumpSetup2.

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

02323 {
02324     GLenum usage = GL_STATIC_DRAW_ARB;
02325 
02326     Geometry *geo = _geo;
02327 
02328     pumpSetup2(Positions  , GeoPositionsPtr , getPositions );
02329     pumpSetup2(Colors     , GeoColorsPtr    , getColors    );
02330     pumpSetup2(SecColors  , GeoColorsPtr    , getSecondaryColors );
02331     pumpSetup2(TexCoords  , GeoTexCoordsPtr , getTexCoords  );
02332     pumpSetup2(TexCoords1 , GeoTexCoordsPtr , getTexCoords1 );
02333     pumpSetup2(TexCoords2 , GeoTexCoordsPtr , getTexCoords2 );
02334     pumpSetup2(TexCoords3 , GeoTexCoordsPtr , getTexCoords3 );
02335     pumpSetup2(TexCoords4 , GeoTexCoordsPtr , getTexCoords4 );
02336     pumpSetup2(TexCoords5 , GeoTexCoordsPtr , getTexCoords5 );
02337     pumpSetup2(TexCoords6 , GeoTexCoordsPtr , getTexCoords6 );
02338     pumpSetup2(TexCoords7 , GeoTexCoordsPtr , getTexCoords7 );
02339     pumpSetup2(Normals    , GeoNormalsPtr   , getNormals    );
02340 
02341     pumpSetup2(Indices    , GeoIndicesPtr   , getIndices    );
02342 
02343     void (OSG_APIENTRY*_glGenBuffersARB)
02344                   (GLsizei, GLuint *)=
02345             (void (OSG_APIENTRY*)(GLsizei, GLuint *))
02346              _win->getFunction(GeoPumpFactory::_funcglGenBuffers);
02347 
02348     if(_glGenBuffersARB == NULL)
02349     {
02350         _glGenBuffersARB = (void (OSG_APIENTRY*)(GLsizei, GLuint *))
02351              _win->getFunction(GeoPumpFactory::_funcglGenBuffersARB);
02352     }
02353 
02354     void (OSG_APIENTRY*_glDeleteBuffersARB)
02355                   (GLsizei, const GLuint *)=
02356             (void (OSG_APIENTRY*)(GLsizei, const GLuint *))
02357              _win->getFunction(GeoPumpFactory::_funcglDeleteBuffers);
02358 
02359     if(_glDeleteBuffersARB == NULL)
02360     {
02361         _glDeleteBuffersARB = (void (OSG_APIENTRY*)(GLsizei, const GLuint *))
02362              _win->getFunction(GeoPumpFactory::_funcglDeleteBuffersARB);
02363     }
02364 
02365     void (OSG_APIENTRY*_glBindBufferARB)
02366                   (GLenum, GLuint)=
02367             (void (OSG_APIENTRY*)(GLenum, GLuint))
02368              _win->getFunction(GeoPumpFactory::_funcglBindBuffer);
02369 
02370     if(_glBindBufferARB == NULL)
02371     {
02372         _glBindBufferARB = (void (OSG_APIENTRY*)(GLenum, GLuint))
02373              _win->getFunction(GeoPumpFactory::_funcglBindBufferARB);
02374     }
02375 
02376     // typedef ptrdiff_t GLsizeiptrARB;
02377     void (OSG_APIENTRY*_glBufferDataARB)
02378                   (GLenum, ptrdiff_t, const GLvoid *, GLenum)=
02379             (void (OSG_APIENTRY*)(GLenum, ptrdiff_t, const GLvoid *, GLenum))
02380              _win->getFunction(GeoPumpFactory::_funcglBufferData);
02381 
02382     if(_glBufferDataARB == NULL)
02383     {
02384         _glBufferDataARB = (void (OSG_APIENTRY*)(GLenum, ptrdiff_t, const GLvoid *, GLenum))
02385              _win->getFunction(GeoPumpFactory::_funcglBufferDataARB);
02386     }
02387 
02388 #if 0
02389     // typedef ptrdiff_t GLsizeiptrARB;
02390     // typedef ptrdiff_t GLintptrARB;
02391     void (OSG_APIENTRY*_glBufferSubDataARB)
02392                   (GLenum, ptrdiff_t, ptrdiff_t, const GLvoid *)=
02393             (void (OSG_APIENTRY*)(GLenum, ptrdiff_t, ptrdiff_t, const GLvoid *))
02394              _win->getFunction(GeoPumpFactory::_funcglBufferSubDataARB);
02395 #endif
02396 
02397     if(PositionsData)
02398     {
02399         if(_positions != 0)
02400             _glDeleteBuffersARB(1, &_positions);
02401 
02402         // calling _glBufferSubDataARB for changed data increases the
02403         // memory usage! why?
02404         _glGenBuffersARB(1, &_positions);
02405         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _positions);
02406         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, PositionsSize, PositionsData, usage);
02407     }
02408     else
02409     {
02410         if(_positions != 0)
02411         {
02412             _glDeleteBuffersARB(1, &_positions);
02413             _positions = 0;
02414         }
02415     }
02416 
02417     if(NormalsData)
02418     {
02419         if(_normals != 0)
02420             _glDeleteBuffersARB(1, &_normals);
02421     
02422         _glGenBuffersARB(1, &_normals);
02423         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _normals);
02424         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, NormalsSize, NormalsData, usage);
02425     }
02426     else
02427     {
02428         if(_normals != 0)
02429         {
02430             _glDeleteBuffersARB(1, &_normals);
02431             _normals = 0;
02432         }
02433     }
02434 
02435     if(ColorsData)
02436     {
02437         if(_colors != 0)
02438             _glDeleteBuffersARB(1, &_colors);
02439 
02440         _glGenBuffersARB(1, &_colors);
02441         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _colors);
02442         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, ColorsSize, ColorsData, usage);
02443     }
02444     else
02445     {
02446         if(_colors != 0)
02447         {
02448             _glDeleteBuffersARB(1, &_colors);
02449             _colors = 0;
02450         }
02451     }
02452 
02453     if(SecColorsData)
02454     {
02455         if(_secColors != 0)
02456             _glDeleteBuffersARB(1, &_secColors);
02457 
02458         _glGenBuffersARB(1, &_secColors);
02459         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _secColors);
02460         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, SecColorsSize, SecColorsData, usage);
02461     }
02462     else
02463     {
02464         if(_secColors != 0)
02465         {
02466             _glDeleteBuffersARB(1, &_secColors);
02467             _secColors = 0;
02468         }
02469     }
02470 
02471     if(TexCoordsData)
02472     {
02473         if(_texCoords != 0)
02474             _glDeleteBuffersARB(1, &_texCoords);
02475 
02476         _glGenBuffersARB(1, &_texCoords);
02477         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords);
02478         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoordsSize, TexCoordsData, usage);
02479     }
02480     else
02481     {
02482         if(_texCoords != 0)
02483         {
02484             _glDeleteBuffersARB(1, &_texCoords);
02485             _texCoords = 0;
02486         }
02487     }
02488 
02489     if(TexCoords1Data)
02490     {
02491         if(_texCoords1 != 0)
02492             _glDeleteBuffersARB(1, &_texCoords1);
02493 
02494         _glGenBuffersARB(1, &_texCoords1);
02495         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords1);
02496         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords1Size, TexCoords1Data, usage);
02497     }
02498     else
02499     {
02500         if(_texCoords1 != 0)
02501         {
02502             _glDeleteBuffersARB(1, &_texCoords1);
02503             _texCoords1 = 0;
02504         }
02505     }
02506 
02507     if(TexCoords2Data)
02508     {
02509         if(_texCoords2 != 0)
02510             _glDeleteBuffersARB(1, &_texCoords2);
02511 
02512         _glGenBuffersARB(1, &_texCoords2);
02513         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords2);
02514         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords2Size, TexCoords2Data, usage);
02515     }
02516     else
02517     {
02518         if(_texCoords2 != 0)
02519         {
02520             _glDeleteBuffersARB(1, &_texCoords2);
02521             _texCoords2 = 0;
02522         }
02523     }
02524 
02525     if(TexCoords3Data)
02526     {
02527         if(_texCoords3 != 0)
02528             _glDeleteBuffersARB(1, &_texCoords3);
02529 
02530         _glGenBuffersARB(1, &_texCoords3);
02531         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords3);
02532         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords3Size, TexCoords3Data, usage);
02533     }
02534     else
02535     {
02536         if(_texCoords3 != 0)
02537         {
02538             _glDeleteBuffersARB(1, &_texCoords3);
02539             _texCoords3 = 0;
02540         }
02541     }
02542 
02543     if(TexCoords4Data)
02544     {
02545         if(_texCoords4 != 0)
02546             _glDeleteBuffersARB(1, &_texCoords4);
02547 
02548         _glGenBuffersARB(1, &_texCoords4);
02549         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords4);
02550         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords4Size, TexCoords4Data, usage);
02551     }
02552     else
02553     {
02554         if(_texCoords4 != 0)
02555         {
02556             _glDeleteBuffersARB(1, &_texCoords4);
02557             _texCoords4 = 0;
02558         }
02559     }
02560 
02561     if(TexCoords5Data)
02562     {
02563         if(_texCoords5 != 0)
02564             _glDeleteBuffersARB(1, &_texCoords5);
02565 
02566         _glGenBuffersARB(1, &_texCoords5);
02567         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords5);
02568         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords5Size, TexCoords5Data, usage);
02569     }
02570     else
02571     {
02572         if(_texCoords5 != 0)
02573         {
02574             _glDeleteBuffersARB(1, &_texCoords5);
02575             _texCoords5 = 0;
02576         }
02577     }
02578 
02579     if(TexCoords6Data)
02580     {
02581         if(_texCoords6 != 0)
02582             _glDeleteBuffersARB(1, &_texCoords6);
02583 
02584         _glGenBuffersARB(1, &_texCoords6);
02585         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords6);
02586         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords6Size, TexCoords6Data, usage);
02587     }
02588     else
02589     {
02590         if(_texCoords6 != 0)
02591         {
02592             _glDeleteBuffersARB(1, &_texCoords6);
02593             _texCoords6 = 0;
02594         }
02595     }
02596 
02597     if(TexCoords7Data)
02598     {
02599         if(_texCoords7 != 0)
02600             _glDeleteBuffersARB(1, &_texCoords7);
02601 
02602         _glGenBuffersARB(1, &_texCoords7);
02603         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords7);
02604         _glBufferDataARB(GL_ARRAY_BUFFER_ARB, TexCoords7Size, TexCoords7Data, usage);
02605     }
02606     else
02607     {
02608         if(_texCoords7 != 0)
02609         {
02610             _glDeleteBuffersARB(1, &_texCoords7);
02611             _texCoords7 = 0;
02612         }
02613     }
02614 
02615     if(IndicesData)
02616     {
02617         if(_indices != 0)
02618             _glDeleteBuffersARB(1, &_indices);
02619 
02620         _glGenBuffersARB(1, &_indices);
02621         _glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, _indices);
02622         _glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, IndicesSize, IndicesData, usage);
02623     }
02624     else
02625     {
02626         if(_indices != 0)
02627         {
02628             _glDeleteBuffersARB(1, &_indices);
02629             _indices = 0;
02630         }
02631     }
02632 
02633     _glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
02634     _glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
02635 }

void GeoVBO::draw ( void   ) 

Definition at line 2637 of file OSGGeoPumpFactory.cpp.

References _colors, osg::GeoPumpFactory::_extDrawRangeElements, osg::GeoPumpFactory::_extMultitexture, osg::GeoPumpFactory::_extSecondaryColor, 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(), 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, GLenum, GLsizei, GLuint(), osg::Window::hasExtension(), osg::NullFC, OSG_APIENTRY, pumpSetup, and start.

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

02638 {
02639     void (OSG_APIENTRY*_glBindBufferARB)
02640                   (GLenum, GLuint)=
02641             (void (OSG_APIENTRY*)(GLenum, GLuint))
02642              _win->getFunction(GeoPumpFactory::_funcglBindBuffer);
02643 
02644     if(_glBindBufferARB == NULL)
02645     {
02646         _glBindBufferARB = (void (OSG_APIENTRY*)(GLenum, GLuint))
02647              _win->getFunction(GeoPumpFactory::_funcglBindBufferARB);
02648     }
02649 
02650     Geometry *geo = _geo;
02651     Int16 modified=0;
02652 
02653     GeoPositionsPtr PositionsPtr = geo->getPositions();
02654     if (PositionsPtr != NullFC)
02655     {
02656         UInt32 PositionsStride = 0;
02657         if(!(PositionsStride = PositionsPtr->getStride()))
02658             PositionsStride = PositionsPtr->getFormatSize() * PositionsPtr->getDimension();
02659 
02660         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _positions);
02661         glVertexPointer(PositionsPtr->getDimension(), PositionsPtr->getFormat(),
02662                         PositionsStride, NULL);
02663         glEnableClientState(GL_VERTEX_ARRAY);
02664         modified|=(1<<0);
02665     }
02666 
02667     GeoNormalsPtr NormalsPtr = geo->getNormals();
02668     if (NormalsPtr != NullFC)
02669     {
02670         UInt32 NormalsStride = 0;
02671         if(!(NormalsStride = NormalsPtr->getStride()))
02672             NormalsStride = NormalsPtr->getFormatSize() * NormalsPtr->getDimension();
02673 
02674         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _normals);
02675         glNormalPointer(NormalsPtr->getFormat(), NormalsStride, NULL);
02676         glEnableClientState(GL_NORMAL_ARRAY);
02677         modified|=(1<<3);
02678     }
02679 
02680     GeoColorsPtr ColorsPtr = geo->getColors();
02681     if (ColorsPtr != NullFC)
02682     {
02683         UInt32 ColorsStride = 0;
02684         if(!(ColorsStride = ColorsPtr->getStride()))
02685             ColorsStride = ColorsPtr->getFormatSize() * ColorsPtr->getDimension();
02686 
02687         _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _colors);
02688         glColorPointer(ColorsPtr->getDimension(), ColorsPtr->getFormat(),
02689                        ColorsStride, NULL);
02690         glEnableClientState(GL_COLOR_ARRAY);
02691         modified|=(1<<1);
02692     }
02693 
02694     GeoColorsPtr SecColorsPtr = geo->getSecondaryColors();
02695     if (SecColorsPtr != NullFC)
02696     {
02697         if (_win->hasExtension(GeoPumpFactory::_extSecondaryColor))
02698         {
02699             UInt32 SecColorsStride = 0;
02700             if(!(SecColorsStride = SecColorsPtr->getStride()))
02701                 SecColorsStride = SecColorsPtr->getFormatSize() * SecColorsPtr->getDimension();
02702 
02703             void (OSG_APIENTRY*_glSecondaryColorPointerEXT)
02704                   (GLint size,GLenum type,GLsizei stride,const GLvoid *pointer)=
02705             (void (OSG_APIENTRY*)(GLint size,GLenum type,GLsizei stride,const GLvoid *pointer))
02706              _win->getFunction(GeoPumpFactory::_funcglSecondaryColorPointer);
02707 
02708             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _secColors);
02709             _glSecondaryColorPointerEXT(SecColorsPtr->getDimension(),
02710                                        SecColorsPtr->getFormat(),
02711                                        SecColorsStride, NULL);
02712             glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
02713             modified|=(1<<2);
02714         }
02715         else
02716             FWARNING(("VBO::draw: Window has no Secondary Color extension\n"));
02717     }
02718 
02719     GeoTexCoordsPtr TexCoordsPtr = geo->getTexCoords();
02720     if (TexCoordsPtr != NullFC)
02721     {
02722         UInt32 TexCoordsStride = 0;
02723         if(!(TexCoordsStride = TexCoordsPtr->getStride()))
02724             TexCoordsStride = TexCoordsPtr->getFormatSize() * TexCoordsPtr->getDimension();
02725 
02726         if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
02727         {
02728             void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02729             (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
02730             _glClientActiveTextureARB(GL_TEXTURE0_ARB);
02731 
02732             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords);
02733             glTexCoordPointer (TexCoordsPtr->getDimension(), TexCoordsPtr->getFormat(),
02734                                TexCoordsStride, NULL);
02735             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02736         }
02737         else
02738         {
02739             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords);
02740             glTexCoordPointer (TexCoordsPtr->getDimension(), TexCoordsPtr->getFormat(),
02741                                TexCoordsStride, NULL);
02742             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02743         }
02744         modified|=(1<<4);
02745     }
02746 
02747     GeoTexCoordsPtr TexCoords1Ptr = geo->getTexCoords1();
02748     if (TexCoords1Ptr != NullFC)
02749     {
02750         UInt32 TexCoords1Stride = 0;
02751         if(!(TexCoords1Stride = TexCoords1Ptr->getStride()))
02752             TexCoords1Stride = TexCoords1Ptr->getFormatSize() * TexCoords1Ptr->getDimension();
02753 
02754         if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
02755         {
02756             void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02757             (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
02758             _glClientActiveTextureARB(GL_TEXTURE1_ARB);
02759             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords1);
02760             glTexCoordPointer (TexCoords1Ptr->getDimension(), TexCoords1Ptr->getFormat(),
02761                                TexCoords1Stride, NULL);
02762             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02763             modified|=(1<<5);
02764         }
02765         else
02766             FWARNING(("VBO::draw: Window has no MultitextureARB extension\n"));
02767     }
02768 
02769     GeoTexCoordsPtr TexCoords2Ptr = geo->getTexCoords2();
02770     if (TexCoords2Ptr != NullFC)
02771     {
02772         UInt32 TexCoords2Stride = 0;
02773         if(!(TexCoords2Stride = TexCoords2Ptr->getStride()))
02774             TexCoords2Stride = TexCoords2Ptr->getFormatSize() * TexCoords2Ptr->getDimension();
02775 
02776         if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
02777         {
02778             void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02779             (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
02780             _glClientActiveTextureARB(GL_TEXTURE2_ARB);
02781 
02782             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords2);
02783             glTexCoordPointer (TexCoords2Ptr->getDimension(), TexCoords2Ptr->getFormat(),
02784                                TexCoords2Stride, NULL);
02785             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02786             modified|=(1<<6);
02787         }
02788         else
02789             FWARNING(("VBO::draw: Window has no MultitextureARB extension\n"));
02790     }
02791 
02792     GeoTexCoordsPtr TexCoords3Ptr = geo->getTexCoords3();
02793     if (TexCoords3Ptr != NullFC)
02794     {
02795         UInt32 TexCoords3Stride = 0;
02796         if(!(TexCoords3Stride = TexCoords3Ptr->getStride()))
02797             TexCoords3Stride = TexCoords3Ptr->getFormatSize() * TexCoords3Ptr->getDimension();
02798 
02799         if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
02800         {
02801             void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02802             (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
02803             _glClientActiveTextureARB(GL_TEXTURE3_ARB);
02804 
02805             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords3);
02806             glTexCoordPointer (TexCoords3Ptr->getDimension(), TexCoords3Ptr->getFormat(),
02807                                TexCoords3Stride, NULL);
02808             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02809             modified|=(1<<7);
02810         }
02811         else
02812             FWARNING(("VBO::draw: Window has no MultitextureARB extension\n"));
02813     }
02814 
02815     GeoTexCoordsPtr TexCoords4Ptr = geo->getTexCoords4();
02816     if (TexCoords4Ptr != NullFC)
02817     {
02818         UInt32 TexCoords4Stride = 0;
02819         if(!(TexCoords4Stride = TexCoords4Ptr->getStride()))
02820             TexCoords4Stride = TexCoords4Ptr->getFormatSize() * TexCoords4Ptr->getDimension();
02821 
02822         if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
02823         {
02824             void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02825             (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
02826             _glClientActiveTextureARB(GL_TEXTURE4_ARB);
02827 
02828             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords4);
02829             glTexCoordPointer (TexCoords4Ptr->getDimension(), TexCoords4Ptr->getFormat(),
02830                                TexCoords4Stride, NULL);
02831             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02832             modified|=(1<<8);
02833         }
02834         else
02835             FWARNING(("VBO::draw: Window has no MultitextureARB extension\n"));
02836     }
02837 
02838     GeoTexCoordsPtr TexCoords5Ptr = geo->getTexCoords5();
02839     if (TexCoords5Ptr != NullFC)
02840     {
02841         UInt32 TexCoords5Stride = 0;
02842         if(!(TexCoords5Stride = TexCoords5Ptr->getStride()))
02843             TexCoords5Stride = TexCoords5Ptr->getFormatSize() * TexCoords5Ptr->getDimension();
02844 
02845         if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
02846         {
02847             void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02848             (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
02849             _glClientActiveTextureARB(GL_TEXTURE5_ARB);
02850 
02851             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords5);
02852             glTexCoordPointer (TexCoords5Ptr->getDimension(), TexCoords5Ptr->getFormat(),
02853                                TexCoords5Stride, NULL);
02854             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02855             modified|=(1<<9);
02856         }
02857         else
02858             FWARNING(("VBO::draw: Window has no MultitextureARB extension\n"));
02859     }
02860 
02861     GeoTexCoordsPtr TexCoords6Ptr = geo->getTexCoords6();
02862     if (TexCoords6Ptr != NullFC)
02863     {
02864         UInt32 TexCoords6Stride = 0;
02865         if(!(TexCoords6Stride = TexCoords6Ptr->getStride()))
02866                 TexCoords6Stride = TexCoords6Ptr->getFormatSize() * TexCoords6Ptr->getDimension();
02867 
02868         if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
02869         {
02870             void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02871             (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
02872             _glClientActiveTextureARB(GL_TEXTURE6_ARB);
02873 
02874             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords6);
02875             glTexCoordPointer (TexCoords6Ptr->getDimension(), TexCoords6Ptr->getFormat(),
02876                                TexCoords6Stride, NULL);
02877             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02878             modified|=(1<<10);
02879         }
02880         else
02881             FWARNING(("VBO::draw: Window has no MultitextureARB extension\n"));
02882     }
02883 
02884     GeoTexCoordsPtr TexCoords7Ptr = geo->getTexCoords7();
02885     if (TexCoords7Ptr != NullFC)
02886     {
02887         UInt32 TexCoords7Stride = 0;
02888         if(!(TexCoords7Stride = TexCoords7Ptr->getStride()))
02889                 TexCoords7Stride = TexCoords7Ptr->getFormatSize() * TexCoords7Ptr->getDimension();
02890 
02891         if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
02892         {
02893             void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
02894             (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
02895             _glClientActiveTextureARB(GL_TEXTURE7_ARB);
02896 
02897             _glBindBufferARB(GL_ARRAY_BUFFER_ARB, _texCoords7);
02898             glTexCoordPointer (TexCoords7Ptr->getDimension(), TexCoords7Ptr->getFormat(),
02899                                TexCoords7Stride, NULL);
02900             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
02901             modified|=(1<<11);
02902         }
02903         else
02904             FWARNING(("VBO::draw: Window has no MultitextureARB extension\n"));
02905     }
02906 
02907     pumpSetup(Lengths    , GeoPLengthsPtr  , getLengths    );
02908     pumpSetup(Types      , GeoPTypesPtr    , getTypes      );
02909     pumpSetup(Indices    , GeoIndicesPtr   , getIndices    );
02910     IndicesData = IndicesData; // workaround for irix compiler.
02911     
02912     UInt32 lendummy;
02913     UInt32 LengthsSize;
02914     bool   len16 = false;
02915 
02916     if(LengthsPtr != NullFC && LengthsData != NULL)
02917     {
02918         LengthsSize = LengthsPtr->getSize();
02919         len16 = (LengthsPtr->getFormatSize() == 2);
02920     }
02921     else
02922     {
02923         LengthsSize = 1;
02924         LengthsData = (UChar8*) &lendummy;
02925         lendummy = PositionsPtr->getSize();
02926     }
02927 
02928     UInt32 LengthsInd = 0, TypesInd = 0, IndicesInd = 0, 
02929            IndicesSize = IndicesPtr->getSize();
02930 
02931     void (OSG_APIENTRY *osgGLDrawRangeElementsEXT)(GLenum mode, GLuint start,
02932            GLuint end, GLsizei count, GLenum type, const GLvoid*indices) =
02933     (void (OSG_APIENTRY *)(GLenum mode, GLuint start,
02934            GLuint end, GLsizei count, GLenum type, const GLvoid*indices))
02935             _win->getFunction(GeoPumpFactory::_funcglDrawRangeElementsEXT);
02936 
02937     _glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, _indices);
02938 
02939     if(len16 == false)
02940     {
02941         for(LengthsInd = 0; LengthsInd < LengthsSize; LengthsInd++)
02942         {
02943             UInt32 count  = *(UInt32*)(LengthsData + LengthsInd * LengthsStride);
02944             // for vbo's we need only a offset!
02945             UInt8 *vind = ((UInt8 *) NULL) + IndicesStride * IndicesInd;
02946             IndicesInd += count;
02947 
02948             if(_win->hasExtension(GeoPumpFactory::_extDrawRangeElements))
02949             {
02950                 osgGLDrawRangeElementsEXT(*(TypesData + TypesInd++ * TypesStride),
02951                                           geo->getLowindices() [LengthsInd], 
02952                                           geo->getHighindices()[LengthsInd], 
02953                                           count,
02954                                           IndicesPtr->getFormat(), 
02955                                           vind);
02956             }
02957             else
02958             {
02959                 // hope this still works
02960                 glDrawElements(*(TypesData + TypesInd++ * TypesStride),
02961                                count,
02962                                IndicesPtr->getFormat(),
02963                                vind);
02964             }
02965         }
02966     }
02967     else if(len16 == true)
02968     {
02969         for(LengthsInd = 0; LengthsInd < LengthsSize; LengthsInd++)
02970         {
02971             UInt16 count  = *(UInt16*)(LengthsData + LengthsInd * LengthsStride);
02972             // for vbo's we need only a offset!
02973             UInt8 *vind = ((UInt8 *) NULL) + IndicesStride * IndicesInd;
02974             IndicesInd += count;
02975 
02976             if(_win->hasExtension(GeoPumpFactory::_extDrawRangeElements))
02977             {
02978                 osgGLDrawRangeElementsEXT(*(TypesData + TypesInd++ * TypesStride),
02979                                           0, 
02980                                           IndicesSize, 
02981                                           count,
02982                                           IndicesPtr->getFormat(), 
02983                                           vind);
02984             }
02985             else
02986             {
02987                 // hope this still works
02988                 glDrawElements(*(TypesData + TypesInd++ * TypesStride),
02989                                count,
02990                                IndicesPtr->getFormat(),
02991                                vind);
02992             }
02993         }
02994     }
02995     else
02996     {
02997         FWARNING(("VBO::draw: unknown Lengths format size\n"));
02998     }
02999 
03000     if(modified&(1<<0)) glDisableClientState(GL_VERTEX_ARRAY);
03001     if(modified&(1<<1)) glDisableClientState(GL_COLOR_ARRAY);
03002     if(modified&(1<<2)) glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
03003     if(modified&(1<<3)) glDisableClientState(GL_NORMAL_ARRAY);
03004 
03005     if (_win->hasExtension(GeoPumpFactory::_extMultitexture))
03006     {
03007         void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
03008         (void (OSG_APIENTRY*) (GLenum type))_win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
03009 
03010         if(modified&(1<<4))
03011         {
03012             _glClientActiveTextureARB(GL_TEXTURE0_ARB);
03013             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03014         }
03015         
03016         if(modified&(1<<5))
03017         {
03018             _glClientActiveTextureARB(GL_TEXTURE1_ARB);
03019             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03020         }
03021         
03022         if(modified&(1<<6))
03023         {
03024             _glClientActiveTextureARB(GL_TEXTURE2_ARB);
03025             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03026         }
03027         
03028         if(modified&(1<<7))
03029         {
03030             _glClientActiveTextureARB(GL_TEXTURE3_ARB);
03031             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03032         }
03033 
03034         if(modified&(1<<8))
03035         {
03036             _glClientActiveTextureARB(GL_TEXTURE4_ARB);
03037             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03038         }
03039 
03040         if(modified&(1<<9))
03041         {
03042             _glClientActiveTextureARB(GL_TEXTURE5_ARB);
03043             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03044         }
03045 
03046         if(modified&(1<<10))
03047         {
03048             _glClientActiveTextureARB(GL_TEXTURE6_ARB);
03049             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03050         }
03051 
03052         if(modified&(1<<11))
03053         {
03054             _glClientActiveTextureARB(GL_TEXTURE7_ARB);
03055             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03056         }
03057     }
03058     else
03059     {
03060         if(modified&(1<<4)) glDisableClientState(GL_TEXTURE_COORD_ARRAY);
03061     }
03062 
03063     _glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
03064     _glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
03065 }


Member Data Documentation

GLuint osg::GeoVBO::_positions [private]

Definition at line 254 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_normals [private]

Definition at line 255 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_colors [private]

Definition at line 256 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_secColors [private]

Definition at line 257 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_texCoords [private]

Definition at line 258 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_texCoords1 [private]

Definition at line 259 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_texCoords2 [private]

Definition at line 260 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_texCoords3 [private]

Definition at line 261 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_texCoords4 [private]

Definition at line 262 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_texCoords5 [private]

Definition at line 263 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_texCoords6 [private]

Definition at line 264 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_texCoords7 [private]

Definition at line 265 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

GLuint osg::GeoVBO::_indices [private]

Definition at line 266 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

Definition at line 268 of file OSGGeoPumpFactory.h.

Referenced by draw(), update(), and ~GeoVBO().

Definition at line 269 of file OSGGeoPumpFactory.h.

Referenced by draw(), and update().


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

Generated on Mon Mar 17 12:07:13 2008 for OpenSG by  doxygen 1.5.5