sheam wrote:
> So I guess, my best bet would be interleaved arrays.=20
> Unfortunately, in order to use interleaved arrays, it looks
> like I will have to strip out
> color, as there is no T2F_C4UB_N3F_V3F. Which seems like kind
> of an odd
> omission to me. I know of atleast two consoles which pack this
> way.
> Yet I don't know of one that does T2F_C4F_N3F_V3F. Oh, well, I
> don't actually need color in most instances, so I will just
> make a vertex variant without it, and use T2F_N3F_V3F.
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
{
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Vector2d texcoord;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0colorRGBA color;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Vector3d normal;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Vector3d 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));=
}
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
I'm rather surprised, that there are almost no bugs due to this.
I'm thinking about using pointers to structs in ABIs. E.g. a lot
of stuff in Linux depends on structs passed around. But almost
none of the system include files explicitly define the memory
layout using pragmas, or compiler extensions.
After years of programming I came to realize this only lately,
when working on the compiler for the programming language I
designed. There are so many things we take for granted, until we
dig deep into the inner structure of things...
So the above code will probably work in 99.9%, but there might be
situations where it won't.
--=20
E-Mail address works, Jabber: hexarith@[EMAIL PROTECTED]
ICQ: 134682867


|