Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualmhagain

Posted 22 April 2014 - 07:09 PM

Yes and no.

 

Much of this is legacy from the old fixed pipeline (glEnable/DisableVertexAttribArray were modelled on glEnable/DisableClientState and first appeared in GL_ARB_vertex_program roundabout OpenGL 1.5: the older calls go back to 1.1) and dates to a time when you might be mixing vertex array drawing with immediate mode drawing.  So you'd use vertex arrays for your complex meshes and maybe glBegin/glEnd for your 2D GUI.

 

VAOs didn't exist then so you'd need to be constantly enabling/disabling arrays, otherwise your current draw calls might pull in unwanted state from your previous draw calls.  Obviously you wouldn't be using the same vertex format for everything (a mesh might have had position, normal, colour and 2 sets of texcoords; 2D GUI might just have position and a single set of texcoords) so a subsequent draw with a simpler format but more vertices might overrun the pointers used for a previous draw with a complex format but fewer vertices.  In software T&L days that was death: your program would crash (if you were lucky: worst case is that it would continue running for a while and crash later on in some completely unrelated part of the code).  Hardware T&L is more robust but back then you couldn't rely on everyone having it.

 

With VAOs - assuming you use them the way they're intended to be used - there's still a need for Enable but it could be argued that Disable is redundant.  An attrib array must have a default state and that default state is disabled.  If you try to draw from an enabled array but with no pointer set you'll crash too, so disabled is safer.  glDisableVertexAttribArray is still handy to have around in case you ever want to modify a VAO at some time.  And of course Enable must then exist if you ever want to go back again and modify it again.  (None of that would exist if VAOs had been specified as immutable, but the ARB don't seem to have liked specifying immutable object types until quite recently.  So in order for VAOs to be mutable both must exist.)

 

Unfortunately GL does carry a lot of legacy baggage like this around.  Things that sometimes don't seem to make sense today can turn out to have a perfectly reasonable explanation when you wind the GL_VERSION back a few notches.

 

All of this goes away with GL_ARB_vertex_attrib_binding of course, which you should be using if possible.


#1mhagain

Posted 22 April 2014 - 07:05 PM

Yes and no.

 

Much of this is legacy from the old fixed pipeline (glEnable/DisableVertexAttribArray were modelled on glEnable/DisableClientState and first appeared in GL_ARB_vertex_program roundabout OpenGL 1.5: the older calls go back to 1.1) and dates to a time when you might be mixing vertex array drawing with immediate mode drawing.  So you'd use vertex arrays for your complex meshes and maybe glBegin/glEnd for your 2D GUI.

 

VAOs didn't exist then so you'd need to be constantly enabling/disabling arrays, otherwise your current draw calls might pull in unwanted state from your previous draw calls.  Obviously you wouldn't be using the same vertex format for everything (a mesh might have had position, normal, colour and 2 sets of texcoords; 2D GUI might just have position and a single set of texcoords) so a subsequent draw with a simpler format but more vertices might overrun the pointers used for a previous draw with a complex format but fewer vertices.  In software T&L days that was death: your program would crash (if you were lucky: worst case is that it would continue running for a while and crash later on in some completely unrelated part of the code).  Hardware T&L is more robust but back then you couldn't rely on everyone having it.

 

With VAOs - assuming you use them the way they're intended to be used - there's still a need for Enable but it could be argued that Disable is redundant.  An attrib array must have a default state and that default state is disabled.  If you try to draw from an enabled array but with no pointer set you'll crash too, so disabled is safer.  glDisableVertexAttribArray is still handy to have around in case you ever want to modify a VAO at some time.  And of course Enable must then exist if you ever want to go back again and modify it again.

 

Unfortunately GL does carry a lot of legacy baggage like this around.  Things that sometimes don't seem to make sense today can turn out to have a perfectly reasonable explanation when you wind the GL_VERSION back a few notches.

 

All of this goes away with GL_ARB_vertex_attrib_binding of course, which you should be using if possible.


PARTNERS