Problems with custom vertex attributes

hi

I’m currently implementing custom vertex attributes. Are there any examples or documents about that? I didn’t find any complete ones.

The problem is, that only one attribute array is accessable in the GLSL vertex shader fixed at index 1. And it doesn’t make a difference to what attribute variable of the vertex shader I bind the attribute index or if I even do the binding.

My vertex shader looks like this:


attribute vec3 customAttrib;
attribute vec3 customAttrib2;
attribute vec3 customAttrib3;

void main(void)
{
    gl_Position   = gl_ModelViewProjectionMatrix * gl_Vertex;
    gl_FrontColor = vec4( customAttrib.x, customAttrib.y, customAttrib.z, 0 );
}

It makes absolutely no difference, if I use customAttrib, customAttrib2 or customAttrib3 for gl_FrontColor. They all contain the values of the first vertex attribute and only, if I bind it to attribute index 1. No other index works.

I bind the vertex attribute array with this code:


GL20.glBindAttribLocation( shaderProgramHandle, 1, byteBufferContainingTheAttribName );
GL20.glEnableVertexAttribArray( 1 );
GL20.glVertexAttribPointer( 1, 3, false, 0, dataBuffer );

Any thoughts? Please ask, if I missed to provide some important information.

Marvin

from #lwjgl on freenode:

[quote][09:39:14] FN’MatthiasM: Mazon: somehow my JGO login is not working again - the problem is that only used attributes are available after linking
[09:39:33] FN’MatthiasM: and bindattriblocation behaves a bit different between renderers
[09:39:51] FN’MatthiasM: it’s better to query the attribute location - which may return -1 if the attribute was not used
[/quote]

Hi, Matzon. Thanks for the answer.

If you use GL20.glGetAttribLocation() I get 1 for the first attribute and 2 for the second one. But how do I know, that opengl has mapped the right attribute2 to index 1 and 2 when I actually have added them to index4 and 7 (or so)?

Marvin

you might want to visit #lwjgl - I’m really clueless in the area

ok. Thanks. I’m currently on it.