/**************************************************************************\ * * 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: remove this, not used.. int mbind, // --"-- int doTextures, // --"-- int32_t idx, const int32_t *ptr, const int32_t *end, SbBool needNormals) { // Make sure specified coordinate startindex is valid assert(idx >= 0); const SbVec3f * coords3d = NULL; const SbVec4f * coords4d = NULL; const SbBool is3d = coords->is3D(); if (is3d) { coords3d = coords->getArrayPtr3(); } else { coords4d = coords->getArrayPtr4(); } int numcoords = coords->getNum(); // This is the same code as in SoGLCoordinateElement::send(). // It is inlined here for speed (~15% speed increase). #define SEND_VERTEX(_idx_) \ if (is3d) glVertex3fv((const GLfloat*) (coords3d + _idx_)); \ else glVertex4fv((const GLfloat*) (coords4d + _idx_)); int matnr = 0; int texnr = 0; int mode = GL_POLYGON; int newmode; 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++; if (n < 3 || idx + n > numcoords) { static uint32_t current_errors = 0; if (current_errors < 1) { SoDebugError::postWarning("[nonindexedfaceset]::GLRender", "Erroneous " "number of coordinates specified: %d. Must " "be >= 3 and less than or equal to the number of " "coordinates available (which is: %d). Aborting " "rendering. This message will be shown only once, " "but more errors might be present", n, numcoords - idx); } current_errors++; break; } if (n == 3) newmode = GL_TRIANGLES; else if (n == 4) newmode = GL_QUADS; else newmode = GL_POLYGON; if (newmode != mode) { if (mode != GL_POLYGON) glEnd(); mode = newmode; glBegin((GLenum) mode); } else if (mode == GL_POLYGON) glBegin(GL_POLYGON); #if NBINDING!=OVERALL currnormal = normals++; glNormal3fv((const GLfloat *)currnormal); #endif #if MBINDING!=OVERALL mb->send(matnr++, TRUE); #endif #if TEXTURES==TRUE tb->send(texnr++, coords->get3(idx), *currnormal); #endif SEND_VERTEX(idx); idx++; while (--n) { #if NBINDING==PER_VERTEX currnormal = normals++; glNormal3fv((const GLfloat *)currnormal); #endif #if MBINDING==PER_VERTEX mb->send(matnr++, TRUE); #elif MBINDING!=OVERALL // only needed for nvidia color-per-face bug workaround mb->send(matnr-1, TRUE); #endif #if TEXTURES==TRUE tb->send(texnr++, coords->get3(idx), *currnormal); #endif SEND_VERTEX(idx); idx++; } if (mode == GL_POLYGON) glEnd(); } if (mode != GL_POLYGON) glEnd(); }