ok, i've had a mild brain fart and cant work something out, so if someone could point me in the right direction on how to do what I need todo I'll be greatfull :)
Basically, I've got aload of vertex data in a VBO (consiting of location and colour data), so i need to render by setting the pointers, which is easy enuff and works fine if I do it this way :
struct terraindata {
float x,y,z;
GLubyte r,g,b,a; // use four bytes so we dont botch the alignment up
};
glVertexPointer(3, GL_FLOAT, sizeof(terraindata), BUFFER_OFFSET(0));
glColorPointer(4,GL_UNSIGNED_BYTE,sizeof(terraindata),BUFFER_OFFSET(12)); // offset of 12 to skip first 3 floats (4 bytes each)
Which is all well and good but not very... gracefull, as if I monkey around with order (which I probably will do) or add things I've goto work out the magic numbers again... yey.
Now, with normal VA you can do this :
glVertexPointer(3, GL_FLOAT, sizeof(terraindata), &vElements[0].x);
glColorPointer(4, GL_FLOAT, sizeof(terraindata), &vElements[0].r);
and ofcourse all your addresses will be worked out nicely, but with VBOs they are from an offset of 0, not a real address.
so, anyone got any ideas as to how I could simulate this?
hmmm infact typing this post out has given me an idea, I could take the address of the first element, subtract it from the address of the 'r' member and that should give me my offset.. anyone see any huge holes in that plan?
I'm falling into bed in a few mins, so I'll probably get on it tomorrow, so if anyone has any ideas in the meantime, or even just to say i'm not going crazy with my idea, then I'd appricate it [smile]