14#ifndef OSG_TERMPLATEPRIMITIVEFUNCTOR
15#define OSG_TERMPLATEPRIMITIVEFUNCTOR 1
55 notify(
WARN)<<
"Triangle Functor does not support Vec2* vertex arrays"<<std::endl;
66 notify(
WARN)<<
"Triangle Functor does not support Vec4* vertex arrays"<<std::endl;
71 notify(
WARN)<<
"Triangle Functor does not support Vec2d* vertex arrays"<<std::endl;
76 notify(
WARN)<<
"Triangle Functor does not support Vec3d* vertex arrays"<<std::endl;
81 notify(
WARN)<<
"Triangle Functor does not support Vec4d* vertex arrays"<<std::endl;
85 virtual void drawArrays(GLenum mode,GLint first,GLsizei count)
94 this->
operator()(*(vptr),*(vptr+1),*(vptr+2),
false);
97 case(GL_TRIANGLE_STRIP): {
99 for(GLsizei i=2;i<count;++i,++vptr)
101 if ((i%2)) this->
operator()(*(vptr),*(vptr+2),*(vptr+1),
false);
102 else this->operator()(*(vptr),*(vptr+1),*(vptr+2),
false);
108 for(GLsizei i=3;i<count;i+=4,vptr+=4)
110 this->operator()(*(vptr),*(vptr+1),*(vptr+2),*(vptr+3),
false);
114 case(GL_QUAD_STRIP): {
116 for(GLsizei i=3;i<count;i+=2,vptr+=2)
118 this->operator()(*(vptr),*(vptr+1),*(vptr+3),*(vptr+2),
false);
123 case(GL_TRIANGLE_FAN): {
125 const Vec3* vptr = vfirst+1;
126 for(GLsizei i=2;i<count;++i,++vptr)
128 this->operator()(*(vfirst),*(vptr),*(vptr+1),
false);
135 this->
operator()(*(vptr),
false);
141 this->
operator()(*(vptr),*(vptr+1),
false);
144 case(GL_LINE_STRIP): {
147 this->
operator()(*(vptr),*(vptr+1),
false);
153 this->
operator()(*(vptr),*(vptr+1),
false);
156 case(GL_LINE_LOOP): {
159 this->
operator()(*(vptr),*(vptr+1),
false);
168 template<
class IndexType>
171 if (indices==0 || count==0)
return;
173 typedef const IndexType* IndexPointer;
177 case(GL_TRIANGLES): {
178 IndexPointer ilast = &indices[count];
179 for(IndexPointer iptr=indices;iptr<ilast;iptr+=3)
183 case(GL_TRIANGLE_STRIP): {
184 IndexPointer iptr = indices;
185 for(GLsizei i=2;i<count;++i,++iptr)
195 IndexPointer iptr = indices;
196 for(GLsizei i=3;i<count;i+=4,iptr+=4)
204 case(GL_QUAD_STRIP): {
205 IndexPointer iptr = indices;
206 for(GLsizei i=3;i<count;i+=2,iptr+=2)
215 case(GL_TRIANGLE_FAN): {
216 IndexPointer iptr = indices;
219 for(GLsizei i=2;i<count;++i,++iptr)
227 IndexPointer ilast = &indices[count];
228 for(IndexPointer iptr=indices;iptr<ilast;iptr+=1)
233 IndexPointer ilast = &indices[count-1];
234 for(IndexPointer iptr=indices;iptr<ilast;iptr+=2)
239 case(GL_LINE_STRIP): {
240 IndexPointer ilast = &indices[count-1];
241 for(IndexPointer iptr=indices;iptr<ilast;iptr+=1)
247 IndexPointer ilast = &indices[count-2];
248 for(IndexPointer iptr=&indices[1];iptr<ilast;iptr+=1)
253 case(GL_LINE_LOOP): {
254 IndexPointer ilast = &indices[count-1];
255 for(IndexPointer iptr=indices;iptr<ilast;iptr+=1)
268 virtual void drawElements(GLenum mode,GLsizei count,
const GLubyte* indices)
273 virtual void drawElements(GLenum mode,GLsizei count,
const GLushort* indices)
278 virtual void drawElements(GLenum mode,GLsizei count,
const GLuint* indices)
#define GL_LINE_STRIP_ADJACENCY
Definition GLDefines:209
Definition PrimitiveSet:54
Definition TemplatePrimitiveFunctor:42
virtual void setVertexArray(unsigned int, const Vec2d *)
Definition TemplatePrimitiveFunctor:69
virtual void drawElements(GLenum mode, GLsizei count, const GLuint *indices)
Mimics the OpenGL glDrawElements() function.
Definition TemplatePrimitiveFunctor:278
virtual void drawElements(GLenum mode, GLsizei count, const GLubyte *indices)
Mimics the OpenGL glDrawElements() function.
Definition TemplatePrimitiveFunctor:268
virtual void setVertexArray(unsigned int, const Vec3d *)
Definition TemplatePrimitiveFunctor:74
virtual void setVertexArray(unsigned int, const Vec4d *)
Definition TemplatePrimitiveFunctor:79
virtual void setVertexArray(unsigned int count, const Vec3 *vertices)
Definition TemplatePrimitiveFunctor:58
void drawElementsTemplate(GLenum mode, GLsizei count, const IndexType *indices)
Definition TemplatePrimitiveFunctor:169
virtual void drawElements(GLenum mode, GLsizei count, const GLushort *indices)
Mimics the OpenGL glDrawElements() function.
Definition TemplatePrimitiveFunctor:273
virtual void setVertexArray(unsigned int, const Vec4 *)
Definition TemplatePrimitiveFunctor:64
virtual void drawArrays(GLenum mode, GLint first, GLsizei count)
Mimics the OpenGL glDrawArrays() function.
Definition TemplatePrimitiveFunctor:85
virtual ~TemplatePrimitiveFunctor()
Definition TemplatePrimitiveFunctor:51
unsigned int _vertexArraySize
Definition TemplatePrimitiveFunctor:285
virtual void setVertexArray(unsigned int, const Vec2 *)
Definition TemplatePrimitiveFunctor:53
const Vec3 * _vertexArrayPtr
Definition TemplatePrimitiveFunctor:286
TemplatePrimitiveFunctor()
Definition TemplatePrimitiveFunctor:45
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
@ WARN
Definition Notify:33
std::ostream & notify(void)
Definition Notify:80