In OpenGL, I always see that the position attribute is always placed at attribute 0. Is it possible for the position attribute to be at number 1? Why is the position attribute always at attribute 0?
In OpenGL, I always see that the position attribute is always placed at attribute 0. Is it possible for the position attribute to be at number 1? Why is the position attribute always at attribute 0?
Outside of the now-removed gl_Vertex built-in attribute, there is no such thing as a "position attribute." GLSL has no idea which attribute corresponds to a "position". They're all just numbers to your vertex shader; they only gain meaning when you assign something to gl_Position.
Which is a vertex shader output. How you generate the value for that output is none of GLSL's business.
That having been said, older versions of OpenGL did anoint attribute 0 with special powers. But these were mainly vestigial elements from fixed-function glBegin/End-style programming, and they were not required to have the meaning "position". The only special status it had was that you had to put something there. That is, you couldn't not use attribute 0.
But again, that's long-since been removed from OpenGL. Nowadays, people put a "position" there merely by habit.