/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #ifndef OSG_TRIANGLINDEXEFUNCTOR #define OSG_TRIANGLINDEXEFUNCTOR 1 #include #include namespace osg { template class TriangleIndexFunctor : public Drawable::PrimitiveIndexFunctor, public T { public: virtual void setVertexArray(unsigned int,const Vec2*) { } virtual void setVertexArray(unsigned int ,const Vec3* ) { } virtual void setVertexArray(unsigned int,const Vec4* ) { } virtual void begin(GLenum mode) { _modeCache = mode; _indexCache.clear(); } virtual void vertex(unsigned int vert) { _indexCache.push_back(vert); } virtual void end() { if (!_indexCache.empty()) { drawArrays(_modeCache,0,_indexCache.size()); } } virtual void drawArrays(GLenum mode,GLint first,GLsizei count) { switch(mode) { case(GL_TRIANGLES): { unsigned int pos=first; for(GLsizei i=2;i _indexCache; }; } #endif