how do I use glDrawPrimitive ?

Can anyone explane how to use glDrawPrimitive ?? or where I can find a tutorial about it

Thanks for your answer

hmmm never heard read oer saw anything about that. You sure it is existing?

Looks like someone had D3D on their mind as it does have a DrawPrimitive command.

geee I should have known, that i have to learn something about 3D3 to answer and post questions in here

[This message has been edited by DaViper (edited 09-03-2001).]

ops… it should be glDrawElement

You specify your vertex arrays as you normally would, but making sure that all are the same size. For example, if you are using color, texture coordinate, and vertex arrays, then the color specified at color array entry x will be applied to the vertex in vertex array slot x, and the texture coordinate will come from the 'x’th element of your texture coordinate array.

That much is simple.

Now you create another array, this one of an integer data type (usually GLuint). Each entry in it is an array index in your vertex, color, and texture arrays. So if your index array looks like this:

GLuint index = {0, 4, 1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11};

Then it will draw the vertex in vertexarray[0] with texture coordinate of texcoord[0] and color of colorarry[0]. And then it’ll do the same thing with, but with the array data at index 4 of each array, and then 1, and then 5, and so on.

You can also use interleaved arrays. They work the same way.

The advantage to using GLDrawElements is that each vertex is transformed once. So, as you saw in my example array of indices, I had several verteces referenced twice. But one of them would only need to be transformed once.

Hope that helps.

[This message has been edited by TerranFury (edited 09-04-2001).]

I can add also, that you should use glEnableClientState(xxxx) and then glXXXXPointer() functions if you wanna render primitive from separate arrays, or glInterleavedArrays() function if you wanna d3d-like non-strided primitive rendering.