1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
17 * This library is free software; you can redistribute it and/or modify it *
18 * under the terms of the GNU Library General Public License as published *
19 * by the Free Software Foundation, version 2. *
21 * This library is distributed in the hope that it will be useful, but *
22 * WITHOUT ANY WARRANTY; without even the implied warranty of *
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
24 * Library General Public License for more details. *
26 * You should have received a copy of the GNU Library General Public *
27 * License along with this library; if not, write to the Free Software *
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
31 \*---------------------------------------------------------------------------*/
32 /*---------------------------------------------------------------------------*\
40 \*---------------------------------------------------------------------------*/
42 //---------------------------------------------------------------------------
44 //---------------------------------------------------------------------------
49 #include "OSGConfig.h"
56 #include "OSGGeometry.h"
57 #include "OSGDrawEnv.h"
59 #include "OSGMaterial.h"
61 #include "OSGGeoImmediatePumpGroup.h"
62 #include "OSGConceptPropertyChecks.h"
64 //#define DEBUG_WHICH_PUMP 1
68 // Intentionally INSIDE the namespace
69 #include "OSGGeoPumpCommon.inl"
71 /***************************************************************************\
73 \***************************************************************************/
75 /***************************************************************************\
77 \***************************************************************************/
79 /*! An InitFuncWrapper to initialize the GeoImmediatePumpGroup.
82 InitFuncWrapper
GeoImmediatePumpGroup::_glextInitFuncWrapper(
83 GeoImmediatePumpGroup::glextInitFunction
);
85 /*! OpenGL extension indices.
87 UInt32
GeoImmediatePumpGroup::_extSecondaryColor
;
88 UInt32
GeoImmediatePumpGroup::_extMultitexture
;
89 UInt32
GeoImmediatePumpGroup::_arbVertexProgram
;
91 /***************************************************************************\
93 \***************************************************************************/
95 /*------------- constructors & destructors --------------------------------*/
97 GeoImmediatePumpGroup::GeoImmediatePumpGroup(void)
101 GeoImmediatePumpGroup::~GeoImmediatePumpGroup(void)
105 /*-------------------------------------------------------------------------*\
107 \*-------------------------------------------------------------------------*/
109 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
113 struct PumpClassicInfo
: public PumpData
115 explicit PumpClassicInfo(void);
117 pumpFunc attribPump
[Geometry::MaxAttribs
];
118 multiPumpFunc attribMPump
[Geometry::MaxAttribs
];
121 PumpClassicInfo::PumpClassicInfo(void) :
124 for(Int16 i
= 0; i
< Geometry::MaxAttribs
; ++i
)
126 attribPump
[i
] = NULL
;
127 attribMPump
[i
] = NULL
;
133 // collect info for property in 'slot'
134 bool pumpGLSetup(PumpClassicInfo
&info
, UInt16 slot
, UInt32 pumpSlot
)
138 if(slot
< info
.prop
->size())
139 info
.attribPtr
[slot
] = (*info
.prop
)[slot
];
141 if(slot
< info
.propIdx
->size())
142 info
.attribIndex
[slot
] = (*info
.propIdx
)[slot
];
144 if(info
.attribPtr
[slot
] != NULL
&&
145 info
.attribPtr
[slot
]->getIgnore() == false )
147 info
.attribData
[slot
] = info
.attribPtr
[slot
]->getData();
148 info
.attribStride
[slot
] = info
.attribPtr
[slot
]->getStride();
150 if(info
.attribStride
[slot
] == 0)
152 info
.attribStride
[slot
] =
153 info
.attribPtr
[slot
]->getFormatSize() *
154 info
.attribPtr
[slot
]->getDimension();
157 UInt16 formatIdx
= info
.attribPtr
[slot
]->getFormat() - formatBase
;
158 UInt16 dimIdx
= info
.attribPtr
[slot
]->getDimension() - 1;
160 info
.attribPump
[slot
] = pumpFuncs
[pumpSlot
][formatIdx
][dimIdx
];
162 if(info
.attribPump
[slot
] == NULL
)
164 SWARNING
<< "GeoImmediatePumpGroup - pumpGLSetup: "
165 << "Invalid pump function for property " << slot
166 << " type " << info
.attribPtr
[slot
]->getDimension()
167 << "D " << formatNames
[formatIdx
]
170 info
.attribData
[slot
] = NULL
;
171 info
.attribStride
[slot
] = 0;
172 info
.attribPtr
[slot
] = NULL
;
173 info
.attribIndex
[slot
] = NULL
;
180 info
.attribData
[slot
] = NULL
;
181 info
.attribStride
[slot
] = 0;
182 info
.attribPtr
[slot
] = NULL
;
183 info
.attribIndex
[slot
] = NULL
;
189 // collect info for property in 'slot'
190 bool pumpGLSetup(PumpAttribInfo
&info
, UInt16 slot
)
194 if(slot
< info
.prop
->size())
195 info
.attribPtr
[slot
] = (*info
.prop
)[slot
];
197 if(slot
< info
.propIdx
->size())
198 info
.attribIndex
[slot
] = (*info
.propIdx
)[slot
];
200 if(info
.attribPtr
[slot
] != NULL
&&
201 info
.attribPtr
[slot
]->getIgnore() == false )
203 info
.attribData
[slot
] = info
.attribPtr
[slot
]->getData();
204 info
.attribStride
[slot
] = info
.attribPtr
[slot
]->getStride();
206 if(info
.attribStride
[slot
] == 0)
208 info
.attribStride
[slot
] =
209 info
.attribPtr
[slot
]->getFormatSize() *
210 info
.attribPtr
[slot
]->getDimension();
219 // collect info for property in 'slot' - using GL extension
220 bool pumpGLExtSetup(PumpClassicInfo
&info
, UInt16 slot
,
221 UInt32 pumpSlot
, Window
*win
)
223 if(slot
< info
.prop
->size())
224 info
.attribPtr
[slot
] = (*info
.prop
)[slot
];
226 if(slot
< info
.propIdx
->size())
227 info
.attribIndex
[slot
] = (*info
.propIdx
)[slot
];
229 if(info
.attribPtr
[slot
] != NULL
&&
230 info
.attribPtr
[slot
]->getIgnore() == false )
232 info
.attribData
[slot
] = info
.attribPtr
[slot
]->getData();
233 info
.attribStride
[slot
] = info
.attribPtr
[slot
]->getStride();
235 if(info
.attribStride
[slot
] == 0)
237 info
.attribStride
[slot
] =
238 info
.attribPtr
[slot
]->getFormatSize() *
239 info
.attribPtr
[slot
]->getDimension();
242 UInt16 formatIdx
= info
.attribPtr
[slot
]->getFormat() - formatBase
;
243 UInt16 dimIdx
= info
.attribPtr
[slot
]->getDimension() - 1;
245 UInt32 funcId
= pumpFuncIDs
[pumpSlot
][formatIdx
][dimIdx
];
247 if(funcId
== Window::invalidFunctionID
)
249 SWARNING
<< "GeoImmediatePumpGroup - pumpGLExtSetup: "
250 << "Invalid extension function for property " << slot
251 << " type " << info
.attribPtr
[slot
]->getDimension()
252 << "D " << formatNames
[formatIdx
]
255 info
.attribData
[slot
] = NULL
;
256 info
.attribStride
[slot
] = 0;
257 info
.attribPtr
[slot
] = NULL
;
258 info
.attribIndex
[slot
] = NULL
;
263 info
.attribPump
[slot
] =
264 reinterpret_cast<pumpFunc
>(win
->getFunction(funcId
));
266 if(info
.attribPump
[slot
] == NULL
)
268 SWARNING
<< "GeoImmediatePumpGroup - pumpGLExtSetup: "
269 << "Extension function for property " << slot
270 << " type " << info
.attribPtr
[slot
]->getDimension()
271 << "D " << formatNames
[formatIdx
]
272 << " not supported by Window " << win
275 info
.attribData
[slot
] = NULL
;
276 info
.attribStride
[slot
] = 0;
277 info
.attribPtr
[slot
] = NULL
;
278 info
.attribIndex
[slot
] = NULL
;
287 // collect info for property in 'slot' - using GL extension, multi
288 bool pumpGLExtMultiSetup(PumpClassicInfo
&info
, UInt16 slot
,
289 UInt32 pumpSlot
, Window
*win
)
291 if(slot
< info
.prop
->size())
292 info
.attribPtr
[slot
] = (*info
.prop
)[slot
];
294 if(slot
< info
.propIdx
->size())
295 info
.attribIndex
[slot
] = (*info
.propIdx
)[slot
];
297 if(info
.attribPtr
[slot
] != NULL
&&
298 info
.attribPtr
[slot
]->getIgnore() == false )
300 info
.attribData
[slot
] = info
.attribPtr
[slot
]->getData();
301 info
.attribStride
[slot
] = info
.attribPtr
[slot
]->getStride();
303 if(info
.attribStride
[slot
] == 0)
305 info
.attribStride
[slot
] =
306 info
.attribPtr
[slot
]->getFormatSize() *
307 info
.attribPtr
[slot
]->getDimension();
310 UInt16 formatIdx
= info
.attribPtr
[slot
]->getFormat() - formatBase
;
311 UInt32 dimIdx
= info
.attribPtr
[slot
]->getDimension() - 1;
313 UInt32 funcId
= pumpFuncIDs
[pumpSlot
][formatIdx
][dimIdx
];
315 if(funcId
== Window::invalidFunctionID
)
317 SWARNING
<< "GeoImmediatePumpGroup - pumpGLExtMultiSetup: "
318 << "Invalid extension function for property " << slot
319 << " type " << info
.attribPtr
[slot
]->getDimension()
320 << "D " << formatNames
[formatIdx
]
323 info
.attribData
[slot
] = NULL
;
324 info
.attribStride
[slot
] = 0;
325 info
.attribPtr
[slot
] = NULL
;
326 info
.attribIndex
[slot
] = NULL
;
331 info
.attribMPump
[slot
] =
332 reinterpret_cast<multiPumpFunc
>(win
->getFunction(funcId
));
334 if(info
.attribMPump
[slot
] == NULL
)
336 SWARNING
<< "GeoImmediatePumpGroup - pumpGLExtMultiSetup: "
337 << "Extension function for property " << slot
338 << " type " << info
.attribPtr
[slot
]->getDimension()
339 << "D " << formatNames
[formatIdx
]
340 << " not supported by Window " << win
343 info
.attribData
[slot
] = NULL
;
344 info
.attribStride
[slot
] = 0;
345 info
.attribPtr
[slot
] = NULL
;
346 info
.attribIndex
[slot
] = NULL
;
356 // handle vertex attrib with global value
357 void globalAttrib(PumpClassicInfo
&info
, UInt16 slot
, UInt16 pumpSlot
)
359 if(info
.attribData
[slot
] != NULL
&&
360 info
.attribPtr
[slot
]->size() == 1 )
362 OSG_ASSERT(info
.attribPump
[slot
] != NULL
);
364 info
.attribPump
[slot
](info
.attribData
[slot
]);
365 info
.attribData
[slot
] = NULL
;
369 // handle vertex attrib with global value - using GL extension
370 void globalExtAttrib(PumpClassicInfo
&info
, UInt16 slot
,
371 UInt16 pumpSlot
, Window
*win
)
373 if(info
.attribData
[slot
] != NULL
&&
374 info
.attribPtr
[slot
]->size() == 1 )
376 OSG_ASSERT(info
.attribPump
[slot
] != NULL
);
378 info
.attribPump
[slot
](info
.attribData
[slot
]);
379 info
.attribData
[slot
] = NULL
;
383 // handle vertex attrib with global value - using GL extension, multi
384 void globalExtMultiAttrib(PumpClassicInfo
&info
, UInt16 slot
,
385 UInt16 pumpSlot
, GLenum attrib
,
388 if(info
.attribData
[slot
] != NULL
&&
389 info
.attribPtr
[slot
]->size() == 1 )
391 OSG_ASSERT(info
.attribMPump
[slot
] != NULL
);
393 info
.attribMPump
[slot
](attrib
, info
.attribData
[slot
]);
394 info
.attribData
[slot
] = NULL
;
398 // pass a single attrib value to OpenGL
399 void pumpAttrib(PumpClassicInfo
&info
, UInt16 slot
, UInt32 vertIdx
)
401 if(info
.attribData
[slot
] != NULL
)
403 OSG_ASSERT(info
.attribPump
[slot
] != NULL
);
405 if(info
.attribIndex
[slot
] != NULL
)
407 info
.attribPump
[slot
](
408 info
.attribData
[slot
] +
409 info
.attribStride
[slot
] *
410 info
.attribIndex
[slot
]->getValue
<UInt32
>(vertIdx
));
414 info
.attribPump
[slot
](
415 info
.attribData
[slot
] +
416 info
.attribStride
[slot
] * vertIdx
);
421 // pass a single (multi) attrib value to OpenGL
422 void pumpMultiAttrib(PumpClassicInfo
&info
, UInt16 slot
,
423 GLenum attrib
, UInt32 vertIdx
)
425 if(info
.attribData
[slot
] != NULL
)
427 OSG_ASSERT(info
.attribMPump
[slot
] != NULL
);
429 if(info
.attribIndex
[slot
] != NULL
)
431 info
.attribMPump
[slot
](
433 info
.attribData
[slot
] +
434 info
.attribStride
[slot
] *
435 info
.attribIndex
[slot
]->getValue
<UInt32
>(vertIdx
));
439 info
.attribMPump
[slot
](
441 info
.attribData
[slot
] +
442 info
.attribStride
[slot
] * vertIdx
);
449 #endif // remove from all but dev docs
451 GeoPumpGroup::GeoPump
GeoImmediatePumpGroup::getGeoPump(
453 PropertyCharacteristics acset
)
455 Window
*win
= pEnv
->getWindow();
457 if(win
->hasExtOrVersion(_arbVertexProgram
,
459 0x0200 ) && (acset
& UsesShader
))
461 return masterAttribGeoPump
;
465 return masterClassicGeoPump
;
469 bool GeoImmediatePumpGroup::glextInitFunction(void)
472 Window::registerExtension("GL_EXT_secondary_color");
474 Window::registerExtension("GL_ARB_multitexture");
476 Window::registerExtension("GL_ARB_vertex_program");
478 for(UInt16 i
= 0; i
< numFormats
; ++i
)
480 for(UInt16 j
= 0; j
< 4; ++j
)
482 pumpFuncIDs
[0][i
][j
] = Window::invalidFunctionID
;
483 pumpFuncIDs
[1][i
][j
] = Window::invalidFunctionID
;
487 for(UInt16 i
= 0; i
< uiNumSecColFunc
; ++i
)
488 secondaryColorInitFuncs
[i
].init(pumpFuncIDs
[SecColorsPumpSlot
],
489 _extSecondaryColor
);
491 for(UInt16 i
= 0; i
< uiNumMTexFuncs
; ++i
)
492 multiTexCoordsInitFuncs
[i
].init(pumpFuncIDs
[TexCoords1PumpSlot
],
495 for(UInt16 i
= 0; i
< uiNumAttribFuncs
; ++i
)
496 attribInitFuncs
[i
].init(attribPumpFuncIDs
, _arbVertexProgram
);
498 for(UInt16 i
= 0; i
< uiNumNormAttribFuncs
; ++i
)
499 normAttribInitFuncs
[i
].init(normAttribPumpFuncIDs
, _arbVertexProgram
);
501 #if defined(OSG_USE_OGLES_PROTOS) || defined(OSG_USE_OGL3_PROTOS) || \
502 defined(OSG_USE_OGL4_PROTOS)
503 osgSinkUnusedWarning(attribPumpFuncs
);
504 osgSinkUnusedWarning(attribNormPumpFuncs
);
510 void GeoImmediatePumpGroup::masterClassicGeoPump(
512 const GeoIntegralProperty
*lengths
,
513 const GeoIntegralProperty
*types
,
514 const Geometry::MFPropertiesType
*prop
,
515 const Geometry::MFPropIndicesType
*propIdx
,
518 #ifdef DEBUG_WHICH_PUMP
519 static bool bPrinted
= false;
521 if(bPrinted
== false)
523 fprintf(stderr
, "GeoImmediatePumpGroup::masterClassicGeoPump\n");
528 Window
*win
= pEnv
->getWindow();
530 // Setup: get all the data
532 // check for empty geometry
533 if(types
== NULL
|| types
->size() == 0)
536 if(!pumpInternalSetup(types
, true))
538 if(!pumpInternalSetup(lengths
, false))
541 PumpClassicInfo pumpInfo
;
542 pumpInfo
.lengths
= lengths
;
543 pumpInfo
.types
= types
;
544 pumpInfo
.prop
= prop
;
545 pumpInfo
.propIdx
= propIdx
;
547 // setup standard properties
548 pumpGLSetup(pumpInfo
, Geometry::PositionsIndex
, PositionsPumpSlot
);
549 pumpGLSetup(pumpInfo
, Geometry::ColorsIndex
, ColorsPumpSlot
);
550 pumpGLSetup(pumpInfo
, Geometry::NormalsIndex
, NormalsPumpSlot
);
551 pumpGLSetup(pumpInfo
, Geometry::TexCoordsIndex
, TexCoordsPumpSlot
);
553 // setup extension properties
554 if(win
->hasExtOrVersion(_extSecondaryColor
, 0x0104) == true)
556 pumpGLExtSetup(pumpInfo
, Geometry::SecondaryColorsIndex
,
557 SecColorsPumpSlot
, win
);
560 // setup extension multi properties
561 if(win
->hasExtOrVersion(_extMultitexture
, 0x0103, 0x0200) == true)
563 pumpGLExtMultiSetup(pumpInfo
, Geometry::TexCoords1Index
,
564 TexCoords1PumpSlot
, win
);
565 pumpGLExtMultiSetup(pumpInfo
, Geometry::TexCoords2Index
,
566 TexCoords2PumpSlot
, win
);
567 pumpGLExtMultiSetup(pumpInfo
, Geometry::TexCoords3Index
,
568 TexCoords3PumpSlot
, win
);
569 pumpGLExtMultiSetup(pumpInfo
, Geometry::TexCoords4Index
,
570 TexCoords4PumpSlot
, win
);
571 pumpGLExtMultiSetup(pumpInfo
, Geometry::TexCoords5Index
,
572 TexCoords5PumpSlot
, win
);
573 pumpGLExtMultiSetup(pumpInfo
, Geometry::TexCoords6Index
,
574 TexCoords6PumpSlot
, win
);
575 pumpGLExtMultiSetup(pumpInfo
, Geometry::TexCoords7Index
,
576 TexCoords7PumpSlot
, win
);
580 if(pumpInfo
.attribPtr
[Geometry::PositionsIndex
] == NULL
)
582 if(pumpInfo
.attribPtr
[Geometry::PositionsIndex
] == NULL
||
583 pumpInfo
.attribPtr
[Geometry::PositionsIndex
]->getUseVBO() == false)
585 SWARNING
<< "GeoImmediatePumpGroup::masterClassicGeoPump: "
586 << "No positions." << endLog
;
592 globalAttrib(pumpInfo
, Geometry::NormalsIndex
, NormalsPumpSlot
);
593 globalAttrib(pumpInfo
, Geometry::ColorsIndex
, ColorsPumpSlot
);
594 globalAttrib(pumpInfo
, Geometry::TexCoordsIndex
, TexCoordsPumpSlot
);
596 if(win
->hasExtOrVersion(_extSecondaryColor
, 0x0200) == true)
598 globalExtAttrib(pumpInfo
, Geometry::SecondaryColorsIndex
,
599 SecColorsPumpSlot
, win
);
602 if(win
->hasExtOrVersion(_extMultitexture
, 0x0103, 0x0200) == true)
604 globalExtMultiAttrib(pumpInfo
, Geometry::TexCoords1Index
,
605 TexCoords1PumpSlot
, GL_TEXTURE1_ARB
, win
);
606 globalExtMultiAttrib(pumpInfo
, Geometry::TexCoords1Index
,
607 TexCoords2PumpSlot
, GL_TEXTURE2_ARB
, win
);
608 globalExtMultiAttrib(pumpInfo
, Geometry::TexCoords1Index
,
609 TexCoords3PumpSlot
, GL_TEXTURE3_ARB
, win
);
610 globalExtMultiAttrib(pumpInfo
, Geometry::TexCoords1Index
,
611 TexCoords4PumpSlot
, GL_TEXTURE4_ARB
, win
);
612 globalExtMultiAttrib(pumpInfo
, Geometry::TexCoords1Index
,
613 TexCoords5PumpSlot
, GL_TEXTURE5_ARB
, win
);
614 globalExtMultiAttrib(pumpInfo
, Geometry::TexCoords1Index
,
615 TexCoords6PumpSlot
, GL_TEXTURE6_ARB
, win
);
616 globalExtMultiAttrib(pumpInfo
, Geometry::TexCoords1Index
,
617 TexCoords7PumpSlot
, GL_TEXTURE7_ARB
, win
);
620 // Length handling. Special case: no length given
625 // no lengths? use all available data for the first type
628 if(types
->size() != 1)
630 SWARNING
<< "GeoImmediatePumpGroup::masterClassicGeoPump: "
631 << "No lengths, but more than one type?!"
637 if(pumpInfo
.attribIndex
[Geometry::PositionsIndex
] != NULL
)
639 curlen
= pumpInfo
.attribIndex
[Geometry::PositionsIndex
]->size32();
643 curlen
= pumpInfo
.attribPtr
[Geometry::PositionsIndex
]->size32();
648 nprims
= types
->size32();
649 lengths
->getValue(curlen
, 0);
652 UInt32 vertindex
= 0;
654 for(UInt32 primindex
= 0; primindex
< nprims
; ++primindex
)
656 glBegin(types
->getValue
<UInt16
>(primindex
));
658 if(primindex
< lengths
->size())
659 curlen
= lengths
->getValue
<UInt32
>(primindex
);
661 for(; curlen
> 0; --curlen
, ++vertindex
)
663 pumpAttrib(pumpInfo
, Geometry::NormalsIndex
, vertindex
);
664 pumpAttrib(pumpInfo
, Geometry::ColorsIndex
, vertindex
);
665 pumpAttrib(pumpInfo
, Geometry::TexCoordsIndex
, vertindex
);
667 if(win
->hasExtOrVersion(_extSecondaryColor
, 0x0104) == true)
669 pumpAttrib(pumpInfo
, Geometry::SecondaryColorsIndex
, vertindex
);
672 if(win
->hasExtOrVersion(_extMultitexture
, 0x0103, 0x0200))
674 pumpMultiAttrib(pumpInfo
, Geometry::TexCoords1Index
,
675 GL_TEXTURE1_ARB
, vertindex
);
676 pumpMultiAttrib(pumpInfo
, Geometry::TexCoords2Index
,
677 GL_TEXTURE2_ARB
, vertindex
);
678 pumpMultiAttrib(pumpInfo
, Geometry::TexCoords3Index
,
679 GL_TEXTURE3_ARB
, vertindex
);
680 pumpMultiAttrib(pumpInfo
, Geometry::TexCoords4Index
,
681 GL_TEXTURE4_ARB
, vertindex
);
682 pumpMultiAttrib(pumpInfo
, Geometry::TexCoords5Index
,
683 GL_TEXTURE5_ARB
, vertindex
);
684 pumpMultiAttrib(pumpInfo
, Geometry::TexCoords6Index
,
685 GL_TEXTURE6_ARB
, vertindex
);
686 pumpMultiAttrib(pumpInfo
, Geometry::TexCoords7Index
,
687 GL_TEXTURE7_ARB
, vertindex
);
690 pumpAttrib(pumpInfo
, Geometry::PositionsIndex
, vertindex
);
697 void GeoImmediatePumpGroup::masterAttribGeoPump(
699 const GeoIntegralProperty
*lengths
,
700 const GeoIntegralProperty
*types
,
701 const Geometry::MFPropertiesType
*prop
,
702 const Geometry::MFPropIndicesType
*propIdx
,
705 #ifdef DEBUG_WHICH_PUMP
706 static bool bPrinted
= false;
708 if(bPrinted
== false)
710 fprintf(stderr
, "GeoImmediatePumpGroup::masterAttribGeoPump\n");
715 Window
*win
= pEnv
->getWindow();
717 // Setup: get all the data
719 // check for empty geometry
720 if(types
== NULL
|| types
->size() == 0)
723 if(!pumpInternalSetup(types
, true))
725 if(!pumpInternalSetup(lengths
, false))
728 PumpAttribInfo pumpInfo
;
729 pumpInfo
.lengths
= lengths
;
730 pumpInfo
.types
= types
;
731 pumpInfo
.prop
= prop
;
732 pumpInfo
.propIdx
= propIdx
;
734 UInt16 nattrib
= prop
->size32();
736 for(UInt16 i
= 0; i
< nattrib
; ++i
)
738 if(pumpGLSetup(pumpInfo
, i
) == false)
741 UInt16 formatIdx
= pumpInfo
.attribPtr
[i
]->getFormat () - formatBase
;
742 UInt16 dimIdx
= pumpInfo
.attribPtr
[i
]->getDimension() - 1;
743 UInt32 funcId
= Window::invalidFunctionID
;
745 if(pumpInfo
.attribPtr
[i
]->getNormalize() == true)
747 funcId
= normAttribPumpFuncIDs
[formatIdx
][dimIdx
];
749 if(funcId
== Window::invalidFunctionID
)
751 SWARNING
<< "GeoImmediatePumpGroup::masterAttribGeoPump: "
752 << "Invalid pump function for property " << i
753 << " type " << pumpInfo
.attribPtr
[i
]->getDimension()
754 << "D " << formatNames
[formatIdx
] << " (normalizing)."
757 pumpInfo
.attribData
[i
] = NULL
;
758 pumpInfo
.attribPtr
[i
] = NULL
;
764 funcId
= attribPumpFuncIDs
[formatIdx
][dimIdx
];
766 if(funcId
== Window::invalidFunctionID
)
768 SWARNING
<< "GeoImmediatePumpGroup::masterAttribGeoPump: "
769 << "Invalid pump function for property " << i
770 << " type " << pumpInfo
.attribPtr
[i
]->getDimension()
771 << "D " << formatNames
[formatIdx
]
774 pumpInfo
.attribData
[i
] = NULL
;
775 pumpInfo
.attribPtr
[i
] = NULL
;
780 pumpInfo
.attribPump
[i
] = reinterpret_cast<attribPumpFunc
>(
781 win
->getFunction(funcId
));
783 if(pumpInfo
.attribPump
[i
] == NULL
)
785 SWARNING
<< "GeoImmediatePumpGroup::masterAttribGeoPump: "
786 << "Extension function for property " << i
787 << " type " << pumpInfo
.attribPtr
[i
]->getDimension()
788 << "D " << formatNames
[formatIdx
]
789 << " not supported by Window " << win
792 pumpInfo
.attribData
[i
] = NULL
;
793 pumpInfo
.attribPtr
[i
] = NULL
;
799 if(pumpInfo
.attribPtr
[0] == NULL
)
801 if(pumpInfo
.attribPtr
[0] == NULL
||
802 pumpInfo
.attribPtr
[0]->getUseVBO() == false)
804 SWARNING
<< "GeoImmediatePumpGroup::masterAttribGeoPump: "
805 << "No positions." << endLog
;
811 for(Int16 i
= 0; i
< nattrib
; ++i
)
813 if(pumpInfo
.attribData
[i
] != NULL
&&
814 pumpInfo
.attribPtr
[i
]->size() == 1 )
816 pumpInfo
.attribPump
[i
](i
, pumpInfo
.attribData
[i
]);
817 pumpInfo
.attribData
[i
] = NULL
;
821 // Length handling. Special case: no length given
826 // no lengths? use all available data for the first type
829 if(types
->size() != 1)
831 SWARNING
<< "GeoImmediatePumpGroup::masterAttribGeoPump: "
832 << "No lengths, but more than one type?!"
838 if(pumpInfo
.attribIndex
[0] != NULL
)
840 curlen
= pumpInfo
.attribIndex
[0]->size32();
844 curlen
= pumpInfo
.attribPtr
[0]->size32();
849 nprims
= types
->size32();
850 lengths
->getValue(curlen
, 0);
853 UInt32 vertindex
= 0;
855 for(UInt32 primindex
= 0; primindex
< nprims
; ++primindex
)
857 glBegin(types
->getValue
<UInt16
>(primindex
));
859 if(primindex
< lengths
->size())
860 curlen
= lengths
->getValue
<UInt32
>(primindex
);
862 for(; curlen
> 0; --curlen
, ++vertindex
)
864 for(Int16 i
= nattrib
- 1; i
>= 0; --i
)
866 if(pumpInfo
.attribData
[i
])
868 if(pumpInfo
.attribIndex
[i
] != NULL
)
870 pumpInfo
.attribPump
[i
](
871 i
, pumpInfo
.attribData
[i
] +
872 pumpInfo
.attribStride
[i
] *
873 pumpInfo
.attribIndex
[i
]->getValue
<UInt32
>(vertindex
));
877 pumpInfo
.attribPump
[i
](
878 i
, pumpInfo
.attribData
[i
] +
879 pumpInfo
.attribStride
[i
] * vertindex
);