14#ifndef OSG_TRIANGLEINDEXFUNCTOR
15#define OSG_TRIANGLEINDEXFUNCTOR 1
34 virtual void drawArrays(GLenum mode,GLint first,GLsizei count)
40 unsigned int pos=first;
41 for(GLsizei i=2;i<count;i+=3,pos+=3)
43 this->operator()(pos,pos+1,pos+2);
47 case(GL_TRIANGLE_STRIP):
49 unsigned int pos=first;
50 for(GLsizei i=2;i<count;++i,++pos)
52 if ((i%2)) this->operator()(pos,pos+2,pos+1);
53 else this->operator()(pos,pos+1,pos+2);
59 unsigned int pos=first;
60 for(GLsizei i=3;i<count;i+=4,pos+=4)
62 this->operator()(pos,pos+1,pos+2);
63 this->operator()(pos,pos+2,pos+3);
69 unsigned int pos=first;
70 for(GLsizei i=3;i<count;i+=2,pos+=2)
72 this->operator()(pos,pos+1,pos+2);
73 this->operator()(pos+1,pos+3,pos+2);
78 case(GL_TRIANGLE_FAN):
80 unsigned int pos=first+1;
81 for(GLsizei i=2;i<count;++i,++pos)
83 this->operator()(first,pos,pos+1);
97 virtual void drawElements(GLenum mode,GLsizei count,
const GLubyte* indices)
99 if (indices==0 || count==0)
return;
101 typedef GLubyte Index;
102 typedef const Index* IndexPointer;
108 IndexPointer ilast = &indices[count];
109 for(IndexPointer iptr=indices;iptr<ilast;iptr+=3)
110 this->
operator()(*iptr,*(iptr+1),*(iptr+2));
113 case(GL_TRIANGLE_STRIP):
115 IndexPointer iptr = indices;
116 for(GLsizei i=2;i<count;++i,++iptr)
118 if ((i%2)) this->operator()(*(iptr),*(iptr+2),*(iptr+1));
119 else this->operator()(*(iptr),*(iptr+1),*(iptr+2));
125 IndexPointer iptr = indices;
126 for(GLsizei i=3;i<count;i+=4,iptr+=4)
128 this->operator()(*(iptr),*(iptr+1),*(iptr+2));
129 this->operator()(*(iptr),*(iptr+2),*(iptr+3));
135 IndexPointer iptr = indices;
136 for(GLsizei i=3;i<count;i+=2,iptr+=2)
138 this->operator()(*(iptr),*(iptr+1),*(iptr+2));
139 this->operator()(*(iptr+1),*(iptr+3),*(iptr+2));
144 case(GL_TRIANGLE_FAN):
146 IndexPointer iptr = indices;
149 for(GLsizei i=2;i<count;++i,++iptr)
151 this->operator()(first,*(iptr),*(iptr+1));
165 virtual void drawElements(GLenum mode,GLsizei count,
const GLushort* indices)
167 if (indices==0 || count==0)
return;
169 typedef GLushort Index;
170 typedef const Index* IndexPointer;
176 IndexPointer ilast = &indices[count];
177 for(IndexPointer iptr=indices;iptr<ilast;iptr+=3)
178 this->
operator()(*iptr,*(iptr+1),*(iptr+2));
181 case(GL_TRIANGLE_STRIP):
183 IndexPointer iptr = indices;
184 for(GLsizei i=2;i<count;++i,++iptr)
186 if ((i%2)) this->operator()(*(iptr),*(iptr+2),*(iptr+1));
187 else this->operator()(*(iptr),*(iptr+1),*(iptr+2));
193 IndexPointer iptr = indices;
194 for(GLsizei i=3;i<count;i+=4,iptr+=4)
196 this->operator()(*(iptr),*(iptr+1),*(iptr+2));
197 this->operator()(*(iptr),*(iptr+2),*(iptr+3));
203 IndexPointer iptr = indices;
204 for(GLsizei i=3;i<count;i+=2,iptr+=2)
206 this->operator()(*(iptr),*(iptr+1),*(iptr+2));
207 this->operator()(*(iptr+1),*(iptr+3),*(iptr+2));
212 case(GL_TRIANGLE_FAN):
214 IndexPointer iptr = indices;
217 for(GLsizei i=2;i<count;++i,++iptr)
219 this->operator()(first,*(iptr),*(iptr+1));
233 virtual void drawElements(GLenum mode,GLsizei count,
const GLuint* indices)
235 if (indices==0 || count==0)
return;
237 typedef GLuint Index;
238 typedef const Index* IndexPointer;
244 IndexPointer ilast = &indices[count];
245 for(IndexPointer iptr=indices;iptr<ilast;iptr+=3)
246 this->
operator()(*iptr,*(iptr+1),*(iptr+2));
249 case(GL_TRIANGLE_STRIP):
251 IndexPointer iptr = indices;
252 for(GLsizei i=2;i<count;++i,++iptr)
254 if ((i%2)) this->operator()(*(iptr),*(iptr+2),*(iptr+1));
255 else this->operator()(*(iptr),*(iptr+1),*(iptr+2));
261 IndexPointer iptr = indices;
262 for(GLsizei i=3;i<count;i+=4,iptr+=4)
264 this->operator()(*(iptr),*(iptr+1),*(iptr+2));
265 this->operator()(*(iptr),*(iptr+2),*(iptr+3));
271 IndexPointer iptr = indices;
272 for(GLsizei i=3;i<count;i+=2,iptr+=2)
274 this->operator()(*(iptr),*(iptr+1),*(iptr+2));
275 this->operator()(*(iptr+1),*(iptr+3),*(iptr+2));
280 case(GL_TRIANGLE_FAN):
282 IndexPointer iptr = indices;
285 for(GLsizei i=2;i<count;++i,++iptr)
287 this->operator()(first,*(iptr),*(iptr+1));
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Vec2f Vec2
Definition Vec2:21
Vec3f Vec3
Definition Vec3:21
Vec4f Vec4
Definition Vec4:21
Definition PrimitiveSet:103
Definition TriangleIndexFunctor:24
virtual void setVertexArray(unsigned int, const Vec3 *)
Definition TriangleIndexFunctor:28
virtual void drawElements(GLenum mode, GLsizei count, const GLuint *indices)
Definition TriangleIndexFunctor:233
virtual void drawElements(GLenum mode, GLsizei count, const GLubyte *indices)
Definition TriangleIndexFunctor:97
virtual void drawElements(GLenum mode, GLsizei count, const GLushort *indices)
Definition TriangleIndexFunctor:165
virtual void setVertexArray(unsigned int, const Vec2d *)
Definition TriangleIndexFunctor:30
virtual void setVertexArray(unsigned int, const Vec3d *)
Definition TriangleIndexFunctor:31
virtual void setVertexArray(unsigned int, const Vec4 *)
Definition TriangleIndexFunctor:29
virtual void setVertexArray(unsigned int, const Vec4d *)
Definition TriangleIndexFunctor:32
virtual void setVertexArray(unsigned int, const Vec2 *)
Definition TriangleIndexFunctor:27
virtual void drawArrays(GLenum mode, GLint first, GLsizei count)
Definition TriangleIndexFunctor:34
General purpose double pair, uses include representation of texture coordinates.
Definition Vec2d:29
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
General purpose double quad.
Definition Vec4d:29