Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: passing Vertex +Face list to opengl

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    235

    passing Vertex +Face list to opengl

    I have a Vertex List(consisting of x,y,z values for every Vertex) and a Face List(consisting of A,B C,specifieing 3 Vertices from Vertex List).Now the pseudo code for my pogram to Draw these Faces looks like this:
    glBegin(GL_TRIANGLES);

    for(i=0;i<=Number of faces;i++ {
    glVertex3f(coords of A from Face[i]);
    glVertex3f(coords of B from Face[i]);
    glVertex3f(coords of C from Face[i]);
    }
    I there another,faster possibility to send such a Face List to OpenGl,than using this "not very smart" loop?
    Perhaps there is a Function like glFaceList() or something like this?

  2. #2

    Re: passing Vertex +Face list to opengl

    I think you should use vertex arrays. Try looking info on glVertexPointer, glArrayElement.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    235

    Re: passing Vertex +Face list to opengl

    Thanks Hude!
    Abother question: can I expect better performance if I change to VertexArrays?

    What perormance to expect if the scene consists of 500 Triangles one Texture without lightmap?(no matter how it is programmed).

    My program runs with about 100FPS on a p2 450
    +TNT 1.(640*480*32).
    I donīt know if this is a good result.
    Any suggestions would be nice.

  4. #4

    Re: passing Vertex +Face list to opengl

    Abother question: can I expect better performance if I change to VertexArrays?
    Using vertex arrays saves a lot of OpenGL function calls. With just a few triangles you won't notice it, but with a larger amount you'll get remarkable better performance.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    235

    Re: passing Vertex +Face list to opengl

    Strange thing:
    After I had changed to VertexArrays,my program ran with 5 FPS lower
    than with my old code.
    For this benchmark I used a scene consisting of 8000 Triangles.
    With my old code I got 25FPS and with the VertexArray only 20.
    How is this possible?

    My old code was replaced with:

    glVertexPointer(3,GL_FLOAT,0,v_array);
    glEnableClientState(GL_VERTEX_ARRAY);
    glDrawarrays(GL_TRIANGLES,0,Num_Vertex);

    //v_array is an array of floats storing the x,y,z,x,y,z,....(declared as float*v_array)
    //Num_Vert is the number of vertices in the Scene(int Num_Vertex)

    Any suggestions,please!!!!!!

  6. #6
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    235

    Re: passing Vertex +Face list to opengl

    Hi!
    Why doesntīt anyone answer to my previos question??????????
    I know nobody has to answer it.
    I know so far you have answered a lot of my questions. (And are very thankful for you using your time to help me)

    So I only want to know:
    Does nobody know the answer or is the question formulated too bad or what else did I do wrong?

  7. #7
    Member Regular Contributor
    Join Date
    Feb 2000
    Location
    milano, italy
    Posts
    282

    Re: passing Vertex +Face list to opengl

    no no, i (and the others, i believe) have understood your problem

    i usually don't reply if a have nothing to say, or if i'm not sure about the answer.

    about your problem, i had the same experience.
    i don't know exactly why vertex arrays behave this way, and that's why i test various techniques on various systems.

    i'm waiting someone with clues to post

    Dolo/\/\ightY
    Dolo/\/\ightY

  8. #8

    Re: passing Vertex +Face list to opengl

    I'm just guessing but it might be just a driver / implementation problem. At least with my updated GeForce drivers things boosted quite a lot..

  9. #9
    Junior Member Regular Contributor
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    235

    Re: passing Vertex +Face list to opengl

    I'm just guessing but it might be just a driver / implementation problem. At least with my updated GeForce drivers things boosted quite a lot..

    This might be a possible solution but I cannot believe that 3D-Card Manufacturers write drivers in which the glDrawarrays Function is slower than the drawing of the same primitives with a "for{....}" loop.
    This would mean programmers have to use Simple "for{....}" loops instead of pass arrays in one run to the 3DCard.
    But,by the complexity of Hard- and Software today,nobody knows!

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: passing Vertex +Face list to opengl

    glDrawElements is faster than glDrawArrays, simply because the driver were optimised for that. There is also less repetitions of vertices using glDrawElements.

    John Carmack talked about it(glDrawElements) in one of his old .plan and I guess the drivers writers listenned to him, because with glDrawElements, my programs are much faster than with for-loop or with glDrawArrays.

Posting Permissions

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