Sign in to follow this  

vertex attributes + VBO's

This topic is 4771 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've loaded my VBO data and set it like so:

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

	glEnableVertexAttribArrayARB(w->handle);
	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.
varying vec4 colour;

void main()
{										
	gl_FragColor = 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?

Share this post


Link to post
Share on other sites


GLuint vboWeights;

glGenBuffersARB( 1, &vboWeights );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboWeights );
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vector4) * weights.GetSize(), weights.GetData(), GL_STATIC_DRAW_ARB );




Vector4 is just an array of 4 floats, weights is an array of Vector4's and GetData returns the pointer to the array.

Share this post


Link to post
Share on other sites
Where do you store the vertices?

You can't use two different buffers, one for vertices and one for weights, you need to put both of them in the same buffer.

To do this you can either assign the weight to the vertex in the vertex structure and use


glBindBufferARB(ID);
glVertexPointer(3, GL_FLOAT, 0, sizeof(vertexstruct));
glVertexAttribPointerARB(ID, 4, GL_FLOAT, false, vertices[0].weight, sizeof(vertexstruct));


I'm a little rusty on the function parameters since this is just off my head but the point is that you have to set the vertex pointer to the first vertex in the vertices buffer and the weight pointer to the the first weight in the vertices buffer. Then you need to set the stride of both of the pointers to the size of the vertex structure.

The other way is to store the vertices in one part of the buffer an the weights in the other one. You then assign the vertex pointer to the start of the vertices buffer and the weight pointer to the start of the vertices buffer plus the offset to the weights.

Note: i've never used weights or fragment programs before, but this is what seems to be wrong.

Share this post


Link to post
Share on other sites
Using multiple buffers at a time is perfectly legal, after each buffer bind that buffer is the current buffer for loading in the next gl*Pointer() call, so there shouldnt be any problem with it.

On the face of it the code looks fine, so part of me wonders if this is a driver issue. However as I dont have any code handy to test this sort of thing myself atm it will have to stay as a wondering.

Supagu; what gfx card and driver set are you using?

Share this post


Link to post
Share on other sites
radeon 9600xt i'm using drivers 4.10, i also tried 4.9 with same problem. phantom, maybe i could send you my exe if you have a different video card?

Share this post


Link to post
Share on other sites

This topic is 4771 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this