Results 1 to 4 of 4

Thread: How do I use glVertexPointer?

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2002
    Location
    Västerås, Sweden
    Posts
    12

    How do I use glVertexPointer?

    How do I use glVertexPointer?

  2. #2
    Member Contributor
    Join Date
    Nov 2002
    Posts
    96

    Re: How do I use glVertexPointer?

    The vertex pointer will have to point to your home made vertex array. This array can be a 2D array (x elements long, 3 elements wide) to contain the vertices. Next you tell OpenGL to use that specific array, and then you draw the array.
    Important is that you enable the right clientstates first.
    You'll also need an INDEX ARRAY. This array will contain the order in which the indexes of the vertex array are given to the card. I haven't figured out a way NOT to use this though, so I keep on defining an Index array every time.

    Example code:
    Code :
    glEnableClientState(GL_VERTEX_ARRAY);   //enable vertex array
    glEnableClientState(GL_NORMAL_ARRAY);   //enable normal array
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);  //enable texcoord array
     
     
    glVertexPointer(	3,	GL_FLOAT,	0,	&vertexA[start]);  //give vertex array to OGL
    glTexCoordPointer(	2,	GL_FLOAT,	0,	&texcoordA[start]);   //same with texcoord array
    glNormalPointer(		GL_FLOAT,	0,	&normalA[start]);  //and normal array
     
    glDrawElements(	GL_QUADS,	len,	GL_UNSIGNED_INT,	indexA);   //draw the whole set in one go
     
    glDisableClientState(GL_VERTEX_ARRAY);   //disable the client states again
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    I use this as reference when I tried to figure out how to use the vertex array: http://www.3dlabs.com/support/developer/GLmanpages/

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2002
    Location
    Västerås, Sweden
    Posts
    12

    Re: How do I use glVertexPointer?

    Is this faster than just traversing the array by your self and using glVertex?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: How do I use glVertexPointer?

    Depending on what you do, it can be anywherefrom a little to a lot faster.

Similar Threads

  1. Glvertexpointer Buffer
    By Crownable in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-30-2012, 06:08 AM
  2. GlVertexPointer
    By Crownable in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-22-2012, 08:03 AM
  3. glVertexPointer
    By trackin in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 05-30-2012, 06:36 AM
  4. VBO->glVertexPointer()
    By dletozeun in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-14-2006, 05:20 AM
  5. glVertexPointer and stl...
    By imported_robert in forum OpenGL: Advanced Coding
    Replies: 16
    Last Post: 07-19-2002, 07:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean