glVertexPointer() & glDrawArrays() algorithms

Hi does anyone know the internal algorithms for glVertexPointer() & glDrawArrays()?

I’m interested to see how they operate internally. I’m tryin to write a subset of these funtions in my dissertation to work on a small embedded system. I know that these functions work the same on OpenGl ES.

Thanks…

You could look at the MESA implementation. http://www.mesa3d.org/

What internal algorithms are you speaking about? It will all depend on the driver/implementation.

I mean, the code for each of those functions.
There must be code, algorithms for them somewhere to work from?

yeah, MESA, as pointed out by Relic.

ok i will take a look at that then…

thanks

MESA is just a particular software implementation. If MESA does it some way it doesn’t mean “OpenGL” generally does it that way. Each hardware driver will have it’s own mechanisms implemented. The OpenGL operations are defined by their semantics and not their “algorithm”.

I mean, if you want to write a subset of OpenGL, you surely can use MESA code as example (if it will do you any good — you will be faster coming up with your own solution). But please dont’t make the mistake of considering them “internal algorithms” of this operations-- they just don’t have any.

P.S. Sorry, if I am being overly serious, I need to get some sleep ))

I looked at mesa and im not sure i understood it.
like i said, i’m very new to all of this.

i was hoping to find pseudo code type information somehwere with regards to those functions.

Also I am going ot have to write code for the glEnableClientState function that enables the use of GL_VERTEX_ARRAYS when provided with this constant. I take it, this is initially disabled?

The pseudo code can be found in the specs. Basically, it goes like this:


void glDrawArrays(glenum mode, glint first, glint count)
{
   glBegin(mode)
     for i in 0:count-1
     {
         glVertexfv(gl_vertex_array_pointer+(first+1)*vertex_size) 
     }
   glEnd
}


 

I see, so it calls another GL function…
where can i find the rest of the pseudo ? can you provide me with a link please?

Come on, what is your problem exactly ?

  • you asked for code, you had a relevant answer : MESA.
  • then you asked for pseudo code because “mesa is too complex”, you had a relevant answer.

Read the specs of http://www.opengl.org/sdk/docs/man/xhtml/glVertex.xml !

What do you expect now ? People writing your dissertation at your place ? The involved algorithms are pretty simple, it is just a matter of sending vertex information in a optimized way.

I must admit, I am most confused with your reply… The pseudocode I supplied reflects the semantics of the DrawArrays operation. Meaning, that a DrawArrays operation has the same effect as a series of Vertex operations. Now, as basic idea of DrawArrays is to provide high-performance primitive setup, it would be very stupid to actually implement it this way (as we are killing all performance benefits). In a real implementation, this function will likely feed the data to the actual primitive setup unit, whih could be a software one (in case of MESA) or a hardware one (a GPU).

P.S. The pseudocode, as I already said, should be found in te OpenGL specifiation, which is available for download from this very site. I don’t remember where I saw it, it was years ago and I don’t have the time to search for it. Still, if you are interested in implementing a subset of the OpenGL, you should read the specifiation anyway.

P.P.S Zbuffer was faster ))

Ok, i see… that makes sense.

I do also have the paper based reference manual too. I was just struggling a bit on the subject.

Thank you for your help guys.

…and sorry to have bothered you.