GLSL - Equivalent Of "layout (location = 1)" In #version 130

Fejwin picture Fejwin · Oct 6, 2011 · Viewed 11.6k times · Source

I am reading a tutorial about openGL 3.3 (where naturally GLSL 330 is in use). Unfortunately my hardware is limited to openGL 3.0 (where GLSL 130 is the newest format). In GLSL 130 the syntax

layout (location = 1) in vec4 position;

produces an error. Most importantly a code where several instances of "layout" are applied to different variables does not work. I even tried

#extension ARB_explicit_attrib_location : require

which is also not supported. Is there a way to rewrite these statements from 330 in 130 equivalently?

Answer

Nicol Bolas picture Nicol Bolas · Oct 6, 2011

If your implementation does not support ARB_explicit_attrib_location (either as an extension or as version 330 or later), then you cannot use explicit attribute locations. You must specify them before the linking phase with glBindAttribLocation.

And technically, your "hardware" could do this just fine. NVIDIA and ATI support this extension in all hardware that they still support in drivers. This is an API convenience. I'm guessing you're on some from of Intel hardware. If so, you have my sympathy.

BTW, is that my code, by chance?