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 3 of 3

Thread: compiled vertex arrays & glDrawElements

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2000
    Posts
    8

    compiled vertex arrays & glDrawElements

    hi there!
    im trying to get my heightmap to be rendered with vertex arrays, using glDrawElements..
    well my problem is that everything is ok, except the terrain doesnt show up with i do this code..
    well im new to this here, so i dunno what can be wrong...

    VertexArray is an array of floats: [Landscape.mapWidth * Landscape.mapHeight * 3];
    IndexArray is an array of unsigned ints: [Landscape.mapWidth * Landscape.mapHeight * 3 * 2];
    (this holds the indices of the 2 triangles that makes each tile in the terrain)

    well anyone have any idea? i've seen some code around on this, but didnt help much..
    this might have sum stupid code, but well im trying this without any info.. cant find any that tells me what these funcs really do


    glEnableClientState(GL_VERTEX_ARRAY);

    glLockArraysEXT(0, Landscape.mapWidth * Landscape.mapHeight * 2); // lock vertex arrays

    glDisable(GL_CULL_FACE);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_LIGHTING);
    glDisable(GL_FOG);
    glColor4f(1,1,1,1);
    glVertexPointer(3, GL_FLOAT, 0, Landscape.VertexArray);
    glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, Landscape.IndexArray);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_CULL_FACE);
    glEnable(GL_LIGHTING);
    glEnable(GL_FOG);

    glUnlockArraysEXT(); // unlock vertex arrays

    glDisableClientState(GL_VERTEX_ARRAY);

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: compiled vertex arrays & glDrawElements

    first get it working without locked arrays (btw locking them will prolly give no speed increase)

    glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, Landscape.IndexArray);

    here youre only drawing 4 elements i assume u want to draw much more then that

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,757

    Re: compiled vertex arrays & glDrawElements

    Also when using compiled vertex arrays, you generally set the vertex pointer before locking the arrays. And uh yep, I doubt in this circumstance you'll get much of any benefit using compiled vertex arrays. You'd likely only see significant benefits if you were drawing very many elements and were using multipass texturing.

Posting Permissions

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