Sign in to follow this  
Guy Meh

Someone explain vertex attributes to me?

Recommended Posts

I want to pass some custom vertex attributes to my shaders, and am having trouble figuring out the process behind that. The functions that I'm looking at are glBindAttribLocation and glEnableVertexAttribArray. As far as I can tell, glBindAttribLocation tells a shader program about a named vertex attribute while glEnableVertexAttribArray is used to "turn on" a particular vertex attribute. The biggest thing I'm having trouble with is how these functions require an index. Unlike uniform variables, it appears I have to supply my own index/location integer first when I want to bind an attribute to a shader program. Choosing indices is made tricky because I get the impression that several index values are reserved and that I only have a finite range of indices available to me depending on the graphics card. I'm also wondering if the order that these functions are called matters. I think I have to call glBindAttribLocation before I call glLinkProgram, but do I call glEnableVertexAttribArray before or after glBindAttribLocation? Thanks if someone could help me out. I'm just disappointed that I haven't been able to find any code examples anywhere.

Share this post


Link to post
Share on other sites
Never mind. The page is showing up for me now.

(Update)

Going by that article, apparently I don't have to call glBindAttribLocation; I can just call glGetAttribLocation to get the location of an attribute variable I know about.

The problem I'm having now is if I make a call to glEnableVertexAttribArray then try to do some drawing, my program crashes even when I don't pass in any vertex data.

[Edited by - Guy Meh on January 21, 2009 10:05:12 PM]

Share this post


Link to post
Share on other sites

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