Vertex attributes + VBO's

i’ve loaded my VBO data and set it like so:

	Shader::Param* w = shader->GetParameterByName("weight");

	glBindBufferARB(GL_ARRAY_BUFFER_ARB, skin->GetMeshMat().vertexBuffer->vboWeights);
	glVertexAttribPointerARB(w->handle, 4, GL_FLOAT, false, 0, 0);

now in my shader:

vert shader:

attribute vec4 weight;
varying vec4 colour;

void main()
	gl_Position = ftransform();	
	colour = weight;
	colour.a = 1.0;

fragment shader simply outputs the colour.

now most values being set are: 1.0, 0.0, 0.0, 0.0
so i would expect red. But what i get is blue and black, and it flickers to black and back like its sending incorrect data!?

any ideas on what i should do to try to indentify the problem?

read in this thread:;f=11;t=000472

that i must bind some vertex attributes before i link?

this is sort of akward, is there a way around this?
the main thing is i dont know what the data for glVertexAttribPointerARB is at link time, if i do need to specify this info at link time makes things a bit more painful. ? must i do this? is that what my problem is?

I assume your GetParameterByName function is calling glGetAttribLocation and the return value is what is stored in w->handle?

Do you have a fragment shader as well? If not, change your shader to write to gl_FrontColor and see if you get the correct output.

You shouldn’t need to call glBindAttribLocation.

heres my fragment shader:

varying vec4 colour;

void main()
	gl_FragColor = colour;		

GetParameterByName simply returns a handle to the shader param, at load time, i parse my shaders, and get handles to all variables and store them in an array which GetParameterByName simply looks through.

but yeah ultimately this handle is gotten via glGetAttribLocationARB

gl_FrontColor isnt a valid variable

any one any ideas why this aint working?

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