PDA

View Full Version : Vertex array and OpenGL client/server



yossi
07-07-2004, 11:01 PM
hello all,
I am not sure if this message should be in the 'advanced' forum, if not than forgive me... ;)

Here is a simple code of how to render vertex arrays:

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, trigs);
glDrawArrays(GL_TRIANGLES, 0, 3*MAX_TRIGS);
glDisableClientState(GL_VERTEX_ARRAY);

I have some questions about vertex arrays and OpenGL client/server model:

1) The red book says that 'glEnableClientState' activates the array. What does
this activation mean?

2) I understand that glVertexPointer tells the server how to look at the array
the client sends to him. right?

3) The red book says that 'glDrawArrays' transfers the array data from the client
to the server. The amount of data is defined in the command.
So again what is the meaning of activation? Don't the glVertexPointer and
glDrawArrays commands tell the client exactly what to do...

4) Inorder to draw I need to call 'glDrawArrays' every time, and I understand
that this trigger the data of the array to be transferred to the server.
But what if the data is constant and I only want to access different indices
in the array? Is theres a mechanism to do so?

Maybe Vertex arrays are considered a simple issue but I when I read the
red book deeply, these delicate issues were not clear to me.

Any help to clear up things would be much appreciated,

Yossi

Obli
07-07-2004, 11:33 PM
Originally posted by yossi:
hello all,
I am not sure if this message should be in the 'advanced' forum, if not than forgive me... ;) I guess this is. No problem however.

Originally posted by yossi:
'glEnableClientState' activates the array. What does this activation mean?If an array is activated, then it will be used when you provoke vertices.
Take a look at the old EXT_vertex_array spec.
Basically, what it does is something like that:
foreach(vertex)
if(Enabled(COLOR_ARRAY)) Color(colorArray[vertex])
if(Enabled(NORMAL_ARRAY)) Normal(normalArray[vertex])
... and so go on.


Originally posted by yossi:
glVertexPointer tells the server how to look at the array the client sends to him. right?It effectively passes some informations to do that.

I have used DrawArrays very few, I don't remember exactly how it works so I won't say a thing about it.


Originally posted by yossi:
4) Inorder to draw I need to call 'glDrawArrays' every time, and I understand
that this trigger the data of the array to be transferred to the server.
But what if the data is constant and I only want to access different indices
in the array? Is theres a mechanism to do so?Sure it is. Take a look at DrawElements. It has pushes an array with all the indices you want to render.
There are also other evolutions of the command such as
- Compiled VAs: outdated. Don't use them.
- DrawRangeElements: never really tried it, but I think it won't give any significant advantage (expecially if ARB_VBO is used).
- MultiDrawElements: I think this is somewhat useful so I actualy have support for it but I have not done any accurate testings.
- ARB_VBO: very fast. Can easily give you +100% peformance without too much hassle (fully tested). Still to fully understand some implications of this method however. I raccomand to implement this before every other method.

Good luck!

yossi
07-07-2004, 11:55 PM
Thank you Obli for your answer!
I have tried ARB_VBO but didn't see any improvement :confused:
What still is not clear to me:
Is glDrawArray sending the vertex array data or only the indices? Because I don't see any API that distinguish between sending the data and using the data through indices, I guess that it sends the vertex data and tells the server what indices to use. I think the major profit is in not sending glBegin and glEnd for each primitive.

Yossi