Jump to content

  • Log In with Google      Sign In   
  • Create Account


Problem using GLSL attributes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Kaelb   Members   -  Reputation: 151

Like
0Likes
Like

Posted 22 March 2012 - 03:16 PM

Hey there, I'm making some skeletal animation coe using bones, for the vertex transformations I want to use GLSL, my buffer/rendering code is something like this:

-Generate a buffer with this function
GLuint generateBuffer(GLenum target, GLsizeiptr size, GLvoid* data, GLenum usage){
GLuint ret;
	glGenBuffers(1, &ret);

	glBindBuffer(target, ret);
	glBufferData(target, size, data, usage);
	return ret;
}

-Then I bind the buffer and call the drawing function
glBindBuffer(GL_ARRAY_BUFFER, mesh->bufferID);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->indicesID);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3, GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(24));
	glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(12));
	glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(0));

The BufferVertex is a structure with this format:
struct BufferVertex{
	float x, y, z;		//Vertex
	float nx, ny, nz;	 //Normal
	float s0, t0, z0;	 //Texcoord0
};

To implement my shader for the skeletal animation I want make another buffer with attribute variables, something like what is found in this site http://www.lighthous...bute-variables/ . My problem is that I'm not using VAOs, instead I'm making two VBOs, one for the geometry (BufferVertex structure) and another for the indices.

I there a way to implement another buffer to pass to the shader without using VAOs? If yes, can anyone explain me the changes I have to do?

Cumps

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 7337

Like
0Likes
Like

Posted 22 March 2012 - 07:31 PM

You should probably be using glVertexAttribPointer instead of glVertexPointer and friends (and glEnableVertexAttribArray instead of glEnableClientState) - it's a much cleaner API. You'll need to declare your own input attributes in your vertex shader instead of using the built-in ones, and (in older GLSL) use glBindAttribLocation to bind them to an attribute slot number (newer GLSL allows you to specify slot numbers in your shader code).

If you don't want to make that kind of change to your code you can just glBindBuffer your extra buffer and set more glTexCoordPointers for it, then use the extra texcoord slots. Don't forget glClientActiveTexture if you go down this route (this is where the old gl*Pointer API starts getting ugly).

VAOs are not needed for either of these aproaches.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS