- const float *base=vbuf?0:&data[0];
- uint offset=0;
- uint found=0;
- for(uint fmt=format; fmt; fmt>>=4)
- {
- uint size=(fmt&3)+1;
- switch(fmt&12)
- {
- case 0:
- glVertexPointer(size, GL_FLOAT, stride, base+offset);
- break;
- case 4:
- glNormalPointer(GL_FLOAT, stride, base+offset);
- break;
- case 8:
- glTexCoordPointer(size, GL_FLOAT, stride, base+offset);
- break;
- case 12:
- if(size==1)
- glColorPointer(4, GL_UNSIGNED_BYTE, stride, base+offset);
- else
- glColorPointer(size, GL_FLOAT, stride, base+offset);
- break;
- }
- found|=1<<((fmt&12)>>2);
- offset+=size;
- }
+VertexArray::Loader::Loader(VertexArray &a):
+ VertexArrayBuilder(a)
+{
+ add("vertex2", static_cast<void (Loader::*)(float, float)>(&Loader::vertex));
+ add("vertex3", static_cast<void (Loader::*)(float, float, float)>(&Loader::vertex));
+ add("vertex4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::vertex));
+ add("normal3", static_cast<void (Loader::*)(float, float, float)>(&Loader::normal));
+ add("texcoord1", static_cast<void (Loader::*)(float)>(&Loader::texcoord));
+ add("texcoord2", static_cast<void (Loader::*)(float, float)>(&Loader::texcoord));
+ add("texcoord3", static_cast<void (Loader::*)(float, float, float)>(&Loader::texcoord));
+ add("texcoord4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::texcoord));
+ add("multitexcoord1", static_cast<void (Loader::*)(unsigned, float)>(&Loader::multitexcoord));
+ add("multitexcoord2", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::multitexcoord));
+ add("multitexcoord3", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::multitexcoord));
+ add("multitexcoord4", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::multitexcoord));
+ add("color3", static_cast<void (Loader::*)(float, float, float)>(&Loader::color));
+ add("color4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::color));
+ add("attrib1", static_cast<void (Loader::*)(unsigned, float)>(&Loader::attrib));
+ add("attrib2", static_cast<void (Loader::*)(unsigned, float, float)>(&Loader::attrib));
+ add("attrib3", static_cast<void (Loader::*)(unsigned, float, float, float)>(&Loader::attrib));
+ add("attrib4", static_cast<void (Loader::*)(unsigned, float, float, float, float)>(&Loader::attrib));
+}