Advertisement Jump to content
Sign in to follow this  

OpenGL Getting order of attributes, as specified in shader file.

This topic is 1883 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I am writing an OpenGL shader loader. Currently, once I have linked the shader program, I am looping through each active attribute using glGetObjectParameterivARB(m_uiShaderID, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &iCount), and calling glGetActiveAttrib() using the loop index, and then glBindAttribLocation() with the index and the name returned from glGetObjectParameter.


This approach is not giving me the attributes in the order in which I have specified them in the shader program, for example I have:


in vec4 vPosition;

in vec3 vNormal;


and my loop output gives:


0 vNormal

1 vPosition;


Is there a way I can get the attributes in the correct order, using OpenGL functionality?

Share this post

Link to post
Share on other sites
Yes. By using layout location qualifier.
For example: layout (location = 0) in vec4 vPosition;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!