/**************************************************************************\ * * This file is part of the Coin 3D visualization library. * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.GPL at the root directory of this source * distribution for additional information about the GNU GPL. * * For using Coin with software that can not be combined with the GNU * GPL, and for taking advantage of the additional benefits of our * support services, please contact Systems in Motion about acquiring * a Coin Professional Edition License. * * See http://www.coin3d.org/ for more information. * * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. * http://www.sim.no/ sales@sim.no coin-support@coin3d.org * \**************************************************************************/ ( const SoGLCoordinateElement * coords, const SbVec3f *normals, SoMaterialBundle * mb, const SoTextureCoordinateBundle * tb, int nbind, // skei FIXME: might be removed, not used... ? int mbind, // --"-- int doTextures, // --"-- int32_t idx, const int32_t *ptr, const int32_t *end, SbBool needNormals) { const SbVec3f * coords3d = NULL; const SbVec4f * coords4d = NULL; const SbBool is3d = coords->is3D(); if (is3d) { coords3d = coords->getArrayPtr3(); } else { coords4d = coords->getArrayPtr4(); } // This is the same code as in SoGLCoordinateElement::send(). // It is inlined here for speed (~15% speed increase). #undef SEND_VERTEX #define SEND_VERTEX(_idx_) \ if (is3d) glVertex3fv((const GLfloat*) (coords3d + _idx_)); \ else glVertex4fv((const GLfloat*) (coords4d + _idx_)); int matnr = 0; int texnr = 0; int n; SbVec3f dummynormal(0.0f, 0.0f, 1.0f); const SbVec3f * currnormal = &dummynormal; if (normals) currnormal = normals; #if NBINDING==OVERALL if (needNormals) glNormal3fv((const GLfloat *)currnormal); #endif while (ptr < end) { n = *ptr++ - 2; assert(n > 0); glBegin(GL_TRIANGLE_STRIP); #if NBINDING==PER_VERTEX || NBINDING==PER_STRIP currnormal = normals++; glNormal3fv((const GLfloat *)currnormal); #endif #if MBINDING==PER_STRIP || MBINDING==PER_VERTEX mb->send(matnr++, TRUE); #endif // workaround for nvidia color-per-face-bug #if MBINDING==PER_FACE mb->send(matnr, TRUE); #endif // end of nvidia workaround #if TEXTURES==TRUE tb->send(texnr++, coords->get3(idx), *currnormal); #endif SEND_VERTEX(idx); idx++; #if NBINDING==PER_VERTEX currnormal = normals++; glNormal3fv((const GLfloat *)currnormal); #endif #if MBINDING==PER_VERTEX mb->send(matnr++, TRUE); #endif // workaround for nvidia color-per-face-bug #if MBINDING==PER_FACE mb->send(matnr, TRUE); #elif MBINDING==PER_STRIP mb->send(matnr-1, TRUE); #endif // end of nvidia workaround #if TEXTURES==TRUE tb->send(texnr++, coords->get3(idx), *currnormal); #endif SEND_VERTEX(idx); idx++; while (n--) { #if NBINDING==PER_FACE || NBINDING==PER_VERTEX currnormal = normals++; glNormal3fv((const GLfloat *)currnormal); #endif #if MBINDING==PER_FACE || MBINDING==PER_VERTEX mb->send(matnr++, TRUE); #endif // workaround for nvidia color-per-face-bug #if MBINDING==PER_STRIP mb->send(matnr-1, TRUE); #endif // end of nvidia workaround #if TEXTURES==TRUE tb->send(texnr++, coords->get3(idx), *currnormal); #endif SEND_VERTEX(idx); idx++; } glEnd(); } } #undef SEND_VERTEX