Hi guys,
I’m trying to use glVertexPointer, but nothing is drawn.
I define
typedef struct vertex{
GLdouble x;
GLdouble y;
GLdouble z;

and an array of vertex: vertex *vertexes;
In the display function i write the following code:

glEnableClientState( GL_VERTEX_ARRAY );
glVertexPointer(3, GL_DOUBLE, sizeof(structure::vertex), content->vertexes);
glDrawArrays(GL_POINT, 0, content->nvertex);

but it doesn’t work.

I try also: glVertexPointer(3, GL_DOUBLE, sizeof(structure::vertex), &(content->vertexes[0]));
but nothing is drawn.

Any ideas??
thank you


Try using floats, not doubles. And what are you trying to draw? Also, what about the rest of your GL state, the matrices and so forth? What happens if you draw this with immediate mode commands?

First of all, the plural of vertex is vertices.Not vertexes. :slight_smile:

glVertexPointer(3, GL_DOUBLE, sizeof(structure::vertex), content->vertexes);

Do you know how the third argument of that function, also called stride, works? A stride of sizeof(structure::vertex) in your case means that each group of 3 vertices of size GL_DOUBLE are positioned in memory with a gap of sizeof(structure::vertex). Since you’re interested in a packed (no stride) array, stride has to be 0.


glVertexPointer(3, GL_DOUBLE, 0, content->vertexes);

Hi Alfonse,
if I use floats nothing changes.

I’m trying to draw a point cloud with ~1 mln of points. If I draw with the following command:
for(int i = 0; i < content->nvertex; i++)
glVertex3d(content->vertexes[i].x, content->vertexes[i].y, content->vertexes[i].z);
the point cloud is drawn.
so I think there’s no problem in the GL state.

hi thokra,
I try also

[LEFT]glVertexPointer(3, GL_DOUBLE, 0, content->vertexes);[/LEFT]

but nothing changes.

Do you get any errors?

I find the error.

glDrawArrays(GL_POINT, 0, content->nvertex);

must be

glDrawArrays(GL_POINTS, 0, content->nvertex);

Thanks to all guys, and sorry for the stupid question.

That’s what glGetError is for

Well, 3 people didn’t see that it was GL_POINT and not GL_POINTS. Personally I blame this on the symbols defined in the spec. glPolygonMode should take something like GL_RASTER_POINT or GL_POINT_MODE.