00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include <stdlib.h>
00047 #include <stdio.h>
00048 #include <stddef.h>
00049
00050 #include "OSGConfig.h"
00051
00052 #include <OSGGL.h>
00053 #include <OSGGLEXT.h>
00054
00055 #include "OSGLog.h"
00056
00057 #include "OSGFieldContainerPtr.h"
00058 #include "OSGGeometry.h"
00059 #include "OSGDrawAction.h"
00060
00061 #include "OSGMaterial.h"
00062
00063 #include "OSGGeoPumpFactory.h"
00064
00065 OSG_USING_NAMESPACE
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00094 GeoPumpFactory *GeoPumpFactory::_the = NULL;
00095
00098 InitFuncWrapper
00099 GeoPumpFactory::_glextInitFuncWrapper(GeoPumpFactory::glextInitFunction);
00100
00103 UInt32 GeoPumpFactory::_extSecondaryColor;
00104 UInt32 GeoPumpFactory::_extMultitexture;
00105 UInt32 GeoPumpFactory::_extCompiledVertexArray;
00106 UInt32 GeoPumpFactory::_extDrawRangeElements;
00107 UInt32 GeoPumpFactory::_arbVBO;
00108
00111 UInt32 GeoPumpFactory::_funcglSecondaryColorPointer;
00112 UInt32 GeoPumpFactory::_funcglClientActiveTextureARB;
00113 UInt32 GeoPumpFactory::_funcglLockArraysEXT;
00114 UInt32 GeoPumpFactory::_funcglUnlockArraysEXT;
00115 UInt32 GeoPumpFactory::_funcglDrawRangeElementsEXT;
00116
00117 UInt32 GeoPumpFactory::_funcglGenBuffers;
00118 UInt32 GeoPumpFactory::_funcglDeleteBuffers;
00119 UInt32 GeoPumpFactory::_funcglBindBuffer;
00120 UInt32 GeoPumpFactory::_funcglBufferData;
00121 UInt32 GeoPumpFactory::_funcglBufferSubData;
00122
00123 UInt32 GeoPumpFactory::_funcglGenBuffersARB;
00124 UInt32 GeoPumpFactory::_funcglDeleteBuffersARB;
00125 UInt32 GeoPumpFactory::_funcglBindBufferARB;
00126 UInt32 GeoPumpFactory::_funcglBufferDataARB;
00127 UInt32 GeoPumpFactory::_funcglBufferSubDataARB;
00128
00129
00130
00131
00132
00133
00134
00135
00136 GeoPumpFactory::GeoPumpFactory(void)
00137 {
00138 }
00139
00140 GeoPumpFactory::~GeoPumpFactory(void)
00141 {
00142 }
00143
00144
00145
00155 GeoPumpFactory::Index GeoPumpFactory::getIndex(Geometry * geo)
00156 {
00157 if (geo->getPositions() == NullFC ||
00158 !geo->getPositions()->getData() ) return 0;
00159
00160 if (geo->getTypes() == NullFC || !geo->getTypes()->getData() ||
00161 geo->getTypes()->getSize() == 0) return 0;
00162
00163 if (geo->getIndices() == NullFC) return 128;
00164 if (geo->getIndexMapping().size() < 2) return 129;
00165
00166 if ((geo->getIndices() != NullFC &&
00167 geo->getIndices()->getFormatSize() != 4) ||
00168 (geo->getLengths() != NullFC &&
00169 geo->getLengths()->getFormatSize() != 4)
00170 )
00171 return 130;
00172
00173 UInt32 uiIndexMask = 0;
00174
00175 for(UInt32 i = 0; i < geo->getIndexMapping().size(); ++i)
00176 {
00177 uiIndexMask |= geo->getIndexMapping()[i];
00178 }
00179
00180
00181 if((uiIndexMask & Geometry::MapTexCoords4 &&
00182 geo->getTexCoords4() != NullFC &&
00183 geo->getTexCoords4()->getData() ) ||
00184 (uiIndexMask & Geometry::MapTexCoords5 &&
00185 geo->getTexCoords5() != NullFC &&
00186 geo->getTexCoords5()->getData() ) ||
00187 (uiIndexMask & Geometry::MapTexCoords6 &&
00188 geo->getTexCoords6() != NullFC &&
00189 geo->getTexCoords6()->getData() ) ||
00190 (uiIndexMask & Geometry::MapTexCoords7 &&
00191 geo->getTexCoords7() != NullFC &&
00192 geo->getTexCoords7()->getData() ))
00193 {
00194 return 130;
00195 }
00196
00197 int a[7];
00198
00199 if(uiIndexMask & Geometry::MapColor &&
00200 geo->getColors() != NullFC &&
00201 geo->getColors()->getData() )
00202 {
00203 a[0]=1;
00204 }
00205 else
00206 {
00207 a[0] = 0;
00208 }
00209
00210 if(uiIndexMask & Geometry::MapSecondaryColor &&
00211 geo->getSecondaryColors() != NullFC &&
00212 geo->getSecondaryColors()->getData() )
00213 {
00214 a[1]=1;
00215 }
00216 else
00217 {
00218 a[1]=0;
00219 }
00220
00221 if(uiIndexMask & Geometry::MapNormal &&
00222 geo->getNormals() != NullFC &&
00223 geo->getNormals()->getData() )
00224 {
00225 a[2]=1;
00226 }
00227 else
00228 {
00229 a[2]=0;
00230 }
00231
00232 if(uiIndexMask & Geometry::MapTexCoords &&
00233 geo->getTexCoords() != NullFC &&
00234 geo->getTexCoords()->getData() )
00235 {
00236 a[3]=1;
00237 }
00238 else
00239 {
00240 a[3]=0;
00241 }
00242
00243 if(uiIndexMask & Geometry::MapTexCoords1 &&
00244 geo->getTexCoords1() != NullFC &&
00245 geo->getTexCoords1()->getData() )
00246 {
00247 a[4]=1;
00248 }
00249 else
00250 {
00251 a[4]=0;
00252 }
00253
00254 if(uiIndexMask & Geometry::MapTexCoords2 &&
00255 geo->getTexCoords2() != NullFC &&
00256 geo->getTexCoords2()->getData() )
00257 {
00258 a[5]=1;
00259 }
00260 else
00261 {
00262 a[5]=0;
00263 }
00264
00265 if(uiIndexMask & Geometry::MapTexCoords3 &&
00266 geo->getTexCoords3() != NullFC &&
00267 geo->getTexCoords3()->getData() )
00268 {
00269 a[6]=1;
00270 }
00271 else
00272 {
00273 a[6]=0;
00274 }
00275
00276 int index=0;
00277
00278 for (int i=0; i<7; i++)
00279 if (a[i]) index=index|(1<<i);
00280
00281
00282
00283
00284
00285
00286 return index;
00287 }
00288
00289
00292 GeoPumpFactory::GeoPump GeoPumpFactory::getGeoPump(
00293 Window * ,
00294 GeoPumpFactory::Index index )
00295 {
00296
00297 return GeoPumps[index];
00298
00299 }
00300
00301 GeoPumpFactory::PartialGeoPump GeoPumpFactory::getPartialGeoPump(
00302 Window * ,
00303 GeoPumpFactory::Index )
00304 {
00305 FWARNING(("GeoPumpFactory::getPartialGeoPump: not implemented yet!\n"));
00306 return NULL;
00307 }
00308
00309 GeoPumpFactory::InterfacePump GeoPumpFactory::getInterfacePump(
00310 Window * ,
00311 GeoPumpFactory::Index )
00312 {
00313 FWARNING(("GeoPumpFactory::getInterfacePump: not implemented yet!\n"));
00314 return NULL;
00315 }
00316
00317 GeoPumpFactory::PartialInterfacePump GeoPumpFactory::getPartialInterfacePump(
00318 Window * ,
00319 GeoPumpFactory::Index )
00320 {
00321 FWARNING(("GeoPumpFactory::getPartialInterfacePump: not "
00322 "implemented yet!\n"));
00323 return NULL;
00324 }
00325
00326
00327
00328
00329
00330
00331 GeoPumpFactory::Index GeoPumpFactory::numIndices( void )
00332 {
00333 return 131;
00334 }
00335
00336
00337
00338
00339
00340
00341
00342 typedef void (OSG_APIENTRY *pumpFunc)(GLubyte * data);
00343 typedef void (OSG_APIENTRY *multiPumpFunc)(GLenum which, GLubyte * data);
00344
00345
00346
00347
00348
00349 static const int formatBase = GL_BYTE;
00350 static const int numFormats = GL_DOUBLE - GL_BYTE + 1;
00351
00352 static char *formatNames[] =
00353 { "GL_BYTE", "GL_UNSIGNED_BYTE", "GL_SHORT", "GL_UNSIGNED_SHORT",
00354 "GL_INT", "GL_UNSIGNED_INT", "GL_FLOAT", "GL_2_BYTES",
00355 "GL_3_BYTES", "GL_4_BYTES", "GL_DOUBLE"
00356 };
00357
00358
00359
00360 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00361
00362 class glextFuncInit
00363 {
00364 public:
00365
00366 glextFuncInit(char *name, UInt32 format, UInt32 dim) :
00367 _name(name), _format(format), _dim(dim) {};
00368
00369 void init(UInt32 (&extids)[numFormats][4], UInt32 extension)
00370 {
00371 extids[_format - formatBase][_dim - 1] =
00372 Window::registerFunction(_name, extension);
00373 }
00374
00375 private:
00376
00377 char *_name;
00378 UInt32 _format;
00379 UInt32 _dim;
00380 };
00381
00382 static glextFuncInit secondaryColorInitFuncs[8] = {
00383 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3bvEXT",
00384 GL_BYTE,
00385 3),
00386 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3ubvEXT",
00387 GL_UNSIGNED_BYTE,
00388 3),
00389 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3svEXT",
00390 GL_SHORT,
00391 3),
00392 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3usvEXT",
00393 GL_UNSIGNED_SHORT,
00394 3),
00395 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3ivEXT",
00396 GL_INT,
00397 3),
00398 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3uivEXT",
00399 GL_UNSIGNED_INT,
00400 3),
00401 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3fvEXT",
00402 GL_FLOAT,
00403 3),
00404 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3dvEXT",
00405 GL_DOUBLE,
00406 3)
00407 };
00408
00409 static glextFuncInit multiTexCoordsInitFuncs[16] = {
00410 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord1svARB",
00411 GL_SHORT,
00412 1),
00413 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord2svARB",
00414 GL_SHORT,
00415 2),
00416 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord3svARB",
00417 GL_SHORT,
00418 3),
00419 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord4svARB",
00420 GL_SHORT,
00421 4),
00422 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord1ivARB",
00423 GL_INT,
00424 1),
00425 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord2ivARB",
00426 GL_INT,
00427 2),
00428 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord3ivARB",
00429 GL_INT,
00430 3),
00431 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord4ivARB",
00432 GL_INT,
00433 4),
00434 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord1fvARB",
00435 GL_FLOAT,
00436 1),
00437 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord2fvARB",
00438 GL_FLOAT,
00439 2),
00440 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord3fvARB",
00441 GL_FLOAT,
00442 3),
00443 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord4fvARB",
00444 GL_FLOAT,
00445 4),
00446 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord1dvARB",
00447 GL_DOUBLE,
00448 1),
00449 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord2dvARB",
00450 GL_DOUBLE,
00451 2),
00452 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord3dvARB",
00453 GL_DOUBLE,
00454 3),
00455 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord4dvARB",
00456 GL_DOUBLE,
00457 4)
00458 };
00459
00460
00461
00462 static pumpFunc PositionFuncs[numFormats][4] = {
00463 { NULL, NULL, NULL, NULL },
00464 { NULL, NULL, NULL, NULL },
00465 { NULL, (pumpFunc)glVertex2sv,
00466 (pumpFunc)glVertex3sv, (pumpFunc)glVertex4sv },
00467 { NULL, NULL, NULL, NULL },
00468 { NULL, (pumpFunc)glVertex2iv,
00469 (pumpFunc)glVertex3iv, (pumpFunc)glVertex4iv },
00470 { NULL, NULL, NULL, NULL },
00471 { NULL, (pumpFunc)glVertex2fv,
00472 (pumpFunc)glVertex3fv, (pumpFunc)glVertex4fv },
00473 { NULL, NULL, NULL, NULL },
00474 { NULL, NULL, NULL, NULL },
00475 { NULL, NULL, NULL, NULL },
00476 { NULL, (pumpFunc)glVertex2dv,
00477 (pumpFunc)glVertex3dv, (pumpFunc)glVertex4dv },
00478 };
00479
00480 static pumpFunc NormalFuncs[numFormats][4] = {
00481 { NULL, NULL, (pumpFunc)glNormal3sv, NULL },
00482 { NULL, NULL, NULL, NULL },
00483 { NULL, NULL, (pumpFunc)glNormal3sv, NULL },
00484 { NULL, NULL, NULL, NULL },
00485 { NULL, NULL, (pumpFunc)glNormal3iv, NULL },
00486 { NULL, NULL, NULL, NULL },
00487 { NULL, NULL, (pumpFunc)glNormal3fv, NULL },
00488 { NULL, NULL, NULL, NULL },
00489 { NULL, NULL, NULL, NULL },
00490 { NULL, NULL, NULL, NULL },
00491 { NULL, NULL, (pumpFunc)glNormal3dv, NULL },
00492 };
00493
00494 static pumpFunc ColorFuncs[numFormats][4] = {
00495 { NULL, NULL,
00496 (pumpFunc)glColor3bv, (pumpFunc)glColor4bv },
00497 { NULL, NULL,
00498 (pumpFunc)glColor3ubv, (pumpFunc)glColor4ubv },
00499 { NULL, NULL,
00500 (pumpFunc)glColor3sv, (pumpFunc)glColor4sv },
00501 { NULL, NULL,
00502 (pumpFunc)glColor3usv, (pumpFunc)glColor4usv },
00503 { NULL, NULL,
00504 (pumpFunc)glColor3iv, (pumpFunc)glColor4iv },
00505 { NULL, NULL,
00506 (pumpFunc)glColor3uiv, (pumpFunc)glColor4uiv },
00507 { NULL, NULL,
00508 (pumpFunc)glColor3fv, (pumpFunc)glColor4fv },
00509 { NULL, NULL, NULL, NULL },
00510 { NULL, NULL, NULL, NULL },
00511 { NULL, NULL, NULL, NULL },
00512 { NULL, NULL,
00513 (pumpFunc)glColor3dv, (pumpFunc)glColor4dv },
00514 };
00515
00516 static UInt32 SecColorIDs[numFormats][4];
00517
00518 static pumpFunc TexCoordsFuncs[numFormats][4] = {
00519 { NULL, NULL, NULL, NULL },
00520 { NULL, NULL, NULL, NULL },
00521 { (pumpFunc)glTexCoord1sv, (pumpFunc)glTexCoord2sv,
00522 (pumpFunc)glTexCoord3sv, (pumpFunc)glTexCoord4sv },
00523 { NULL, NULL, NULL, NULL },
00524 { (pumpFunc)glTexCoord1iv, (pumpFunc)glTexCoord2iv,
00525 (pumpFunc)glTexCoord3iv, (pumpFunc)glTexCoord4iv },
00526 { NULL, NULL, NULL, NULL },
00527 { (pumpFunc)glTexCoord1fv, (pumpFunc)glTexCoord2fv,
00528 (pumpFunc)glTexCoord3fv, (pumpFunc)glTexCoord4fv },
00529 { NULL, NULL, NULL, NULL },
00530 { NULL, NULL, NULL, NULL },
00531 { NULL, NULL, NULL, NULL },
00532 { (pumpFunc)glTexCoord1dv, (pumpFunc)glTexCoord2dv,
00533 (pumpFunc)glTexCoord3dv, (pumpFunc)glTexCoord4dv },
00534 };
00535
00536 static UInt32 TexCoords1IDs[numFormats][4];
00537
00538 #define TexCoords2IDs TexCoords1IDs
00539 #define TexCoords3IDs TexCoords1IDs
00540 #define TexCoords4IDs TexCoords1IDs
00541 #define TexCoords5IDs TexCoords1IDs
00542 #define TexCoords6IDs TexCoords1IDs
00543 #define TexCoords7IDs TexCoords1IDs
00544
00545 #endif // remove from all but dev docs
00546
00550 static
00551 void GeoPump0(Window *OSG_CHECK_ARG(win),
00552 Geometry *OSG_CHECK_ARG(geo))
00553 {
00554 return;
00555 }
00556
00557 #define pumpSetup( name, typename, getmethod ) \
00558 typename name##Ptr; \
00559 GLubyte * name##Data = NULL; \
00560 UInt32 name##Stride = 0; \
00561 \
00562 name##Ptr = geo->getmethod(); \
00563 if ( name##Ptr != NullFC ) \
00564 { \
00565 name##Data = name##Ptr->getData(); \
00566 if ( ! ( name##Stride = name##Ptr->getStride() ) ) \
00567 name##Stride = name##Ptr->getFormatSize() * \
00568 name##Ptr->getDimension(); \
00569 }
00570
00573 static
00574 void GeoPump128(Window *win,
00575 Geometry *geo )
00576 {
00577 Int16 modified=0;
00578 pumpSetup(Positions , GeoPositionsPtr , getPositions );
00579 pumpSetup(Colors , GeoColorsPtr , getColors );
00580 pumpSetup(SecColors , GeoColorsPtr , getSecondaryColors );
00581 pumpSetup(TexCoords , GeoTexCoordsPtr , getTexCoords );
00582 pumpSetup(TexCoords1 , GeoTexCoordsPtr , getTexCoords1 );
00583 pumpSetup(TexCoords2 , GeoTexCoordsPtr , getTexCoords2 );
00584 pumpSetup(TexCoords3 , GeoTexCoordsPtr , getTexCoords3 );
00585 pumpSetup(TexCoords4 , GeoTexCoordsPtr , getTexCoords4 );
00586 pumpSetup(TexCoords5 , GeoTexCoordsPtr , getTexCoords5 );
00587 pumpSetup(TexCoords6 , GeoTexCoordsPtr , getTexCoords6 );
00588 pumpSetup(TexCoords7 , GeoTexCoordsPtr , getTexCoords7 );
00589 pumpSetup(Normals , GeoNormalsPtr , getNormals );
00590
00591 pumpSetup(Lengths , GeoPLengthsPtr , getLengths );
00592 pumpSetup(Types , GeoPTypesPtr , getTypes );
00593
00594 if (PositionsData)
00595 {
00596 glVertexPointer(PositionsPtr->getDimension(), PositionsPtr->getFormat(),
00597 PositionsStride, PositionsData);
00598 glEnableClientState(GL_VERTEX_ARRAY);
00599 modified|=(1<<0);
00600 }
00601
00602 if (ColorsData)
00603 {
00604 glColorPointer(ColorsPtr->getDimension(), ColorsPtr->getFormat(),
00605 ColorsStride, ColorsData);
00606 glEnableClientState(GL_COLOR_ARRAY);
00607 modified|=(1<<1);
00608 }
00609
00610 if (SecColorsData)
00611 {
00612 if (win->hasExtension(GeoPumpFactory::_extSecondaryColor))
00613 {
00614 void (OSG_APIENTRY*_glSecondaryColorPointerEXT)
00615 (GLint size,GLenum type,GLsizei stride,const GLvoid *pointer)=
00616 (void (OSG_APIENTRY*)(GLint size,GLenum type,GLsizei stride,const GLvoid *pointer))
00617 win->getFunction(GeoPumpFactory::_funcglSecondaryColorPointer);
00618
00619 _glSecondaryColorPointerEXT(SecColorsPtr->getDimension(),
00620 SecColorsPtr->getFormat(),
00621 SecColorsStride, SecColorsData);
00622 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
00623 modified|=(1<<2);
00624 }
00625 else
00626 FWARNING(("GeoPump128: Window has no Secondary Color extension\n"));
00627 }
00628
00629
00630 if (NormalsData)
00631 {
00632 glNormalPointer(NormalsPtr->getFormat(), NormalsStride, NormalsData);
00633 glEnableClientState(GL_NORMAL_ARRAY);
00634 modified|=(1<<3);
00635 }
00636
00637 if (TexCoordsData)
00638 {
00639 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00640 {
00641 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00642 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00643 _glClientActiveTextureARB(GL_TEXTURE0_ARB);
00644 glTexCoordPointer (TexCoordsPtr->getDimension(), TexCoordsPtr->getFormat(),
00645 TexCoordsStride, TexCoordsData);
00646 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00647 }
00648 else
00649 {
00650 glTexCoordPointer (TexCoordsPtr->getDimension(), TexCoordsPtr->getFormat(),
00651 TexCoordsStride, TexCoordsData);
00652 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00653 }
00654 modified|=(1<<4);
00655 }
00656
00657 if (TexCoords1Data)
00658 {
00659 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00660 {
00661 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00662 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00663 _glClientActiveTextureARB(GL_TEXTURE1_ARB);
00664 glTexCoordPointer (TexCoords1Ptr->getDimension(), TexCoords1Ptr->getFormat(),
00665 TexCoords1Stride, TexCoords1Data);
00666 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00667 modified|=(1<<5);
00668 }
00669 else
00670 FWARNING(("GeoPump128: Window has no MultitextureARB extension\n"));
00671 }
00672
00673 if (TexCoords2Data)
00674 {
00675 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00676 {
00677 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00678 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00679 _glClientActiveTextureARB(GL_TEXTURE2_ARB);
00680 glTexCoordPointer (TexCoords2Ptr->getDimension(), TexCoords2Ptr->getFormat(),
00681 TexCoords2Stride, TexCoords2Data);
00682 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00683 modified|=(1<<6);
00684 }
00685 else
00686 FWARNING(("GeoPump128: Window has no MultitextureARB extension\n"));
00687 }
00688
00689 if (TexCoords3Data)
00690 {
00691 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00692 {
00693 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00694 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00695 _glClientActiveTextureARB(GL_TEXTURE3_ARB);
00696 glTexCoordPointer (TexCoords3Ptr->getDimension(), TexCoords3Ptr->getFormat(),
00697 TexCoords3Stride, TexCoords3Data);
00698 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00699 modified|=(1<<7);
00700 }
00701 else
00702 FWARNING(("GeoPump128: Window has no MultitextureARB extension\n"));
00703 }
00704
00705 if (TexCoords4Data)
00706 {
00707 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00708 {
00709 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00710 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00711 _glClientActiveTextureARB(GL_TEXTURE4_ARB);
00712 glTexCoordPointer (TexCoords4Ptr->getDimension(), TexCoords4Ptr->getFormat(),
00713 TexCoords4Stride, TexCoords4Data);
00714 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00715 modified|=(1<<8);
00716 }
00717 else
00718 FWARNING(("GeoPump128: Window has no MultitextureARB extension\n"));
00719 }
00720
00721 if (TexCoords5Data)
00722 {
00723 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00724 {
00725 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00726 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00727 _glClientActiveTextureARB(GL_TEXTURE5_ARB);
00728 glTexCoordPointer (TexCoords5Ptr->getDimension(), TexCoords5Ptr->getFormat(),
00729 TexCoords5Stride, TexCoords5Data);
00730 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00731 modified|=(1<<9);
00732 }
00733 else
00734 FWARNING(("GeoPump128: Window has no MultitextureARB extension\n"));
00735 }
00736
00737 if (TexCoords6Data)
00738 {
00739 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00740 {
00741 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00742 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00743 _glClientActiveTextureARB(GL_TEXTURE6_ARB);
00744 glTexCoordPointer (TexCoords6Ptr->getDimension(), TexCoords6Ptr->getFormat(),
00745 TexCoords6Stride, TexCoords6Data);
00746 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00747 modified|=(1<<10);
00748 }
00749 else
00750 FWARNING(("GeoPump128: Window has no MultitextureARB extension\n"));
00751 }
00752
00753 if (TexCoords7Data)
00754 {
00755 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00756 {
00757 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00758 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00759 _glClientActiveTextureARB(GL_TEXTURE7_ARB);
00760 glTexCoordPointer (TexCoords7Ptr->getDimension(), TexCoords7Ptr->getFormat(),
00761 TexCoords7Stride, TexCoords7Data);
00762 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00763 modified|=(1<<11);
00764 }
00765 else
00766 FWARNING(("GeoPump128: Window has no MultitextureARB extension\n"));
00767 }
00768
00769 UInt32 lendummy;
00770 UInt32 LengthsSize;
00771 UInt32 LengthsFormatSize;
00772
00773 if(LengthsPtr != NullFC && LengthsData != NULL)
00774 {
00775 LengthsSize = LengthsPtr->getSize();
00776 LengthsFormatSize = LengthsPtr->getFormatSize();
00777 }
00778 else
00779 {
00780 LengthsSize = 1;
00781 LengthsFormatSize = 4;
00782 LengthsData = (UChar8*) &lendummy;
00783 lendummy = PositionsPtr->getSize();
00784 }
00785
00786 UInt32 LengthsInd,TypesInd = 0;
00787 UInt32 first=0;
00788
00789 if(LengthsFormatSize == 4)
00790 {
00791 for(LengthsInd = 0; LengthsInd < LengthsSize; LengthsInd++)
00792 {
00793 UInt32 count = *(UInt32*)(LengthsData + LengthsInd * LengthsStride);
00794 glDrawArrays(*(TypesData + TypesInd++ * TypesStride),first,count);
00795 first+=count;
00796 }
00797 }
00798 else if(LengthsFormatSize == 2)
00799 {
00800 for(LengthsInd = 0; LengthsInd < LengthsSize; LengthsInd++)
00801 {
00802 UInt16 count = *(UInt16*)(LengthsData + LengthsInd * LengthsStride);
00803 glDrawArrays(*(TypesData + TypesInd++ * TypesStride),first,count);
00804 first+=count;
00805 }
00806 }
00807 else
00808 {
00809 FWARNING(("GeoPump128: unknown Lengths format size\n"));
00810 }
00811
00812 if(modified&(1<<0)) glDisableClientState(GL_VERTEX_ARRAY);
00813 if(modified&(1<<1)) glDisableClientState(GL_COLOR_ARRAY);
00814 if(modified&(1<<2)) glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
00815 if(modified&(1<<3)) glDisableClientState(GL_NORMAL_ARRAY);
00816
00817 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00818 {
00819 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00820 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00821
00822 if(modified&(1<<4))
00823 {
00824 _glClientActiveTextureARB(GL_TEXTURE0_ARB);
00825 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00826 }
00827
00828 if(modified&(1<<5))
00829 {
00830 _glClientActiveTextureARB(GL_TEXTURE1_ARB);
00831 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00832 }
00833
00834 if(modified&(1<<6))
00835 {
00836 _glClientActiveTextureARB(GL_TEXTURE2_ARB);
00837 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00838 }
00839
00840 if(modified&(1<<7))
00841 {
00842 _glClientActiveTextureARB(GL_TEXTURE3_ARB);
00843 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00844 }
00845
00846 if(modified&(1<<8))
00847 {
00848 _glClientActiveTextureARB(GL_TEXTURE4_ARB);
00849 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00850 }
00851
00852 if(modified&(1<<9))
00853 {
00854 _glClientActiveTextureARB(GL_TEXTURE5_ARB);
00855 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00856 }
00857
00858 if(modified&(1<<10))
00859 {
00860 _glClientActiveTextureARB(GL_TEXTURE6_ARB);
00861 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00862 }
00863
00864 if(modified&(1<<11))
00865 {
00866 _glClientActiveTextureARB(GL_TEXTURE7_ARB);
00867 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00868 }
00869 }
00870 else
00871 {
00872 if(modified&(1<<4)) glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00873 }
00874 }
00875
00879 static
00880 void GeoPump129(Window *win,
00881 Geometry *geo)
00882 {
00883 Int16 modified=0;
00884 pumpSetup(Positions , GeoPositionsPtr , getPositions );
00885 pumpSetup(Colors , GeoColorsPtr , getColors );
00886 pumpSetup(SecColors , GeoColorsPtr , getSecondaryColors );
00887 pumpSetup(TexCoords , GeoTexCoordsPtr , getTexCoords );
00888 pumpSetup(TexCoords1 , GeoTexCoordsPtr , getTexCoords1 );
00889 pumpSetup(TexCoords2 , GeoTexCoordsPtr , getTexCoords2 );
00890 pumpSetup(TexCoords3 , GeoTexCoordsPtr , getTexCoords3 );
00891 pumpSetup(TexCoords4 , GeoTexCoordsPtr , getTexCoords4 );
00892 pumpSetup(TexCoords5 , GeoTexCoordsPtr , getTexCoords5 );
00893 pumpSetup(TexCoords6 , GeoTexCoordsPtr , getTexCoords6 );
00894 pumpSetup(TexCoords7 , GeoTexCoordsPtr , getTexCoords7 );
00895 pumpSetup(Normals , GeoNormalsPtr , getNormals );
00896
00897 pumpSetup(Lengths , GeoPLengthsPtr , getLengths );
00898 pumpSetup(Types , GeoPTypesPtr , getTypes );
00899 pumpSetup(Indices , GeoIndicesPtr , getIndices );
00900
00901 if (PositionsData)
00902 {
00903 glVertexPointer(PositionsPtr->getDimension(), PositionsPtr->getFormat(),
00904 PositionsStride, PositionsData);
00905 glEnableClientState(GL_VERTEX_ARRAY);
00906 modified|=(1<<0);
00907 }
00908
00909 if (ColorsData)
00910 {
00911 glColorPointer(ColorsPtr->getDimension(), ColorsPtr->getFormat(),
00912 ColorsStride, ColorsData);
00913 glEnableClientState(GL_COLOR_ARRAY);
00914 modified|=(1<<1);
00915 }
00916
00917 if (SecColorsData)
00918 {
00919 if (win->hasExtension(GeoPumpFactory::_extSecondaryColor))
00920 {
00921 void (OSG_APIENTRY*_glSecondaryColorPointerEXT)
00922 (GLint size,GLenum type,GLsizei stride,const GLvoid *pointer)=
00923 (void (OSG_APIENTRY*)(GLint size,GLenum type,GLsizei stride,const GLvoid *pointer))
00924 win->getFunction(GeoPumpFactory::_funcglSecondaryColorPointer);
00925
00926 _glSecondaryColorPointerEXT(SecColorsPtr->getDimension(),
00927 SecColorsPtr->getFormat(),
00928 SecColorsStride, SecColorsData);
00929 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
00930 modified|=(1<<2);
00931 }
00932 else
00933 FWARNING(("GeoPump129: Window has no Secondary Color extension\n"));
00934 }
00935
00936
00937 if (NormalsData)
00938 {
00939 glNormalPointer(NormalsPtr->getFormat(), NormalsStride, NormalsData);
00940 glEnableClientState(GL_NORMAL_ARRAY);
00941 modified|=(1<<3);
00942 }
00943
00944 if (TexCoordsData)
00945 {
00946 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00947 {
00948 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00949 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00950 _glClientActiveTextureARB(GL_TEXTURE0_ARB);
00951 glTexCoordPointer (TexCoordsPtr->getDimension(), TexCoordsPtr->getFormat(),
00952 TexCoordsStride, TexCoordsData);
00953 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00954 }
00955 else
00956 {
00957 glTexCoordPointer (TexCoordsPtr->getDimension(), TexCoordsPtr->getFormat(),
00958 TexCoordsStride, TexCoordsData);
00959 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00960 }
00961 modified|=(1<<4);
00962 }
00963
00964 if (TexCoords1Data)
00965 {
00966 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00967 {
00968 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00969 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00970 _glClientActiveTextureARB(GL_TEXTURE1_ARB);
00971 glTexCoordPointer (TexCoords1Ptr->getDimension(), TexCoords1Ptr->getFormat(),
00972 TexCoords1Stride, TexCoords1Data);
00973 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00974 modified|=(1<<5);
00975 }
00976 else
00977 FWARNING(("GeoPump129: Window has no MultitextureARB extension\n"));
00978 }
00979
00980 if (TexCoords2Data)
00981 {
00982 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00983 {
00984 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
00985 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
00986 _glClientActiveTextureARB(GL_TEXTURE2_ARB);
00987 glTexCoordPointer (TexCoords2Ptr->getDimension(), TexCoords2Ptr->getFormat(),
00988 TexCoords2Stride, TexCoords2Data);
00989 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00990 modified|=(1<<6);
00991 }
00992 else
00993 FWARNING(("GeoPump129: Window has no MultitextureARB extension\n"));
00994 }
00995
00996 if (TexCoords3Data)
00997 {
00998 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
00999 {
01000 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
01001 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
01002 _glClientActiveTextureARB(GL_TEXTURE3_ARB);
01003 glTexCoordPointer (TexCoords3Ptr->getDimension(), TexCoords3Ptr->getFormat(),
01004 TexCoords3Stride, TexCoords3Data);
01005 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
01006 modified|=(1<<7);
01007 }
01008 else
01009 FWARNING(("GeoPump129: Window has no MultitextureARB extension\n"));
01010 }
01011
01012 if (TexCoords4Data)
01013 {
01014 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
01015 {
01016 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
01017 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
01018 _glClientActiveTextureARB(GL_TEXTURE4_ARB);
01019 glTexCoordPointer (TexCoords4Ptr->getDimension(), TexCoords4Ptr->getFormat(),
01020 TexCoords4Stride, TexCoords4Data);
01021 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
01022 modified|=(1<<8);
01023 }
01024 else
01025 FWARNING(("GeoPump129: Window has no MultitextureARB extension\n"));
01026 }
01027
01028 if (TexCoords5Data)
01029 {
01030 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
01031 {
01032 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
01033 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
01034 _glClientActiveTextureARB(GL_TEXTURE5_ARB);
01035 glTexCoordPointer (TexCoords5Ptr->getDimension(), TexCoords5Ptr->getFormat(),
01036 TexCoords5Stride, TexCoords5Data);
01037 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
01038 modified|=(1<<9);
01039 }
01040 else
01041 FWARNING(("GeoPump129: Window has no MultitextureARB extension\n"));
01042 }
01043
01044 if (TexCoords6Data)
01045 {
01046 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
01047 {
01048 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
01049 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
01050 _glClientActiveTextureARB(GL_TEXTURE6_ARB);
01051 glTexCoordPointer (TexCoords6Ptr->getDimension(), TexCoords6Ptr->getFormat(),
01052 TexCoords6Stride, TexCoords6Data);
01053 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
01054 modified|=(1<<10);
01055 }
01056 else
01057 FWARNING(("GeoPump129: Window has no MultitextureARB extension\n"));
01058 }
01059
01060 if (TexCoords7Data)
01061 {
01062 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
01063 {
01064 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
01065 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
01066 _glClientActiveTextureARB(GL_TEXTURE7_ARB);
01067 glTexCoordPointer (TexCoords7Ptr->getDimension(), TexCoords7Ptr->getFormat(),
01068 TexCoords7Stride, TexCoords7Data);
01069 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
01070 modified|=(1<<11);
01071 }
01072 else
01073 FWARNING(("GeoPump129: Window has no MultitextureARB extension\n"));
01074 }
01075
01076 UInt32 lendummy;
01077 UInt32 LengthsSize;
01078 bool len16 = false;
01079
01080 if(LengthsPtr != NullFC && LengthsData != NULL)
01081 {
01082 LengthsSize = LengthsPtr->getSize();
01083 len16 = (LengthsPtr->getFormatSize() == 2);
01084 }
01085 else
01086 {
01087 LengthsSize = 1;
01088 LengthsData = (UChar8*) &lendummy;
01089 lendummy = PositionsPtr->getSize();
01090 }
01091
01092 UInt32 LengthsInd = 0, TypesInd = 0, IndicesInd = 0,
01093 IndicesSize = IndicesPtr->getSize();
01094
01095 if (win->hasExtension(GeoPumpFactory::_extCompiledVertexArray))
01096 {
01097 void (OSG_APIENTRY*_glLockArraysEXT) (GLint first, GLsizei count)=
01098 (void (OSG_APIENTRY*) (GLint first, GLsizei count))
01099 win->getFunction(GeoPumpFactory::_funcglLockArraysEXT);
01100
01101 _glLockArraysEXT(geo->getMinindex(), geo->getMaxindex() + 1);
01102 }
01103
01104 void (OSG_APIENTRY *osgGLDrawRangeElementsEXT)(GLenum mode, GLuint start,
01105 GLuint end, GLsizei count, GLenum type, const GLvoid*indices) =
01106 (void (OSG_APIENTRY *)(GLenum mode, GLuint start,
01107 GLuint end, GLsizei count, GLenum type, const GLvoid*indices))
01108 win->getFunction(GeoPumpFactory::_funcglDrawRangeElementsEXT);
01109
01110
01111 if(len16 == false)
01112 {
01113 for(LengthsInd = 0; LengthsInd < LengthsSize; LengthsInd++)
01114 {
01115 UInt32 count = *(UInt32*)(LengthsData + LengthsInd * LengthsStride);
01116 UInt8 * vind = IndicesData + IndicesStride * IndicesInd;
01117 IndicesInd += count;
01118
01119 #if 0
01120 glDrawElements(*(TypesData + TypesInd++ * TypesStride),count,
01121 IndicesPtr->getFormat(),vind);
01122 #else
01123 if(win->hasExtension(GeoPumpFactory::_extDrawRangeElements))
01124 {
01125 osgGLDrawRangeElementsEXT(*(TypesData + TypesInd++ * TypesStride),
01126 geo->getLowindices() [LengthsInd],
01127 geo->getHighindices()[LengthsInd],
01128 count,
01129 IndicesPtr->getFormat(),
01130 vind);
01131 }
01132 else
01133 {
01134
01135 glDrawElements(*(TypesData + TypesInd++ * TypesStride),
01136 count,
01137 IndicesPtr->getFormat(),
01138 vind);
01139 }
01140 #endif
01141 }
01142 }
01143 else if(len16 == true)
01144 {
01145 for(LengthsInd = 0; LengthsInd < LengthsSize; LengthsInd++)
01146 {
01147 UInt16 count = *(UInt16*)(LengthsData + LengthsInd * LengthsStride);
01148 UInt8 * vind = IndicesData + IndicesStride * IndicesInd;
01149 IndicesInd += count;
01150
01151 #if 0
01152 glDrawElements(*(TypesData + TypesInd++ * TypesStride),count,
01153 IndicesPtr->getFormat(),vind);
01154 #else
01155 if(win->hasExtension(GeoPumpFactory::_extDrawRangeElements))
01156 {
01157 osgGLDrawRangeElementsEXT(*(TypesData + TypesInd++ * TypesStride),
01158 0,
01159 IndicesSize,
01160 count,
01161 IndicesPtr->getFormat(),
01162 vind);
01163 }
01164 else
01165 {
01166
01167 glDrawElements(*(TypesData + TypesInd++ * TypesStride),
01168 count,
01169 IndicesPtr->getFormat(),
01170 vind);
01171 }
01172 #endif
01173 }
01174 }
01175 else
01176 {
01177 FWARNING(("GeoPump129: unknown Lengths format size\n"));
01178 }
01179
01180 if (win->hasExtension(GeoPumpFactory::_extCompiledVertexArray))
01181 {
01182 void (OSG_APIENTRY*_glUnlockArraysEXT) (void)=
01183 (void (OSG_APIENTRY*) (void))
01184 win->getFunction(GeoPumpFactory::_funcglUnlockArraysEXT);
01185
01186 _glUnlockArraysEXT();
01187 }
01188
01189 if(modified&(1<<0)) glDisableClientState(GL_VERTEX_ARRAY);
01190 if(modified&(1<<1)) glDisableClientState(GL_COLOR_ARRAY);
01191 if(modified&(1<<2)) glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
01192 if(modified&(1<<3)) glDisableClientState(GL_NORMAL_ARRAY);
01193
01194 if (win->hasExtension(GeoPumpFactory::_extMultitexture))
01195 {
01196 void (OSG_APIENTRY*_glClientActiveTextureARB) (GLenum type)=
01197 (void (OSG_APIENTRY*) (GLenum type))win->getFunction(GeoPumpFactory::_funcglClientActiveTextureARB);
01198
01199 if(modified&(1<<4))
01200 {
01201 _glClientActiveTextureARB(GL_TEXTURE0_ARB);
01202 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01203 }
01204
01205 if(modified&(1<<5))
01206 {
01207 _glClientActiveTextureARB(GL_TEXTURE1_ARB);
01208 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01209 }
01210
01211 if(modified&(1<<6))
01212 {
01213 _glClientActiveTextureARB(GL_TEXTURE2_ARB);
01214 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01215 }
01216
01217 if(modified&(1<<7))
01218 {
01219 _glClientActiveTextureARB(GL_TEXTURE3_ARB);
01220 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01221 }
01222
01223 if(modified&(1<<8))
01224 {
01225 _glClientActiveTextureARB(GL_TEXTURE4_ARB);
01226 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01227 }
01228
01229 if(modified&(1<<9))
01230 {
01231 _glClientActiveTextureARB(GL_TEXTURE5_ARB);
01232 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01233 }
01234
01235 if(modified&(1<<10))
01236 {
01237 _glClientActiveTextureARB(GL_TEXTURE6_ARB);
01238 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01239 }
01240
01241 if(modified&(1<<11))
01242 {
01243 _glClientActiveTextureARB(GL_TEXTURE7_ARB);
01244 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01245 }
01246 }
01247 else
01248 {
01249 if(modified&(1<<4)) glDisableClientState(GL_TEXTURE_COORD_ARRAY);
01250 }
01251 }
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264 #define pumpInternalSetup( name, typename, getmethod, mandatory ) \
01265 GLubyte * name##Data; \
01266 UInt32 name##Stride; \
01267 UInt32 name##Ind = 0; \
01268 typename name##Ptr; \
01269 \
01270 name##Ptr = geo->getmethod(); \
01271 if(mandatory && name##Ptr == NullFC) \
01272 { \
01273 SWARNING << "masterPump: Geometry " << geo << " has no " \
01274 << #name << "s!" << std::endl; \
01275 return; \
01276 } \
01277 else if(name##Ptr != NullFC) \
01278 { \
01279 name##Data = name##Ptr->getData(); \
01280 if(!(name##Stride = name##Ptr->getStride())) \
01281 name##Stride = name##Ptr->getFormatSize() * \
01282 name##Ptr->getDimension(); \
01283 } \
01284 else \
01285 { \
01286 name##Data = NULL; \
01287 name##Stride = 0; \
01288 }
01289
01290 #define pumpGLSetup( name, typename, getmethod ) \
01291 GLubyte * name##Data; \
01292 UInt32 name##Stride; \
01293 UInt32 name##Ind = 0; \
01294 typename name##Ptr; \
01295 pumpFunc name##Func; \
01296 \
01297 name##Ptr = geo->getmethod(); \
01298 if(name##Ptr != NullFC) \
01299 { \
01300 name##Data = name##Ptr->getData(); \
01301 if(!(name##Stride = name##Ptr->getStride())) \
01302 name##Stride = name##Ptr->getFormatSize() * \
01303 name##Ptr->getDimension(); \
01304 if(!(name##Func = name##Funcs[name##Ptr->getFormat() - \
01305 formatBase] \
01306 [name##Ptr->getDimension() - 1] \
01307 ) ) \
01308 { \
01309 SWARNING << "masterPump: Geometry " << geo << " has illegal " \
01310 << #name << "s: " << name##Ptr->getDimension() \
01311 << "D " << formatNames[ name##Ptr->getFormat() - \
01312 formatBase ] \
01313 << "!" << std::endl; \
01314 return; \
01315 } \
01316 } \
01317 else \
01318 { \
01319 name##Data = NULL; \
01320 name##Func = NULL; \
01321 name##Stride = 0; \
01322 }
01323
01324 #define pumpGLExtSetup( name, typename, getmethod ) \
01325 GLubyte * name##Data; \
01326 UInt32 name##Stride; \
01327 UInt32 name##Ind = 0; \
01328 typename name##Ptr; \
01329 pumpFunc name##Func; \
01330 \
01331 name##Ptr = geo->getmethod(); \
01332 if(name##Ptr != NullFC) \
01333 { \
01334 name##Data = name##Ptr->getData(); \
01335 if(!(name##Stride = name##Ptr->getStride())) \
01336 name##Stride = name##Ptr->getFormatSize() * \
01337 name##Ptr->getDimension(); \
01338 if(name##IDs[name##Ptr->getFormat() - formatBase] \
01339 [name##Ptr->getDimension() - 1] == \
01340 Window::invalidFunctionID) \
01341 { \
01342 SWARNING << "masterPump: Geometry " << geo << " has illegal " \
01343 << #name << "s: " << name##Ptr->getDimension() \
01344 << "D " << formatNames[ name##Ptr->getFormat() - \
01345 formatBase ] \
01346 << "!" << std::endl; \
01347 return; \
01348 } \
01349 if(!(name##Func = (pumpFunc)win->getFunction(name##IDs \
01350 [name##Ptr->getFormat() - formatBase] \
01351 [name##Ptr->getDimension() - 1]) \
01352 ) ) \
01353 { \
01354 SWARNING << "masterPump: Geometry " << geo << " uses " \
01355 << #name << "s: " << name##Ptr->getDimension() \
01356 << "D " << formatNames[ name##Ptr->getFormat() - \
01357 formatBase ] \
01358 << " which are not supported by Window " << win \
01359 << "!" << std::endl; \
01360 return; \
01361 } \
01362 } \
01363 else \
01364 { \
01365 name##Data = NULL; \
01366 name##Func = NULL; \
01367 name##Stride = 0; \
01368 }
01369
01370 #define pumpMultiGLExtSetup(name, typename, getmethod) \
01371 GLubyte * name##Data; \
01372 UInt32 name##Stride; \
01373 UInt32 name##Ind = 0; \
01374 typename name##Ptr; \
01375 multiPumpFunc name##Func; \
01376 \
01377 name##Ptr = geo->getmethod(); \
01378 if(name##Ptr != NullFC) \
01379 { \
01380 name##Data = name##Ptr->getData(); \
01381 if(!(name##Stride = name##Ptr->getStride() ) ) \
01382 name##Stride = name##Ptr->getFormatSize() * \
01383 name##Ptr->getDimension(); \
01384 if(name##IDs[name##Ptr->getFormat() - formatBase] \
01385 [name##Ptr->getDimension() - 1] == \
01386 Window::invalidFunctionID) \
01387 { \
01388 SWARNING << "masterPump: Geometry " << geo << "has illegal " \
01389 << #name << "s: " << name##Ptr->getDimension() \
01390 << "D " << formatNames[ name##Ptr->getFormat() - \
01391 formatBase ] \
01392 << "!" << std::endl; \
01393 return; \
01394 } \
01395 if(!(name##Func = (multiPumpFunc)win->getFunction(name##IDs \
01396 [name##Ptr->getFormat() - formatBase] \
01397 [name##Ptr->getDimension() - 1]) \
01398 ) ) \
01399 { \
01400 SWARNING << "masterPump: Geometry " << geo << "uses " \
01401 << #name << "s: " << name##Ptr->getDimension() \
01402 << "D " << formatNames[ name##Ptr->getFormat() - \
01403 formatBase ] \
01404 << "which are not supported by Window " << win \
01405 << "!" << std::endl; \
01406 return; \
01407 } \
01408 } \
01409 else \
01410 { \
01411 name##Data = NULL; \
01412 name##Func = NULL; \
01413 name##Stride = 0; \
01414 }
01415
01416 #define iC pumpGLSetup ( Color , GeoColorsPtr , getColors )\
01417 Int16 ColorIndex = geo->calcMappingIndex( Geometry::MapColor ); \
01418 if(ColorData && ColorPtr->getSize() == 1) \
01419 ColorFunc(ColorData);
01420
01421 #define iS pumpGLExtSetup ( SecColor , GeoColorsPtr , getSecondaryColors)\
01422 Int16 SecColorIndex = geo->calcMappingIndex(Geometry::MapSecondaryColor);
01423
01424 #define iN pumpGLSetup ( Normal , GeoNormalsPtr , getNormals )\
01425 Int16 NormalIndex = geo->calcMappingIndex(Geometry::MapNormal);
01426
01427 #define iT pumpGLSetup ( TexCoords , GeoTexCoordsPtr, getTexCoords )\
01428 Int16 TexCoordsIndex = geo->calcMappingIndex(Geometry::MapTexCoords);
01429
01430 #define iT1 pumpMultiGLExtSetup ( TexCoords1, GeoTexCoordsPtr, getTexCoords1 )\
01431 Int16 TexCoords1Index = geo->calcMappingIndex(Geometry::MapTexCoords1);
01432
01433 #define iT2 pumpMultiGLExtSetup ( TexCoords2, GeoTexCoordsPtr, getTexCoords2 )\
01434 Int16 TexCoords2Index = geo->calcMappingIndex(Geometry::MapTexCoords2);
01435
01436 #define iT3 pumpMultiGLExtSetup ( TexCoords3, GeoTexCoordsPtr, getTexCoords3 )\
01437 Int16 TexCoords3Index = geo->calcMappingIndex(Geometry::MapTexCoords3);
01438
01439 #define iT4 pumpMultiGLExtSetup ( TexCoords4, GeoTexCoordsPtr, getTexCoords4 )\
01440 Int16 TexCoords4Index = geo->calcMappingIndex(Geometry::MapTexCoords4);
01441
01442 #define iT5 pumpMultiGLExtSetup ( TexCoords5, GeoTexCoordsPtr, getTexCoords5 )\
01443 Int16 TexCoords5Index = geo->calcMappingIndex(Geometry::MapTexCoords5);
01444
01445 #define iT6 pumpMultiGLExtSetup ( TexCoords6, GeoTexCoordsPtr, getTexCoords6 )\
01446 Int16 TexCoords6Index = geo->calcMappingIndex(Geometry::MapTexCoords6);
01447
01448 #define iT7 pumpMultiGLExtSetup ( TexCoords7, GeoTexCoordsPtr, getTexCoords7 )\
01449 Int16 TexCoords7Index = geo->calcMappingIndex(Geometry::MapTexCoords7);
01450
01451 #define rC ColorFunc ( ColorData + ColorStride * vind[ColorIndex] );
01452 #define rS SecColorFunc ( SecColorData + SecColorStride * vind[SecColorIndex] );
01453 #define rN NormalFunc ( NormalData + NormalStride * vind[NormalIndex] );
01454 #define rT TexCoordsFunc ( TexCoordsData + TexCoordsStride * vind[TexCoordsIndex] );
01455 #define rT1 TexCoords1Func( GL_TEXTURE1_ARB , TexCoords1Data + TexCoords1Stride * vind[TexCoords1Index] );
01456 #define rT2 TexCoords2Func( GL_TEXTURE2_ARB , TexCoords2Data + TexCoords2Stride * vind[TexCoords2Index] );
01457 #define rT3 TexCoords3Func( GL_TEXTURE3_ARB , TexCoords3Data + TexCoords3Stride * vind[TexCoords3Index] );
01458 #define rT4 TexCoords4Func( GL_TEXTURE4_ARB , TexCoords4Data + TexCoords4Stride * vind[TexCoords4Index] );
01459 #define rT5 TexCoords5Func( GL_TEXTURE5_ARB , TexCoords5Data + TexCoords5Stride * vind[TexCoords5Index] );
01460 #define rT6 TexCoords6Func( GL_TEXTURE6_ARB , TexCoords6Data + TexCoords6Stride * vind[TexCoords6Index] );
01461 #define rT7 TexCoords7Func( GL_TEXTURE7_ARB , TexCoords7Data + TexCoords7Stride * vind[TexCoords7Index] );
01462
01463
01464
01465
01466
01467
01468 #define defMultiGeoPump( func, init , render ) \
01469 static \
01470 void GeoPump##func( Window *win, \
01471 Geometry *geo) \
01472 { \
01473 \
01474 \
01475 pumpInternalSetup( Type , GeoPTypesPtr , getTypes , true ); \
01476 pumpInternalSetup( Length, GeoPLengthsPtr , getLengths, false ); \
01477 pumpInternalSetup( Index , GeoIndicesPtr , getIndices, false ); \
01478 \
01479 pumpGLSetup( Position , GeoPositionsPtr, getPositions ); \
01480 Int16 PositionIndex = geo->calcMappingIndex(Geometry::MapPosition); \
01481 \
01482 init; \
01483 UInt16 nmappings = geo->getIndexMapping().size(); \
01484 \
01485 UInt32 lendummy; \
01486 UInt32 LengthSize; \
01487 \
01488 if ( ! LengthData ) \
01489 { \
01490 LengthSize = 1; \
01491 LengthData = (UChar8*) &lendummy; \
01492 lendummy = IndexPtr->getSize() / nmappings; \
01493 } \
01494 else \
01495 { \
01496 LengthSize = LengthPtr->getSize(); \
01497 } \
01498 \
01499 for ( LengthInd = 0; LengthInd < LengthSize; LengthInd++ ) \
01500 { \
01501 glBegin( *(TypeData + TypeInd++ * TypeStride) ); \
01502 \
01503 for ( UInt32 l = *(UInt32*)(LengthData + LengthInd * LengthStride); \
01504 l > 0; l-- ) \
01505 { \
01506 UInt32 * vind; \
01507 \
01508 vind = (UInt32*)(IndexData + IndexStride * IndexInd); \
01509 IndexInd += nmappings; \
01510 \
01511 render; \
01512 PositionFunc(PositionData+PositionStride*vind[PositionIndex]); \
01513 } \
01514 glEnd(); \
01515 } \
01516 \
01517 }
01518
01519
01520 #ifdef __sgi
01521 #pragma set woff 1174,1209
01522 #endif
01523
01524
01525
01526
01527
01528 defMultiGeoPump( 1 , iC; , rC; )
01529 defMultiGeoPump( 2 , iS; , rS; )
01530 defMultiGeoPump( 3 , iC; iS; , rC; rS; )
01531 defMultiGeoPump( 4 , iN; , rN; )
01532 defMultiGeoPump( 5 , iC; iN; , rC; rN; )
01533 defMultiGeoPump( 6 , iS; iN; , rS; rN; )
01534 defMultiGeoPump( 7 , iC; iS; iN; , rC; rS; rN; )
01535 defMultiGeoPump( 8 , iT; , rT; )
01536 defMultiGeoPump( 9 , iC; iT; , rC; rT; )
01537 defMultiGeoPump( 10 , iS; iT; , rS; rT; )
01538 defMultiGeoPump( 11 , iC; iS; iT; , rC; rS; rT; )
01539 defMultiGeoPump( 12 , iN; iT; , rN; rT; )
01540 defMultiGeoPump( 13 , iC; iN; iT; , rC; rN; rT; )
01541 defMultiGeoPump( 14 , iS; iN; iT; , rS; rN; rT; )
01542 defMultiGeoPump( 15 , iC; iS; iN; iT; , rC; rS; rN; rT; )
01543 defMultiGeoPump( 16 , iT1; , rT1; )
01544 defMultiGeoPump( 17 , iC; iT1; , rC; rT1; )
01545 defMultiGeoPump( 18 , iS; iT1; , rS; rT1; )
01546 defMultiGeoPump( 19 , iC; iS; iT1; , rC; rS; rT1; )
01547 defMultiGeoPump( 20 , iN; iT1; , rN; rT1; )
01548 defMultiGeoPump( 21 , iC; iN; iT1; , rC; rN; rT1; )
01549 defMultiGeoPump( 22 , iS; iN; iT1; , rS; rN; rT1; )
01550 defMultiGeoPump( 23 , iC; iS; iN; iT1; , rC; rS; rN; rT1; )
01551 defMultiGeoPump( 24 , iT; iT1; , rT; rT1; )
01552 defMultiGeoPump( 25 , iC; iT; iT1; , rC; rT; rT1; )
01553 defMultiGeoPump( 26 , iS; iT; iT1; , rS; rT; rT1; )
01554 defMultiGeoPump( 27 , iC; iS; iT; iT1; , rC; rS; rT; rT1; )
01555 defMultiGeoPump( 28 , iN; iT; iT1; , rN; rT; rT1; )
01556 defMultiGeoPump( 29 , iC; iN; iT; iT1; , rC; rN; rT; rT1; )
01557 defMultiGeoPump( 30 , iS; iN; iT; iT1; , rS; rN; rT; rT1; )
01558 defMultiGeoPump( 31 , iC; iS; iN; iT; iT1; , rC; rS; rN; rT; rT1; )
01559 defMultiGeoPump( 32 , iT2; , rT2; )
01560 defMultiGeoPump( 33 , iC; iT2; , rC; rT2; )
01561 defMultiGeoPump( 34 , iS; iT2; , rS; rT2; )
01562 defMultiGeoPump( 35 , iC; iS; iT2; , rC; rS; rT2; )
01563 defMultiGeoPump( 36 , iN; iT2; , rN; rT2; )
01564 defMultiGeoPump( 37 , iC; iN; iT2; , rC; rN; rT2; )
01565 defMultiGeoPump( 38 , iS; iN; iT2; , rS; rN; rT2; )
01566 defMultiGeoPump( 39 , iC; iS; iN; iT2; , rC; rS; rN; rT2; )
01567 defMultiGeoPump( 40 , iT; iT2; , rT; rT2; )
01568 defMultiGeoPump( 41 , iC; iT; iT2; , rC; rT; rT2; )
01569 defMultiGeoPump( 42 , iS; iT; iT2; , rS; rT; rT2; )
01570 defMultiGeoPump( 43 , iC; iS; iT; iT2; , rC; rS; rT; rT2; )
01571 defMultiGeoPump( 44 , iN; iT; iT2; , rN; rT; rT2; )
01572 defMultiGeoPump( 45 , iC; iN; iT; iT2; , rC; rN; rT; rT2; )
01573 defMultiGeoPump( 46 , iS; iN; iT; iT2; , rS; rN; rT; rT2; )
01574 defMultiGeoPump( 47 , iC; iS; iN; iT; iT2; , rC; rS; rN; rT; rT2; )
01575 defMultiGeoPump( 48 , iT1; iT2; , rT1; rT2; )
01576 defMultiGeoPump( 49 , iC; iT1; iT2; , rC; rT1; rT2; )
01577 defMultiGeoPump( 50 , iS; iT1; iT2; , rS; rT1; rT2; )
01578 defMultiGeoPump( 51 , iC; iS; iT1; iT2; , rC; rS; rT1; rT2; )
01579 defMultiGeoPump( 52 , iN; iT1; iT2; , rN; rT1; rT2; )
01580 defMultiGeoPump( 53 , iC; iN; iT1; iT2; , rC; rN; rT1; rT2; )
01581 defMultiGeoPump( 54 , iS; iN; iT1; iT2; , rS; rN; rT1; rT2; )
01582 defMultiGeoPump( 55 , iC; iS; iN; iT1; iT2; , rC; rS; rN; rT1; rT2; )
01583 defMultiGeoPump( 56 , iT; iT1; iT2; , rT; rT1; rT2; )
01584 defMultiGeoPump( 57 , iC; iT; iT1; iT2; , rC; rT; rT1; rT2; )
01585 defMultiGeoPump( 58 , iS; iT; iT1; iT2; , rS; rT; rT1; rT2; )
01586 defMultiGeoPump( 59 , iC; iS; iT; iT1; iT2; , rC; rS; rT; rT1; rT2; )
01587 defMultiGeoPump( 60 , iN; iT; iT1; iT2; , rN; rT; rT1; rT2; )
01588 defMultiGeoPump( 61 , iC; iN; iT; iT1; iT2; , rC; rN; rT; rT1; rT2; )
01589 defMultiGeoPump( 62 , iS; iN; iT; iT1; iT2; , rS; rN; rT; rT1; rT2; )
01590 defMultiGeoPump( 63 , iC; iS; iN; iT; iT1; iT2; , rC; rS; rN; rT; rT1; rT2; )
01591 defMultiGeoPump( 64 , iT3; , rT3; )
01592 defMultiGeoPump( 65 , iC; iT3; , rC; rT3; )
01593 defMultiGeoPump( 66 , iS; iT3; , rS; rT3; )
01594 defMultiGeoPump( 67 , iC; iS; iT3; , rC; rS; rT3; )
01595 defMultiGeoPump( 68 , iN; iT3; , rN; rT3; )
01596 defMultiGeoPump( 69 , iC; iN; iT3; , rC; rN; rT3; )
01597 defMultiGeoPump( 70 , iS; iN; iT3; , rS; rN; rT3; )
01598 defMultiGeoPump( 71 , iC; iS; iN; iT3; , rC; rS; rN; rT3; )
01599 defMultiGeoPump( 72 , iT; iT3; , rT; rT3; )
01600 defMultiGeoPump( 73 , iC; iT; iT3; , rC; rT; rT3; )
01601 defMultiGeoPump( 74 , iS; iT; iT3; , rS; rT; rT3; )
01602 defMultiGeoPump( 75 , iC; iS; iT; iT3; , rC; rS; rT; rT3; )
01603 defMultiGeoPump( 76 , iN; iT; iT3; , rN; rT; rT3; )
01604 defMultiGeoPump( 77 , iC; iN; iT; iT3; , rC; rN; rT; rT3; )
01605 defMultiGeoPump( 78 , iS; iN; iT; iT3; , rS; rN; rT; rT3; )
01606 defMultiGeoPump( 79 , iC; iS; iN; iT; iT3; , rC; rS; rN; rT; rT3; )
01607 defMultiGeoPump( 80 , iT1; iT3; , rT1; rT3; )
01608 defMultiGeoPump( 81 , iC; iT1; iT3; , rC; rT1; rT3; )
01609 defMultiGeoPump( 82 , iS; iT1; iT3; , rS; rT1; rT3; )
01610 defMultiGeoPump( 83 , iC; iS; iT1; iT3; , rC; rS; rT1; rT3; )
01611 defMultiGeoPump( 84 , iN; iT1; iT3; , rN; rT1; rT3; )
01612 defMultiGeoPump( 85 , iC; iN; iT1; iT3; , rC; rN; rT1; rT3; )
01613 defMultiGeoPump( 86 , iS; iN; iT1; iT3; , rS; rN; rT1; rT3; )
01614 defMultiGeoPump( 87 , iC; iS; iN; iT1; iT3; , rC; rS; rN; rT1; rT3; )
01615 defMultiGeoPump( 88 , iT; iT1; iT3; , rT; rT1; rT3; )
01616 defMultiGeoPump( 89 , iC; iT; iT1; iT3; , rC; rT; rT1; rT3; )
01617 defMultiGeoPump( 90 , iS; iT; iT1; iT3; , rS; rT; rT1; rT3; )
01618 defMultiGeoPump( 91 , iC; iS; iT; iT1; iT3; , rC; rS; rT; rT1; rT3; )
01619 defMultiGeoPump( 92 , iN; iT; iT1; iT3; , rN; rT; rT1; rT3; )
01620 defMultiGeoPump( 93 , iC; iN; iT; iT1; iT3; , rC; rN; rT; rT1; rT3; )
01621 defMultiGeoPump( 94 , iS; iN; iT; iT1; iT3; , rS; rN; rT; rT1; rT3; )
01622 defMultiGeoPump( 95 , iC; iS; iN; iT; iT1; iT3; , rC; rS; rN; rT; rT1; rT3; )
01623 defMultiGeoPump( 96 , iT2; iT3; , rT2; rT3; )
01624 defMultiGeoPump( 97 , iC; iT2; iT3; , rC; rT2; rT3; )
01625 defMultiGeoPump( 98 , iS; iT2; iT3; , rS; rT2; rT3; )
01626 defMultiGeoPump( 99 , iC; iS; iT2; iT3; , rC; rS; rT2; rT3; )
01627 defMultiGeoPump( 100 , iN; iT2; iT3; , rN; rT2; rT3; )
01628 defMultiGeoPump( 101 , iC; iN; iT2; iT3; , rC; rN; rT2; rT3; )
01629 defMultiGeoPump( 102 , iS; iN; iT2; iT3; , rS; rN; rT2; rT3; )
01630 defMultiGeoPump( 103 , iC; iS; iN; iT2; iT3; , rC; rS; rN; rT2; rT3; )
01631 defMultiGeoPump( 104 , iT; iT2; iT3; , rT; rT2; rT3; )
01632 defMultiGeoPump( 105 , iC; iT; iT2; iT3; , rC; rT; rT2; rT3; )
01633 defMultiGeoPump( 106 , iS; iT; iT2; iT3; , rS; rT; rT2; rT3; )
01634 defMultiGeoPump( 107 , iC; iS; iT; iT2; iT3; , rC; rS; rT; rT2; rT3; )
01635 defMultiGeoPump( 108 , iN; iT; iT2; iT3; , rN; rT; rT2; rT3; )
01636 defMultiGeoPump( 109 , iC; iN; iT; iT2; iT3; , rC; rN; rT; rT2; rT3; )
01637 defMultiGeoPump( 110 , iS; iN; iT; iT2; iT3; , rS; rN; rT; rT2; rT3; )
01638 defMultiGeoPump( 111 , iC; iS; iN; iT; iT2; iT3; , rC; rS; rN; rT; rT2; rT3; )
01639 defMultiGeoPump( 112 , iT1; iT2; iT3; , rT1; rT2; rT3; )
01640 defMultiGeoPump( 113 , iC; iT1; iT2; iT3; , rC; rT1; rT2; rT3; )
01641 defMultiGeoPump( 114 , iS; iT1; iT2; iT3; , rS; rT1; rT2; rT3; )
01642 defMultiGeoPump( 115 , iC; iS; iT1; iT2; iT3; , rC; rS; rT1; rT2; rT3; )
01643 defMultiGeoPump( 116 , iN; iT1; iT2; iT3; , rN; rT1; rT2; rT3; )
01644 defMultiGeoPump( 117 , iC; iN; iT1; iT2; iT3; , rC; rN; rT1; rT2; rT3; )
01645 defMultiGeoPump( 118 , iS; iN; iT1; iT2; iT3; , rS; rN; rT1; rT2; rT3; )
01646 defMultiGeoPump( 119 , iC; iS; iN; iT1; iT2; iT3; , rC; rS; rN; rT1; rT2; rT3; )
01647 defMultiGeoPump( 120 , iT; iT1; iT2; iT3; , rT; rT1; rT2; rT3; )
01648 defMultiGeoPump( 121 , iC; iT; iT1; iT2; iT3; , rC; rT; rT1; rT2; rT3; )
01649 defMultiGeoPump( 122 , iS; iT; iT1; iT2; iT3; , rS; rT; rT1; rT2; rT3; )
01650 defMultiGeoPump( 123 , iC; iS; iT; iT1; iT2; iT3; , rC; rS; rT; rT1; rT2; rT3; )
01651 defMultiGeoPump( 124 , iN; iT; iT1; iT2; iT3; , rN; rT; rT1; rT2; rT3; )
01652 defMultiGeoPump( 125 , iC; iN; iT; iT1; iT2; iT3; , rC; rN; rT; rT1; rT2; rT3; )
01653 defMultiGeoPump( 126 , iS; iN; iT; iT1; iT2; iT3; , rS; rN; rT; rT1; rT2; rT3; )
01654 defMultiGeoPump( 127 , iC; iS; iN; iT; iT1; iT2; iT3; , rC; rS; rN; rT; rT1; rT2; rT3; )
01655
01656
01657
01658 GeoPumpFactory::GeoPump GeoPumpFactory::GeoPumps[131]={&GeoPump0,
01659 &GeoPump1,&GeoPump2,&GeoPump3,&GeoPump4,&GeoPump5,&GeoPump6,&GeoPump7,&GeoPump8,
01660 &GeoPump9,&GeoPump10,&GeoPump11,&GeoPump12,&GeoPump13,&GeoPump14,&GeoPump15,&GeoPump16,
01661 &GeoPump17,&GeoPump18,&GeoPump19,&GeoPump20,&GeoPump21,&GeoPump22,&GeoPump23,&GeoPump24,
01662 &GeoPump25,&GeoPump26,&GeoPump27,&GeoPump28,&GeoPump29,&GeoPump30,&GeoPump31,&GeoPump32,
01663 &GeoPump33,&GeoPump34,&GeoPump35,&GeoPump36,&GeoPump37,&GeoPump38,&GeoPump39,&GeoPump40,
01664 &GeoPump41,&GeoPump42,&GeoPump43,&GeoPump44,&GeoPump45,&GeoPump46,&GeoPump47,&GeoPump48,
01665 &GeoPump49,&GeoPump50,&GeoPump51,&GeoPump52,&GeoPump53,&GeoPump54,&GeoPump55,&GeoPump56,
01666 &GeoPump57,&GeoPump58,&GeoPump59,&GeoPump60,&GeoPump61,&GeoPump62,&GeoPump63,&GeoPump64,
01667 &GeoPump65,&GeoPump66,&GeoPump67,&GeoPump68,&GeoPump69,&GeoPump70,&GeoPump71,&GeoPump72,
01668 &GeoPump73,&GeoPump74,&GeoPump75,&GeoPump76,&GeoPump77,&GeoPump78,&GeoPump79,&GeoPump80,
01669 &GeoPump81,&GeoPump82,&GeoPump83,&GeoPump84,&GeoPump85,&GeoPump86,&GeoPump87,&GeoPump88,
01670 &GeoPump89,&GeoPump90,&GeoPump91,&GeoPump92,&GeoPump93,&GeoPump94,&GeoPump95,&GeoPump96,
01671 &GeoPump97,&GeoPump98,&GeoPump99,&GeoPump100,&GeoPump101,&GeoPump102,&GeoPump103,&GeoPump104,
01672 &GeoPump105,&GeoPump106,&GeoPump107,&GeoPump108,&GeoPump109,&GeoPump110,&GeoPump111,&GeoPump112,
01673 &GeoPump113,&GeoPump114,&GeoPump115,&GeoPump116,&GeoPump117,&GeoPump118,&GeoPump119,&GeoPump120,
01674 &GeoPump121,&GeoPump122,&GeoPump123,&GeoPump124,&GeoPump125,&GeoPump126,&GeoPump127,&GeoPump128,
01675 &GeoPump129,&GeoPumpFactory::masterGeoPump};
01676
01677 void GeoPumpFactory::masterGeoPump(Window *win,
01678 Geometry *geo)
01679 {
01680
01681
01682 pumpInternalSetup( Type, GeoPTypesPtr, getTypes, true );
01683 pumpInternalSetup( Length, GeoPLengthsPtr, getLengths, false );
01684 pumpInternalSetup( Index, GeoIndicesPtr, getIndices, false );
01685
01686 pumpGLSetup ( Position, GeoPositionsPtr, getPositions );
01687 pumpGLSetup ( Color, GeoColorsPtr, getColors );
01688 pumpGLExtSetup ( SecColor, GeoColorsPtr, getSecondaryColors);
01689 pumpGLSetup ( Normal, GeoNormalsPtr, getNormals );
01690 pumpGLSetup ( TexCoords, GeoTexCoordsPtr, getTexCoords );
01691 pumpMultiGLExtSetup( TexCoords1, GeoTexCoordsPtr, getTexCoords1 );
01692 pumpMultiGLExtSetup( TexCoords2, GeoTexCoordsPtr, getTexCoords2 );
01693 pumpMultiGLExtSetup( TexCoords3, GeoTexCoordsPtr, getTexCoords3 );
01694 pumpMultiGLExtSetup( TexCoords4, GeoTexCoordsPtr, getTexCoords4 );
01695 pumpMultiGLExtSetup( TexCoords5, GeoTexCoordsPtr, getTexCoords5 );
01696 pumpMultiGLExtSetup( TexCoords6, GeoTexCoordsPtr, getTexCoords6 );
01697 pumpMultiGLExtSetup( TexCoords7, GeoTexCoordsPtr, getTexCoords7 );
01698
01699
01700 if(! TypeData || TypePtr->getSize() == 0)
01701 return;
01702
01703
01704 if(! PositionData)
01705 {
01706 SWARNING << "masterPump: Geometry " << geo << " has no positions!?!"
01707 << std::endl;
01708 return;
01709 }
01710
01711
01712 UInt16 nmappings = geo->getIndexMapping().size();
01713 Int16 PositionIndex = -1,
01714 NormalIndex = -1,
01715 ColorIndex = -1,
01716 SecColorIndex = -1,
01717 TexCoordsIndex = -1,
01718 TexCoords1Index = -1,
01719 TexCoords2Index = -1,
01720 TexCoords3Index = -1,
01721 TexCoords4Index = -1,
01722 TexCoords5Index = -1,
01723 TexCoords6Index = -1,
01724 TexCoords7Index = -1;
01725
01726 if(nmappings)
01727 {
01728 PositionIndex = geo->calcMappingIndex(Geometry::MapPosition );
01729 NormalIndex = geo->calcMappingIndex(Geometry::MapNormal );
01730 ColorIndex = geo->calcMappingIndex(Geometry::MapColor );
01731 SecColorIndex = geo->calcMappingIndex(Geometry::MapSecondaryColor);
01732 TexCoordsIndex = geo->calcMappingIndex(Geometry::MapTexCoords );
01733 TexCoords1Index = geo->calcMappingIndex(Geometry::MapTexCoords1 );
01734 TexCoords2Index = geo->calcMappingIndex(Geometry::MapTexCoords2 );
01735 TexCoords3Index = geo->calcMappingIndex(Geometry::MapTexCoords3 );
01736 TexCoords4Index = geo->calcMappingIndex(Geometry::MapTexCoords4 );
01737 TexCoords5Index = geo->calcMappingIndex(Geometry::MapTexCoords5 );
01738 TexCoords6Index = geo->calcMappingIndex(Geometry::MapTexCoords6 );
01739 TexCoords7Index = geo->calcMappingIndex(Geometry::MapTexCoords7 );
01740
01741 if(! PositionData)
01742 {
01743 SWARNING << "masterPump: Geometry "
01744 << geo
01745 << "has no position index!?!"
01746 << std::endl;
01747 return;
01748 }
01749
01750 }
01751 else if(IndexData)
01752 {
01753 nmappings = 1;
01754 PositionIndex =
01755 NormalIndex =
01756 ColorIndex =
01757 SecColorIndex =
01758 TexCoordsIndex =
01759 TexCoords1Index =
01760 TexCoords2Index =
01761 TexCoords3Index =
01762 TexCoords4Index =
01763 TexCoords5Index =
01764 TexCoords6Index =
01765 TexCoords7Index = 0;
01766 }
01767
01768
01769 if(ColorData && ColorPtr->getSize() == 1)
01770 ColorFunc(ColorData);
01771
01772
01773
01774 UInt32 lendummy;
01775 UInt32 LengthSize;
01776 bool len16 = false;
01777
01778
01779 if(! LengthData)
01780 {
01781 LengthSize = 1;
01782 LengthData = (UChar8*) &lendummy;
01783 if(IndexData)
01784 {
01785 lendummy = IndexPtr->getSize() / nmappings;
01786 }
01787 else
01788 {
01789 lendummy = PositionPtr->getSize();
01790 }
01791 }
01792 else
01793 {
01794 LengthSize = LengthPtr->getSize();
01795 len16 = (LengthPtr->getFormatSize() == 2);
01796 }
01797
01798 bool ind16 = false;
01799 ind16 = (IndexPtr != NullFC && IndexPtr->getFormatSize() == 2);
01800
01801 UInt32 l;
01802
01803 for(LengthInd = 0; LengthInd < LengthSize; LengthInd++)
01804 {
01805 glBegin(*(TypeData + TypeInd++ * TypeStride));
01806
01807 if(len16)
01808 {
01809 l = *(UInt16*)(LengthData + LengthInd * LengthStride);
01810 }
01811 else
01812 {
01813 l = *(UInt32*)(LengthData + LengthInd * LengthStride);
01814 }
01815
01816 for( ; l > 0; l--)
01817 {
01818 if(IndexData && !ind16)
01819 {
01820 UInt32 * vind;
01821
01822 vind = (UInt32*)(IndexData + IndexStride * IndexInd);
01823 IndexInd += nmappings;
01824
01825 if(ColorData && ColorIndex >= 0)
01826 {
01827 ColorFunc(ColorData + ColorStride * vind[ColorIndex]);
01828 }
01829
01830 if(SecColorData && SecColorIndex >= 0)
01831 {
01832 SecColorFunc(SecColorData + SecColorStride *
01833 vind[SecColorIndex]);
01834 }
01835
01836 if(NormalData && NormalIndex >= 0)
01837 {
01838 NormalFunc(NormalData + NormalStride * vind[NormalIndex]);
01839 }
01840
01841 if(TexCoordsData && TexCoordsIndex >= 0)
01842 {
01843 TexCoordsFunc(TexCoordsData + TexCoordsStride *
01844 vind[TexCoordsIndex]);
01845 }
01846
01847 if(TexCoords1Data && TexCoords1Index >= 0)
01848 {
01849 TexCoords1Func(GL_TEXTURE1_ARB,
01850 TexCoords1Data + TexCoords1Stride *
01851 vind[TexCoords1Index]);
01852 }
01853
01854 if(TexCoords2Data && TexCoords2Index >= 0)
01855 {
01856 TexCoords2Func(GL_TEXTURE2_ARB,
01857 TexCoords2Data + TexCoords2Stride *
01858 vind[TexCoords2Index]);
01859 }
01860
01861 if(TexCoords3Data && TexCoords3Index >= 0)
01862 {
01863 TexCoords3Func(GL_TEXTURE3_ARB,
01864 TexCoords3Data + TexCoords3Stride *
01865 vind[TexCoords3Index]);
01866 }
01867
01868 if(TexCoords4Data && TexCoords4Index >= 0)
01869 {
01870 TexCoords4Func(GL_TEXTURE4_ARB,
01871 TexCoords4Data + TexCoords4Stride *
01872 vind[TexCoords4Index]);
01873 }
01874
01875 if(TexCoords5Data && TexCoords5Index >= 0)
01876 {
01877 TexCoords5Func(GL_TEXTURE5_ARB,
01878 TexCoords5Data + TexCoords5Stride *
01879 vind[TexCoords5Index]);
01880 }
01881
01882 if(TexCoords6Data && TexCoords6Index >= 0)
01883 {
01884 TexCoords6Func(GL_TEXTURE6_ARB,
01885 TexCoords6Data + TexCoords6Stride *
01886 vind[TexCoords6Index]);
01887 }
01888
01889 if(TexCoords7Data && TexCoords7Index >= 0)
01890 {
01891 TexCoords7Func(GL_TEXTURE7_ARB,
01892 TexCoords7Data + TexCoords7Stride *
01893 vind[TexCoords7Index]);
01894 }
01895
01896 PositionFunc(PositionData + PositionStride * vind[PositionIndex]);
01897 }
01898 else if(IndexData && ind16)
01899 {
01900 UInt16 * vind;
01901
01902 vind = (UInt16*)(IndexData + IndexStride * IndexInd);
01903 IndexInd += nmappings;
01904
01905 if(ColorData && ColorIndex >= 0)
01906 {
01907 ColorFunc(ColorData + ColorStride * vind[ColorIndex]);
01908 }
01909
01910 if(SecColorData && SecColorIndex >= 0)
01911 {
01912 SecColorFunc(SecColorData + SecColorStride *
01913 vind[SecColorIndex]);
01914 }
01915
01916 if(NormalData && NormalIndex >= 0)
01917 {
01918 NormalFunc(NormalData + NormalStride * vind[NormalIndex]);
01919 }
01920
01921 if(TexCoordsData && TexCoordsIndex >= 0)
01922 {
01923 TexCoordsFunc(TexCoordsData + TexCoordsStride *
01924 vind[TexCoordsIndex]);
01925 }
01926
01927 if(TexCoords1Data && TexCoords1Index >= 0)
01928 {
01929 TexCoords1Func(GL_TEXTURE1_ARB,
01930 TexCoords1Data + TexCoords1Stride *
01931 vind[TexCoords1Index]);
01932 }
01933
01934 if(TexCoords2Data && TexCoords2Index >= 0)
01935 {
01936 TexCoords2Func(GL_TEXTURE2_ARB,
01937 TexCoords2Data + TexCoords2Stride *
01938 vind[TexCoords2Index]);
01939 }
01940
01941 if(TexCoords3Data && TexCoords3Index >= 0)
01942 {
01943 TexCoords3Func(GL_TEXTURE3_ARB,
01944 TexCoords3Data + TexCoords3Stride *
01945 vind[TexCoords3Index]);
01946 }
01947
01948 if(TexCoords4Data && TexCoords4Index >= 0)
01949 {
01950 TexCoords4Func(GL_TEXTURE4_ARB,
01951 TexCoords4Data + TexCoords4Stride *
01952 vind[TexCoords4Index]);
01953 }
01954
01955 if(TexCoords5Data && TexCoords5Index >= 0)
01956 {
01957 TexCoords5Func(GL_TEXTURE5_ARB,
01958 TexCoords5Data + TexCoords5Stride *
01959 vind[TexCoords5Index]);
01960 }
01961
01962 if(TexCoords6Data && TexCoords6Index >= 0)
01963 {
01964 TexCoords6Func(GL_TEXTURE6_ARB,
01965 TexCoords6Data + TexCoords6Stride *
01966 vind[TexCoords6Index]);
01967 }
01968
01969 if(TexCoords7Data && TexCoords7Index >= 0)
01970 {
01971 TexCoords7Func(GL_TEXTURE7_ARB,
01972 TexCoords7Data + TexCoords7Stride *
01973 vind[TexCoords7Index]);
01974 }
01975
01976 PositionFunc(PositionData + PositionStride * vind[PositionIndex]);
01977 }
01978 else
01979 {
01980 if(ColorData)
01981 {
01982 ColorFunc(ColorData + ColorStride * PositionInd);
01983 }
01984
01985 if(SecColorData)
01986 {
01987 SecColorFunc(SecColorData + SecColorStride * PositionInd);
01988 }
01989
01990 if(NormalData)
01991 {
01992 NormalFunc(NormalData + NormalStride * PositionInd);
01993 }
01994
01995 if(TexCoordsData)
01996 {
01997 TexCoordsFunc(TexCoordsData + TexCoordsStride *
01998 PositionInd);
01999 }
02000
02001 if(TexCoords1Data)
02002 {
02003 TexCoords1Func(GL_TEXTURE1_ARB,
02004 TexCoords1Data + TexCoords1Stride *
02005 PositionInd);
02006 }
02007
02008 if(TexCoords2Data)
02009 {
02010 TexCoords2Func(GL_TEXTURE2_ARB,
02011 TexCoords2Data + TexCoords2Stride *
02012 PositionInd);
02013 }
02014
02015 if(TexCoords3Data)
02016 {
02017 TexCoords3Func(GL_TEXTURE3_ARB,
02018 TexCoords3Data + TexCoords3Stride *
02019 PositionInd);
02020 }
02021
02022 if(TexCoords4Data)
02023 {
02024 TexCoords4Func(GL_TEXTURE4_ARB,
02025 TexCoords4Data + TexCoords4Stride *
02026 PositionInd);
02027 }
02028
02029 if(TexCoords5Data)
02030 {
02031 TexCoords5Func(GL_TEXTURE5_ARB,
02032 TexCoords5Data + TexCoords5Stride *
02033 PositionInd);
02034 }
02035
02036 if(TexCoords6Data)
02037 {
02038 TexCoords6Func(GL_TEXTURE6_ARB,
02039 TexCoords6Data + TexCoords6Stride *
02040 PositionInd);
02041 }
02042
02043 if(TexCoords7Data)
02044 {
02045 TexCoords7Func(GL_TEXTURE7_ARB,
02046 TexCoords7Data + TexCoords7Stride *
02047 PositionInd);
02048 }
02049
02050 PositionFunc(PositionData + PositionStride * PositionInd);
02051
02052 PositionInd++;
02053 }
02054 }
02055
02056 glEnd();
02057 }
02058 }
02059
02060
02061 void GeoPumpFactory::masterPartialGeoPump(Window *OSG_CHECK_ARG(win ),
02062 Geometry *OSG_CHECK_ARG(geo ),
02063 UInt32 OSG_CHECK_ARG(primtype ),
02064 UInt32 OSG_CHECK_ARG(firstvert),
02065 UInt32 OSG_CHECK_ARG(nvert ))
02066 {
02067 FWARNING(("GeoPumpFactory::masterPartialGeoPump: not implemented yet!\n"));
02068 }
02069
02070 void GeoPumpFactory::masterInterfacePump(
02071 Window *OSG_CHECK_ARG(win ),
02072 GeoPositionsInterface *OSG_CHECK_ARG(pos ),
02073 GeoNormalsInterface *OSG_CHECK_ARG(norm ),
02074 GeoColorsInterface *OSG_CHECK_ARG(col ),
02075 GeoColorsInterface *OSG_CHECK_ARG(seccol ),
02076 GeoTexCoordsInterface *OSG_CHECK_ARG(texcoords ),
02077 GeoTexCoordsInterface *OSG_CHECK_ARG(texcoords1),
02078 GeoTexCoordsInterface *OSG_CHECK_ARG(texcoords2),
02079 GeoTexCoordsInterface *OSG_CHECK_ARG(texcoords3),
02080 GeoPTypesInterface *OSG_CHECK_ARG(type ),
02081 GeoPLengthsInterface *OSG_CHECK_ARG(len ),
02082 GeoIndicesInterface *OSG_CHECK_ARG(ind ),
02083 UInt16 *OSG_CHECK_ARG(pMap ),
02084 UInt16 OSG_CHECK_ARG(nmap ))
02085 {
02086 FWARNING(("GeoPumpFactory::masterInterfacePump: not implemented yet!\n"));
02087 }
02088
02089 void GeoPumpFactory::masterPartialInterfacePump(
02090 Window *OSG_CHECK_ARG(win ),
02091 GeoPositionsInterface *OSG_CHECK_ARG(pos ),
02092 GeoNormalsInterface *OSG_CHECK_ARG(norm ),
02093 GeoColorsInterface *OSG_CHECK_ARG(col ),
02094 GeoColorsInterface *OSG_CHECK_ARG(seccol ),
02095 GeoTexCoordsInterface *OSG_CHECK_ARG(texcoords ),
02096 GeoTexCoordsInterface *OSG_CHECK_ARG(texcoords1),
02097 GeoTexCoordsInterface *OSG_CHECK_ARG(texcoords2),
02098 GeoTexCoordsInterface *OSG_CHECK_ARG(texcoords3),
02099 GeoPTypesInterface *OSG_CHECK_ARG(type ),
02100 GeoPLengthsInterface *OSG_CHECK_ARG(len ),
02101 GeoIndicesInterface *OSG_CHECK_ARG(ind ),
02102 UInt16 *OSG_CHECK_ARG(pMap ),
02103 UInt16 OSG_CHECK_ARG(nmap ),
02104 UInt32 OSG_CHECK_ARG(primtype ),
02105 UInt32 OSG_CHECK_ARG(firstvert ),
02106 UInt32 OSG_CHECK_ARG(nvert ))
02107 {
02108 FWARNING(
02109 ("GeoPumpFactory::masterPartialInterfacePump not implemented yet!\n"));
02110 }
02111
02112 #ifdef __sgi
02113 #pragma reset woff 1174,1209
02114 #endif
02115
02116 bool GeoPumpFactory::glextInitFunction(void)
02117 {
02118 _extSecondaryColor =
02119 Window::registerExtension("GL_EXT_secondary_color");
02120 _extMultitexture =
02121 Window::registerExtension("GL_ARB_multitexture");
02122 _extCompiledVertexArray =
02123 Window::registerExtension("GL_EXT_compiled_vertex_array");
02124 _extDrawRangeElements =
02125 Window::registerExtension("GL_EXT_draw_range_elements");
02126 _arbVBO =
02127 Window::registerExtension("GL_ARB_vertex_buffer_object");
02128
02129 UInt16 i,j;
02130 for(i = 0; i < numFormats; i++)
02131 {
02132 for(j = 0; j < 4; j++)
02133 {
02134 SecColorIDs [i][j] = Window::invalidFunctionID;
02135 TexCoords1IDs[i][j] = Window::invalidFunctionID;
02136 }
02137 }
02138
02139 for(i = 0; i < 8; i++)
02140 secondaryColorInitFuncs[i].init(SecColorIDs, _extSecondaryColor);
02141
02142 for(i = 0; i < 16; i++)
02143 multiTexCoordsInitFuncs[i].init(TexCoords1IDs, _extMultitexture);
02144
02145 _funcglSecondaryColorPointer = Window::registerFunction(
02146 OSG_DLSYM_UNDERSCORE"glSecondaryColorPointerEXT",
02147 _extSecondaryColor);
02148 _funcglClientActiveTextureARB = Window::registerFunction(
02149 OSG_DLSYM_UNDERSCORE"glClientActiveTextureARB",
02150 _extMultitexture);
02151 _funcglLockArraysEXT = Window::registerFunction(
02152 OSG_DLSYM_UNDERSCORE"glLockArraysEXT",
02153 _extCompiledVertexArray);
02154 _funcglUnlockArraysEXT = Window::registerFunction(
02155 OSG_DLSYM_UNDERSCORE"glUnlockArraysEXT",
02156 _extCompiledVertexArray);
02157 _funcglDrawRangeElementsEXT = Window::registerFunction(
02158 OSG_DLSYM_UNDERSCORE"glDrawRangeElementsEXT",
02159 _extDrawRangeElements);
02160
02161 _funcglGenBuffers = Window::registerFunction(
02162 OSG_DLSYM_UNDERSCORE"glGenBuffers",
02163 _arbVBO);
02164 _funcglDeleteBuffers = Window::registerFunction(
02165 OSG_DLSYM_UNDERSCORE"glDeleteBuffers",
02166 _arbVBO);
02167 _funcglBindBuffer = Window::registerFunction(
02168 OSG_DLSYM_UNDERSCORE"glBindBuffer",
02169 _arbVBO);
02170 _funcglBufferData = Window::registerFunction(
02171 OSG_DLSYM_UNDERSCORE"glBufferData",
02172 _arbVBO);
02173 _funcglBufferSubData = Window::registerFunction(
02174 OSG_DLSYM_UNDERSCORE"glBufferSubData",
02175 _arbVBO);
02176
02177 _funcglGenBuffersARB = Window::registerFunction(
02178 OSG_DLSYM_UNDERSCORE"glGenBuffersARB",
02179 _arbVBO);
02180 _funcglDeleteBuffersARB = Window::registerFunction(
02181 OSG_DLSYM_UNDERSCORE"glDeleteBuffersARB",
02182 _arbVBO);
02183 _funcglBindBufferARB = Window::registerFunction(
02184 OSG_DLSYM_UNDERSCORE"glBindBufferARB",
02185 _arbVBO);
02186 _funcglBufferDataARB = Window::registerFunction(
02187 OSG_DLSYM_UNDERSCORE"glBufferDataARB",
02188 _arbVBO);
02189 _funcglBufferSubDataARB = Window::registerFunction(
02190 OSG_DLSYM_UNDERSCORE"glBufferSubDataARB",
02191 _arbVBO);
02192
02193 return true;
02194 }
02195
02196
02197
02198
02199
02200 #ifndef GL_ARB_vertex_buffer_object
02201 #define GL_BUFFER_SIZE_ARB 0x8764
02202 #define GL_BUFFER_USAGE_ARB 0x8765
02203 #define GL_ARRAY_BUFFER_ARB 0x8892
02204 #define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
02205 #define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
02206 #define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
02207 #define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
02208 #define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
02209 #define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
02210 #define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
02211 #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
02212 #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
02213 #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
02214 #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
02215 #define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
02216 #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
02217 #define GL_READ_ONLY_ARB 0x88B8
02218 #define GL_WRITE_ONLY_ARB 0x88B9
02219 #define GL_READ_WRITE_ARB 0x88BA
02220 #define GL_BUFFER_ACCESS_ARB 0x88BB
02221 #define GL_BUFFER_MAPPED_ARB 0x88BC
02222 #define GL_BUFFER_MAP_POINTER_ARB 0x88BD
02223 #define GL_STREAM_DRAW_ARB 0x88E0
02224 #define GL_STREAM_READ_ARB 0x88E1
02225 #define GL_STREAM_COPY_ARB 0x88E2
02226 #define GL_STATIC_DRAW_ARB 0x88E4
02227 #define GL_STATIC_READ_ARB 0x88E5
02228 #define GL_STATIC_COPY_ARB 0x88E6
02229 #define GL_DYNAMIC_DRAW_ARB 0x88E8
02230 #define GL_DYNAMIC_READ_ARB 0x88E9
02231 #define GL_DYNAMIC_COPY_ARB 0x88EA
02232 #endif
02233
02234 #define pumpSetup2( name, typename, getmethod ) \
02235 typename name##Ptr; \
02236 GLubyte * name##Data = NULL; \
02237 UInt32 name##Size = 0; \
02238 \
02239 name##Ptr = geo->getmethod(); \
02240 if ( name##Ptr != NullFC ) \
02241 { \
02242 name##Data = name##Ptr->getData(); \
02243 name##Size = name##Ptr->getSize() * name##Ptr->getFormatSize() * name##Ptr->getDimension(); \
02244 }
02245
02246 GeoVBO::GeoVBO(Window *win, Geometry *geo) :
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 }
02265
02266 GeoVBO::~GeoVBO()
02267 {
02268
02269
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 }
02321
02322 void GeoVBO::update(void)
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
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
02390
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
02403
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 }
02636
02637 void GeoVBO::draw(void)
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;
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
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
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
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
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 }
03066
03067
03068
03069
03070
03071 #ifdef OSG_SGI_CC
03072 #pragma set woff 1174
03073 #endif
03074
03075 #ifdef OSG_LINUX_ICC
03076 #pragma warning( disable : 177 )
03077 #endif
03078
03079 namespace
03080 {
03081 static Char8 cvsid_cpp [] = "@(#)$Id: $";
03082 static Char8 cvsid_hpp [] = OSGGEOPUMPFACTORY_HEADER_CVSID;
03083 static Char8 cvsid_inl [] = OSGGEOPUMPFACTORY_INLINE_CVSID;
03084 }
03085