1
votes

When using glBegin/glEnd, is it equivalent to one draw call?

I mean, when using glDrawArrays, as I understand, that's the point when data is transferred to GPU (client side to server side). When using glBegin/glEnd, is data transferred to GPU only at the glEnd call? Or vertex are transferred one by one every glVertex/glNormal/glTexCoord call?

1
see nicols answer for exact details but its pretty safe to think of one glBegin/glEnd as one draw callJustin Meiners
So, can I suppose that using glBegin/glEnd is similar in performance to using Vertex Arrays and glDrawArrays? Both are immediate mode.Ray
@Ray No, you definitely can't. Vertex arrays are not immediate mode. The advantage of glDrawArrays over glBegin/glEnd does not just come from using GPU data right away (i.e. when using VBOs), but also from the fact that you don't make a driver call for each and every stupid little vertex. And that is a strength that plays out even for client side vertex arrays. So while in practice anything is possible and depends on your application and implementation the general rule is, that glBegin/glEnd is likely slower than glDrawArrays (no matter if using VBOs or not).Christian Rau
@Cristian Thanks for clarification. I just read in another answer that Vertex Arrays could be considered "immediate mode" because vertex data is stored in client side (link).Ray

1 Answers

5
votes

How these work is implementation dependent. At the very least, you can know that nothing gets transferred to the GPU until you call glVertex/glVertexAttrib(0), since those are what provokes a vertex (ie: causes the attribute state to be sent). Whether vertex data are transferred immediately upon calling a provoking function, or if they are buffered and transferred at glEnd time, or perhaps even later than that, is entirely implementation dependent.

Also... you shouldn't care. If you're using immediate mode, it should be because you don't care about performance. If you cared, you'd be using buffer objects and modern rendering functionality, not immediate mode.