13 #ifndef TRIANGLE_LINE_POINT_INDEX_FUNCTOR
14 #define TRIANGLE_LINE_POINT_INDEX_FUNCTOR
16 #include <osg/PrimitiveSet>
42 virtual void begin(GLenum mode) {
47 virtual void vertex(
unsigned int vert) {
57 virtual void drawArrays(GLenum mode, GLint first, GLsizei count) {
62 unsigned int pos=first;
63 for(GLsizei i = 2 ; i < count ; i += 3, pos += 3) {
64 this->operator()(pos, pos + 1, pos + 2);
68 case(GL_TRIANGLE_STRIP):
70 unsigned int pos = first;
71 for(GLsizei i = 2 ; i < count ; ++ i, ++ pos) {
72 if ((i%2)) this->operator()(pos, pos + 2, pos + 1);
73 else this->operator()(pos, pos + 1, pos + 2);
79 unsigned int pos = first;
80 for(GLsizei i = 3 ; i < count ; i += 4, pos += 4) {
81 this->operator()(pos,pos + 1, pos + 2);
82 this->operator()(pos,pos + 2, pos + 3);
88 unsigned int pos = first;
89 for(GLsizei i = 3 ; i < count ; i += 2, pos += 2) {
90 this->operator()(pos, pos + 1,pos + 2);
91 this->operator()(pos + 1,pos + 3,pos + 2);
96 case(GL_TRIANGLE_FAN):
98 unsigned int pos = first + 1;
99 for(GLsizei i = 2 ; i < count ; ++ i, ++ pos) {
100 this->operator()(first, pos, pos + 1);
106 unsigned int pos = first;
107 for(GLsizei i = 0 ; i < count ; i += 2, pos += 2) {
108 this->operator()(pos, pos + 1);
114 unsigned int pos = first;
115 for(GLsizei i = 0 ; i < count - 1 ; i += 1, pos += 1) {
116 this->operator()(pos, pos + 1);
122 unsigned int pos = first;
123 for(GLsizei i = 0 ; i < count - 1 ; i += 1, pos += 1) {
124 this->operator()(pos, pos + 1);
126 this->operator()(pos, first);
131 unsigned int pos=first;
132 for(GLsizei i = 0 ; i < count ; ++ i) {
133 this->operator()(pos + i);
146 typedef const I* IndexPointer;
148 if (indices == 0 || count == 0) {
156 IndexPointer ilast = &indices[count];
157 for(IndexPointer iptr = indices ; iptr < ilast ; iptr += 3) {
158 this->operator()(*iptr, *(iptr + 1), *(iptr + 2));
162 case(GL_TRIANGLE_STRIP):
164 IndexPointer iptr = indices;
165 for(GLsizei i = 2 ; i < count ; ++ i, ++ iptr) {
166 if ((i%2)) this->operator()(*(iptr), *(iptr + 2), *(iptr + 1));
167 else this->operator()(*(iptr), *(iptr + 1), *(iptr + 2));
173 IndexPointer iptr = indices;
174 for(GLsizei i = 3 ; i < count ; i += 4, iptr += 4) {
175 this->operator()(*(iptr), *(iptr + 1), *(iptr + 2));
176 this->operator()(*(iptr), *(iptr + 2), *(iptr + 3));
182 IndexPointer iptr = indices;
183 for(GLsizei i = 3 ; i < count ; i += 2, iptr += 2) {
184 this->operator()(*(iptr), *(iptr + 1), *(iptr + 2));
185 this->operator()(*(iptr + 1), *(iptr + 3), *(iptr + 2));
190 case(GL_TRIANGLE_FAN):
192 IndexPointer iptr = indices;
195 for(GLsizei i = 2 ; i < count ; ++ i, ++ iptr) {
196 this->operator()(first, *(iptr), *(iptr + 1));
202 const I* iptr = indices;
203 for(GLsizei i = 0 ; i < count ; i += 2, iptr += 2) {
204 this->operator()(*iptr, *(iptr + 1));
210 const I* iptr = indices;
211 for(GLsizei i = 0 ; i < count - 1 ; i += 1, iptr += 1) {
212 this->operator()(*iptr, *(iptr + 1));
218 const I* iptr = indices;
220 for(GLsizei i = 0 ; i < count - 1 ; i += 1, iptr += 1) {
221 this->operator()(*iptr, *(iptr + 1));
223 this->operator()(*iptr, first);
228 IndexPointer ilast = &indices[count];
229 for(IndexPointer iptr = indices ; iptr < ilast ; iptr += 1) {
230 this->operator()(*iptr);
239 virtual void drawElements(GLenum mode, GLsizei count,
const GLubyte* indices) {
240 drawElements<GLubyte>(mode, count, indices);
243 virtual void drawElements(GLenum mode,GLsizei count,
const GLushort* indices) {
244 drawElements<GLushort>(mode, count, indices);
247 virtual void drawElements(GLenum mode,GLsizei count,
const GLuint* indices) {
248 drawElements<GLuint>(mode, count, indices);
virtual void setVertexArray(unsigned int, const osg::Vec2d *)
virtual void setVertexArray(unsigned int, const osg::Vec3 *)
virtual void vertex(unsigned int vert)
virtual void drawElements(GLenum mode, GLsizei count, const GLushort *indices)
void drawElements(GLenum mode, GLsizei count, const I *indices)
std::vector< unsigned int > _remap
std::vector< GLuint > _indexCache
virtual void setVertexArray(unsigned int, const osg::Vec2 *)
virtual void drawElements(GLenum mode, GLsizei count, const GLubyte *indices)
virtual void drawElements(GLenum mode, GLsizei count, const GLuint *indices)
virtual void setVertexArray(unsigned int, const osg::Vec4d *)
virtual void begin(GLenum mode)
virtual void drawArrays(GLenum mode, GLint first, GLsizei count)
virtual void setVertexArray(unsigned int, const osg::Vec4 *)
virtual void setVertexArray(unsigned int, const osg::Vec3d *)