PDA

View Full Version : passing Vertex +Face list to opengl



XBCT
03-04-2000, 03:52 AM
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++ http://www.opengl.org/discussion_boards/ubb/wink.gif{
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?
http://www.opengl.org/discussion_boards/ubb/confused.gif

Hude
03-05-2000, 10:21 PM
I think you should use vertex arrays. Try looking info on glVertexPointer, glArrayElement.

XBCT
03-06-2000, 04:25 AM
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.

Hude
03-06-2000, 10:05 PM
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.

XBCT
03-07-2000, 04:09 AM
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? http://www.opengl.org/discussion_boards/ubb/confused.gif

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!!!!!!

XBCT
03-09-2000, 03:25 AM
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. http://www.opengl.org/discussion_boards/ubb/smile.gif(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?

dmy
03-09-2000, 03:33 AM
no no, i (and the others, i believe) have understood your problem http://www.opengl.org/discussion_boards/ubb/smile.gif

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Dolo/\/\ightY

Hude
03-09-2000, 05:04 AM
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..

XBCT
03-09-2000, 11:05 AM
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! http://www.opengl.org/discussion_boards/ubb/smile.gif

Gorg
03-09-2000, 02:59 PM
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.

XBCT
03-10-2000, 03:11 AM
Looks like a good answer Gorg.
Do you know if there is an Archive with Carmackīs Plan Files somewhere on then net????
P.s.:Thank you for taking time to answer my questions guys! http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Bobtree
03-14-2000, 08:04 PM
the document by Carmack which you seek is available here: http://www.quake3arena.com/news/glopt.html

XBCT
03-15-2000, 03:27 AM
Thanks Bobtree! http://www.opengl.org/discussion_boards/ubb/biggrin.gif