> You're not forced to use glInterleavedArrays.
>
> #include <stdint.h>
> typedef uint32_t colorRGBA;
> typedef struct Vector3d { GLfloat x,y,z; } Vector3d;
> typedev struct Vector2d { GLfloat u,v; } Vector2d;
> typedef struct Vertex
> {
> Vector2d texcoord;
> colorRGBA color;
> Vector3d normal;
> Vector3d coord;
> } Vertex;
>
> void setVAPointer(Vertex *V)
> {
> glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &(V->coord));
> glNormalPointer(GL_FLOAT, sizeof(Vertex), &(V->normal));
> glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex),
> &(V->colorRGBA));
> glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &(V->texcoord));
> }
This is exactly what I am currently doing, but using Draw Arrays, not
draw elements. I'll switch my code up to use DrawElements, to try and
take advantage of vertext caching.
>
> In fact in most implementations glInterleavedArrays is just a
> shorthand for a arrangement of these calls.
>
> Wolfgang Draxinger
>
> P.S.: Note, that it's impossible in pure C/C++ without extensions
> to exactly define the memory layout of structs. Thank good most
> compilers provide pragmas/extensions to do this. Given this fact
>
Can't this be acomplished with an __aligned__ tag in gcc? I think there
is a 'pack' pragma with visual C++, iirc.
Thanks for the insight,
~S


|