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 //---------------------------------------------------------------------------
46 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
48 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
49 #pragma GCC diagnostic push
50 #pragma GCC diagnostic ignored "-Wunused-function"
55 // Pumping function definitions
57 typedef void (OSG_APIENTRY *pumpFunc )(const UInt8 *data);
58 typedef void (OSG_APIENTRY *multiPumpFunc )( GLenum which,
60 typedef void (OSG_APIENTRY *attribPumpFunc)( GLuint index,
64 // Some helper arrays for function selection
65 // indexed by data type and dimension
67 const Int16 formatBase = GL_BYTE;
68 #ifndef OSG_OGL_NO_DOUBLE
69 const Int16 numFormats = GL_DOUBLE - GL_BYTE + 1;
71 const Int16 numFormats = GL_4_BYTES - GL_BYTE + 1;
74 const char *formatNames[] =
85 #ifndef OSG_OGL_NO_DOUBLE
87 "GL_DOUBLE_EXT", // Not used
89 "GL_FIXED" // Not used
92 // little helper class for function init
98 glextFuncInit(const char *name,
101 bool normalizing = false) :
106 _normalizing(normalizing)
110 void init(UInt32 (&extids)[numFormats][4], UInt32 extension)
112 extids[_format - formatBase][_dim - 1] =
113 Window::registerFunction(_name, extension);
125 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
127 const UInt32 uiNumSecColFunc = 8;
129 glextFuncInit secondaryColorInitFuncs[uiNumSecColFunc] = {
130 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3bvEXT",
133 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3ubvEXT",
136 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3svEXT",
139 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3usvEXT",
142 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3ivEXT",
145 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3uivEXT",
148 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3fvEXT",
151 glextFuncInit(OSG_DLSYM_UNDERSCORE"glSecondaryColor3dvEXT",
156 const UInt32 uiNumMTexFuncs = 16;
158 glextFuncInit multiTexCoordsInitFuncs[uiNumMTexFuncs] = {
159 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord1svARB",
162 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord2svARB",
165 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord3svARB",
168 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord4svARB",
171 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord1ivARB",
174 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord2ivARB",
177 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord3ivARB",
180 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord4ivARB",
183 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord1fvARB",
186 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord2fvARB",
189 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord3fvARB",
192 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord4fvARB",
195 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord1dvARB",
198 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord2dvARB",
201 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord3dvARB",
204 glextFuncInit(OSG_DLSYM_UNDERSCORE"glMultiTexCoord4dvARB",
212 #ifndef OSG_OGL_NO_DOUBLE
213 const UInt32 uiNumAttribFuncs = 23;
215 const UInt32 uiNumAttribFuncs = 19;
218 glextFuncInit attribInitFuncs[uiNumAttribFuncs] = {
219 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib1svARB",
222 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib1fvARB",
225 #ifndef OSG_OGL_NO_DOUBLE
226 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib1dvARB",
230 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib2svARB",
233 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib2fvARB",
236 #ifndef OSG_OGL_NO_DOUBLE
237 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib2dvARB",
241 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib3svARB",
244 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib3fvARB",
247 #ifndef OSG_OGL_NO_DOUBLE
248 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib3dvARB",
252 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4bvARB",
255 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4svARB",
258 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4ivARB",
261 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4ubvARB",
264 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4usvARB",
267 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4uivARB",
270 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4bvARB",
273 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4svARB",
276 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4ivARB",
279 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4ubvARB",
282 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4usvARB",
285 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4uivARB",
288 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4fvARB",
291 #ifndef OSG_OGL_NO_DOUBLE
292 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4dvARB",
298 const UInt32 uiNumNormAttribFuncs = 6;
300 glextFuncInit normAttribInitFuncs[uiNumNormAttribFuncs] = {
301 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4NbvARB",
304 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4NsvARB",
307 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4NivARB",
310 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4NubvARB",
313 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4NusvARB",
316 glextFuncInit(OSG_DLSYM_UNDERSCORE"glVertexAttrib4NuivARB",
323 // Classic pumping functions
325 const UInt16 PositionsPumpSlot = 0;
326 const UInt16 NormalsPumpSlot = 1;
327 const UInt16 ColorsPumpSlot = 2;
328 const UInt16 TexCoordsPumpSlot = 3;
331 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
332 pumpFunc pumpFuncs[4][numFormats][4] = {
334 { NULL, NULL, NULL, NULL }, // GL_BYTE
335 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_BYTE
337 reinterpret_cast<pumpFunc>(glVertex2sv),
338 reinterpret_cast<pumpFunc>(glVertex3sv),
339 reinterpret_cast<pumpFunc>(glVertex4sv) }, // GL_SHORT
340 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_SHORT
342 reinterpret_cast<pumpFunc>(glVertex2iv),
343 reinterpret_cast<pumpFunc>(glVertex3iv),
344 reinterpret_cast<pumpFunc>(glVertex4iv) }, // GL_INT
345 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_INT
347 reinterpret_cast<pumpFunc>(glVertex2fv),
348 reinterpret_cast<pumpFunc>(glVertex3fv),
349 reinterpret_cast<pumpFunc>(glVertex4fv) }, // GL_FLOAT
350 { NULL, NULL, NULL, NULL }, // GL_2_BYTES
351 { NULL, NULL, NULL, NULL }, // GL_3_BYTES
352 { NULL, NULL, NULL, NULL }, // GL_4_BYTES
354 reinterpret_cast<pumpFunc>(glVertex2dv),
355 reinterpret_cast<pumpFunc>(glVertex3dv),
356 reinterpret_cast<pumpFunc>(glVertex4dv) }, // GL_DOUBLE
361 reinterpret_cast<pumpFunc>(glNormal3sv),
363 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_BYTE
366 reinterpret_cast<pumpFunc>(glNormal3sv),
368 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_SHORT
370 reinterpret_cast<pumpFunc>(glNormal3iv),
372 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_INT
375 reinterpret_cast<pumpFunc>(glNormal3fv),
377 { NULL, NULL, NULL, NULL }, // GL_2_BYTES
378 { NULL, NULL, NULL, NULL }, // GL_3_BYTES
379 { NULL, NULL, NULL, NULL }, // GL_4_BYTES
382 reinterpret_cast<pumpFunc>(glNormal3dv),
388 reinterpret_cast<pumpFunc>(glColor3bv),
389 reinterpret_cast<pumpFunc>(glColor4bv) }, // GL_BYTE
392 reinterpret_cast<pumpFunc>(glColor3ubv),
393 reinterpret_cast<pumpFunc>(glColor4ubv) }, // GL_UNSIGNED_BYTE
396 reinterpret_cast<pumpFunc>(glColor3sv),
397 reinterpret_cast<pumpFunc>(glColor4sv) }, // GL_SHORT
400 reinterpret_cast<pumpFunc>(glColor3usv),
401 reinterpret_cast<pumpFunc>(glColor4usv) }, // GL_UNSIGNED_SHORT
404 reinterpret_cast<pumpFunc>(glColor3iv),
405 reinterpret_cast<pumpFunc>(glColor4iv) }, // GL_INT
408 reinterpret_cast<pumpFunc>(glColor3uiv),
409 reinterpret_cast<pumpFunc>(glColor4uiv) }, // GL_UNSIGNED_INT
412 reinterpret_cast<pumpFunc>(glColor3fv),
413 reinterpret_cast<pumpFunc>(glColor4fv) }, // GL_FLOAT
414 { NULL, NULL, NULL, NULL }, // GL_2_BYTES
415 { NULL, NULL, NULL, NULL }, // GL_3_BYTES
416 { NULL, NULL, NULL, NULL }, // GL_4_BYTES
419 reinterpret_cast<pumpFunc>(glColor3dv),
420 reinterpret_cast<pumpFunc>(glColor4dv) }, // GL_DOUBLE
423 { NULL, NULL, NULL, NULL }, // GL_BYTE
424 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_BYTE
425 { reinterpret_cast<pumpFunc>(glTexCoord1sv),
426 reinterpret_cast<pumpFunc>(glTexCoord2sv),
427 reinterpret_cast<pumpFunc>(glTexCoord3sv),
428 reinterpret_cast<pumpFunc>(glTexCoord4sv) }, // GL_SHORT
429 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_SHORT
430 { reinterpret_cast<pumpFunc>(glTexCoord1iv),
431 reinterpret_cast<pumpFunc>(glTexCoord2iv),
432 reinterpret_cast<pumpFunc>(glTexCoord3iv),
433 reinterpret_cast<pumpFunc>(glTexCoord4iv) }, // GL_INT
434 { NULL, NULL, NULL, NULL }, // GL_UNSIGNED_INT
435 { reinterpret_cast<pumpFunc>(glTexCoord1fv),
436 reinterpret_cast<pumpFunc>(glTexCoord2fv),
437 reinterpret_cast<pumpFunc>(glTexCoord3fv),
438 reinterpret_cast<pumpFunc>(glTexCoord4fv) }, // GL_FLOAT
439 { NULL, NULL, NULL, NULL }, // GL_2_BYTES
440 { NULL, NULL, NULL, NULL }, // GL_3_BYTES
441 { NULL, NULL, NULL, NULL }, // GL_4_BYTES
442 { reinterpret_cast<pumpFunc>(glTexCoord1dv),
443 reinterpret_cast<pumpFunc>(glTexCoord2dv),
444 reinterpret_cast<pumpFunc>(glTexCoord3dv),
445 reinterpret_cast<pumpFunc>(glTexCoord4dv) }, // GL_DOUBLE
451 #if defined(OSG_USE_OGLES_PROTOS) || defined(OSG_USE_OGL3_PROTOS) || \
452 defined(OSG_USE_OGL4_PROTOS)
454 attribPumpFunc attribPumpFuncs[numFormats][4] = {
455 #if !defined(OSG_USE_OGLES_PROTOS)
456 { NULL, NULL, NULL, // GL_BYTE
457 reinterpret_cast<attribPumpFunc>(glVertexAttrib4bv) },
458 { NULL, NULL, NULL, // GL_UBYTE
459 reinterpret_cast<attribPumpFunc>(glVertexAttrib4ubv) },
460 { reinterpret_cast<attribPumpFunc>(glVertexAttrib1sv),
461 reinterpret_cast<attribPumpFunc>(glVertexAttrib2sv),
462 reinterpret_cast<attribPumpFunc>(glVertexAttrib3sv),
463 reinterpret_cast<attribPumpFunc>(glVertexAttrib4sv) }, // GL_SHORT
464 { NULL, NULL, NULL, // GL_USHORT
465 reinterpret_cast<attribPumpFunc>(glVertexAttrib4usv) },
466 { NULL, NULL, NULL, // GL_INT
467 reinterpret_cast<attribPumpFunc>(glVertexAttrib4iv) },
468 { NULL, NULL, NULL, // GL_UINT
469 reinterpret_cast<attribPumpFunc>(glVertexAttrib4uiv) },
471 { NULL, NULL, NULL, NULL }, // GL_BYTE ES
472 { NULL, NULL, NULL, NULL }, // GL_UBYTE ES
473 { NULL, NULL, NULL, NULL }, // GL_SHORT ES
474 { NULL, NULL, NULL, NULL }, // GL_USHORT ES
475 { NULL, NULL, NULL, NULL }, // GL_INT ES
476 { NULL, NULL, NULL, NULL }, // GL_UINT ES
478 { reinterpret_cast<attribPumpFunc>(glVertexAttrib1fv),
479 reinterpret_cast<attribPumpFunc>(glVertexAttrib2fv),
480 reinterpret_cast<attribPumpFunc>(glVertexAttrib3fv),
481 reinterpret_cast<attribPumpFunc>(glVertexAttrib4fv) }, // GL_FLOAT
482 { NULL, NULL, NULL, NULL }, // GL_2_BYTES
483 { NULL, NULL, NULL, NULL }, // GL_3_BYTES
484 { NULL, NULL, NULL, NULL }, // GL_4_BYTES
485 #if !defined(OSG_OGL_NO_DOUBLE)
486 { reinterpret_cast<attribPumpFunc>(glVertexAttrib1dv),
487 reinterpret_cast<attribPumpFunc>(glVertexAttrib2dv),
488 reinterpret_cast<attribPumpFunc>(glVertexAttrib3dv),
489 reinterpret_cast<attribPumpFunc>(glVertexAttrib4dv) } // GL_DOUBLE
494 attribPumpFunc attribNormPumpFuncs[numFormats][4] = {
495 #if !defined(OSG_USE_OGLES_PROTOS)
496 { NULL, NULL, NULL, // GL_BYTE
497 reinterpret_cast<attribPumpFunc>(glVertexAttrib4Nbv) },
498 { NULL, NULL, NULL, // GL_UBYTE
499 reinterpret_cast<attribPumpFunc>(glVertexAttrib4Nubv) },
501 reinterpret_cast<attribPumpFunc>(glVertexAttrib4Nsv) }, // GL_SHORT
502 { NULL, NULL, NULL, // GL_USHORT
503 reinterpret_cast<attribPumpFunc>(glVertexAttrib4Nusv) },
504 { NULL, NULL, NULL, // GL_INT
505 reinterpret_cast<attribPumpFunc>(glVertexAttrib4Niv) },
506 { NULL, NULL, NULL, // GL_UINT
507 reinterpret_cast<attribPumpFunc>(glVertexAttrib4Nuiv) },
508 { NULL, NULL, NULL, NULL }, // GL_FLOAT
509 { NULL, NULL, NULL, NULL }, // GL_2_BYTES
510 { NULL, NULL, NULL, NULL }, // GL_3_BYTES
511 { NULL, NULL, NULL, NULL }, // GL_4_BYTES
512 #if !defined(OSG_OGL_NO_DOUBLE)
513 { NULL, NULL, NULL, NULL } // GL_DOUBLE
516 #else // !OSG_USE_OGLES_PROTOS
517 { NULL, NULL, NULL, NULL }, // GL_BYTE ES
518 { NULL, NULL, NULL, NULL }, // GL_UBYTE ES
519 { NULL, NULL, NULL, NULL }, // GL_SHORT ES
520 { NULL, NULL, NULL, NULL }, // GL_USHORT ES
521 { NULL, NULL, NULL, NULL }, // GL_INT ES
522 { NULL, NULL, NULL, NULL }, // GL_UINT ES
523 { NULL, NULL, NULL, NULL }, // GL_FLOAT ES
524 { NULL, NULL, NULL, NULL }, // GL_2_BYTES ES
525 { NULL, NULL, NULL, NULL }, // GL_3_BYTES ES
526 { NULL, NULL, NULL, NULL }, // GL_4_BYTES ES
527 #if !defined(OSG_OGL_NO_DOUBLE)
528 { NULL, NULL, NULL, NULL } // GL_DOUBLE ES
530 #endif // OSG_USE_OGLES_PROTOS
536 const UInt16 SecColorsPumpSlot = 0;
537 const UInt16 TexCoords1PumpSlot = 1;
538 const UInt16 TexCoords2PumpSlot = 1;
539 const UInt16 TexCoords3PumpSlot = 1;
540 const UInt16 TexCoords4PumpSlot = 1;
541 const UInt16 TexCoords5PumpSlot = 1;
542 const UInt16 TexCoords6PumpSlot = 1;
543 const UInt16 TexCoords7PumpSlot = 1;
545 #if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
546 UInt32 pumpFuncIDs [2][numFormats][4];
549 UInt32 attribPumpFuncIDs [numFormats][4];
550 UInt32 normAttribPumpFuncIDs[numFormats][4];
557 const GeoIntegralProperty *lengths;
558 const GeoIntegralProperty *types;
559 const Geometry::MFPropertiesType *prop;
560 const Geometry::MFPropIndicesType *propIdx;
562 const UInt8 *attribData [Geometry::MaxAttribs];
563 UInt32 attribStride[Geometry::MaxAttribs];
564 GeoVectorProperty *attribPtr [Geometry::MaxAttribs];
565 GeoIntegralProperty *attribIndex [Geometry::MaxAttribs];
568 PumpData::PumpData() :
574 for(Int16 i = 0; i < Geometry::MaxAttribs; ++i)
576 attribData [i] = NULL;
578 attribPtr [i] = NULL;
579 attribIndex [i] = NULL;
583 struct PumpAttribInfo : public PumpData
585 explicit PumpAttribInfo(void);
587 attribPumpFunc attribPump[Geometry::MaxAttribs];
591 PumpAttribInfo::PumpAttribInfo(void) :
594 for(Int16 i = 0; i < Geometry::MaxAttribs; ++i)
596 attribPump[i] = NULL;
601 // check mandatory properties
602 bool pumpInternalSetup(const GeoIntegralProperty* prop, bool mandatory)
606 if(mandatory == true && prop == NULL)
616 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
617 #pragma GCC diagnostic pop
620 #endif // remove from all but dev docs