How to access color array set by older API from within a vertex shader?

In my understanding , if I set a color array with a newer API which use the attribute index , for example , the attribindex parameter of glVertexAttribFormat , I can access the array from within a vertex shader by declare the layout

layout(location=attribindex) ...

but if I set the color array with older API , for example , glColorPointer, what the attribute index will be ?

You have to use the compatibility attributes, like gl_Color.

Also, please don’t use compatibility attributes. There’s no reason at this point to do that. If you’re able to use GLSL (let alone GLSL 3.30 features like layout(location attribute setting), then you’re able to use generic attributes.

thank you , this really help. the compatible API is simple and strait forward. It is convenient for exercise purpose.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.