View Full Version : glVertexPointer

05-30-2012, 01:21 AM
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


Alfonse Reinheart
05-30-2012, 02:22 AM
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?

05-30-2012, 02:24 AM
First of all, the plural of vertex is vertices.Not vertexes. :)

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);

05-30-2012, 02:30 AM
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.

05-30-2012, 02:34 AM
hi thokra,
I try also

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

but nothing changes.

05-30-2012, 02:43 AM
Do you get any errors?

05-30-2012, 02:52 AM
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.

05-30-2012, 04:32 AM
That's what glGetError is for

05-30-2012, 05:36 AM
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.