Hiram

05-11-2011, 07:46 AM

Hi guys,

I'm trying to get the following data structure to work with glVertexPointer and subsequently glDrawArrays:

struct Vertex

{

float x, y, z, w, nx, ny, nz, tx, ty;

}

typedef std::vector<Vertex> Face;

typedef std::vector<Face> Mesh;

So if I create a cube object, it's Mesh will have 6 vectors, and those 6 vectors will have 4 Vertex's each.

If I make the following calls, I get a single face the way I'd expect:

glVertexPointer(4, GL_FLOAT, sizeof(Vertex), &mesh[0][0];

glDrawArrays(GL_QUADS, 0, 4);

However subsequent calls to glDrawArrays with different first values don't give me the other faces, instead I get garbage like random polygons to random points in the screen.

I've tried a heap of different values for first, like 1 through to 10, and none of them work. I'm sure the problem is that I don't understand glVertexPointer properly. Any help would be greatly appreciated.

I'm trying to get the following data structure to work with glVertexPointer and subsequently glDrawArrays:

struct Vertex

{

float x, y, z, w, nx, ny, nz, tx, ty;

}

typedef std::vector<Vertex> Face;

typedef std::vector<Face> Mesh;

So if I create a cube object, it's Mesh will have 6 vectors, and those 6 vectors will have 4 Vertex's each.

If I make the following calls, I get a single face the way I'd expect:

glVertexPointer(4, GL_FLOAT, sizeof(Vertex), &mesh[0][0];

glDrawArrays(GL_QUADS, 0, 4);

However subsequent calls to glDrawArrays with different first values don't give me the other faces, instead I get garbage like random polygons to random points in the screen.

I've tried a heap of different values for first, like 1 through to 10, and none of them work. I'm sure the problem is that I don't understand glVertexPointer properly. Any help would be greatly appreciated.