/**************************************************************************\ * * 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, int mbind, int doTextures, int32_t idx, const int32_t *ptr, const int32_t *end, SbBool needNormals, SbBool drawPoints) { 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). #define SEND_VERTEX(_idx_) \ if (is3d) glVertex3fv((const GLfloat*) (coords3d + _idx_)); \ else glVertex4fv((const GLfloat*) (coords4d + _idx_)); 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 int matnr = 0; int texnr = 0; #if NBINDING==PER_SEGMENT || MBINDING==PER_SEGMENT if (drawPoints) glBegin(GL_POINTS); else glBegin(GL_LINES); while (ptr < end) { int n = *ptr++; if (n < 2) { idx += n; continue; } #if MBINDING==PER_LINE || MBINDING==PER_VERTEX mb->send(matnr++, TRUE); #endif #if NBINDING==PER_LINE || NBINDING==PER_VERTEX currnormal = normals++; glNormal3fv((const GLfloat*)currnormal); #endif #if TEXTURES==TRUE tb->send(texnr++, coords->get3(idx), *currnormal); #endif while (--n) { #if MBINDING==PER_SEGMENT mb->send(matnr++, TRUE); #endif #if NBINDING==PER_SEGMENT currnormal = normals++; glNormal3fv((const GLfloat*)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 #if TEXTURES==TRUE tb->send(texnr++, coords->get3(idx), *currnormal); #endif SEND_VERTEX(idx); } idx++; } glEnd(); #else // NBINDING==PER_SEGMENT || MBINDING==PER_SEGMENT if (drawPoints) glBegin(GL_POINTS); while (ptr < end) { int n = *ptr++; if (n < 2) { idx += n; // FIXME: is this correct? continue; } n -= 2; if (!drawPoints) glBegin(GL_LINE_STRIP); #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++; do { #if NBINDING==PER_VERTEX currnormal = normals++; glNormal3fv((const GLfloat *)currnormal); #endif #if MBINDING==PER_VERTEX mb->send(matnr++, TRUE); #endif #if TEXTURES==TRUE tb->send(texnr++, coords->get3(idx), *currnormal); #endif SEND_VERTEX(idx); idx++; } while (n--); if (!drawPoints) glEnd(); } #endif // NBINDING==PER_SEGMENT || MBINDING==PER_SEGMENT if (drawPoints) glEnd(); } #undef SEND_VERTEX