Jump to content
  • Advertisement
Sign in to follow this  
gatofedorento

Problem using GLSL attributes

This topic is 2339 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

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!