They both can transfer vertex data, but what is the difference between them?
Do them work in a similar way?
attribute
is a qualifier for input variables.
From the OpenGL Wiki page:
The attribute qualifier is effectively equivalent to an input qualifier in vertex shaders.
In other words, they're equivalent (in
is the input qualifier), but do note that this applies to attribute
:
The following qualifiers are deprecated as of GLSL 1.30 (OpenGL 3.0) and removed from GLSL 1.40 and above.
The layout
qualifier lets you specify the variable's locations directly, avoiding the need to use glBindAttribLocation
, or these can be used to match variables from (e.g.) vertex shader to fragment shader instead of using name matching, among other uses.