I’ve defined a small structure to hold model data for my OpenGL project. However, for some reason, the result isn’t quite what I expect. I don’t know if I’m reading the spec wrong or what.
Here’s what I’m doing:
I have defined an array of floats as:
MapData = (float*)new float[4 * cx * cy];
MapData[i + 0] has the X coordinate of a vertex
MapData[i + 1] has the Y
MapData[i + 2] has the Z
MapData[i + 3] is set to 1.0f
Then in the rendering path I have:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);glVertexPointer(3, GL_FLOAT, 4, tMap.GetData());
glColorPointer(4, GL_UNSIGNED_BYTE, 0, tMap.colorptr);
glDrawArrays(GL_POINTS, 0, tMap.GetXSize() * tMap.GetYSize());glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
I’ve tried a stride of 16, and things look a bit better, but it looks like every other row of points is missing. Am I not using stride correctly? What am I missing here?
It may possibly be the generation code, but when I define the array with a 3 * cx * cy, and specify a 0 stride, everything works properly.
Help?
Thanks,
Siwko