Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: glVertexPointer

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    22

    glVertexPointer

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

    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);
    glDisableClientState(GL_VERTEX_ARRAY);

    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

    G.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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?

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    First of all, the plural of vertex is vertices.Not vertexes.

    Code :
    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.

    Try

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

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    22
    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:
    glBegin(GL_POINTS);
    for(int i = 0; i < content->nvertex; i++)
    glVertex3d(content->vertexes[i].x, content->vertexes[i].y, content->vertexes[i].z);
    glEnd();
    the point cloud is drawn.
    so I think there's no problem in the GL state.

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    22
    hi thokra,
    I try also

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

    but nothing changes.

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    Do you get any errors?

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    22
    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.


  8. #8
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •