Someone explain vertex attributes to me?

Started by
3 comments, last by Guy Meh 15 years, 3 months ago
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.
Advertisement
Should help..

http://www.lighthouse3d.com/opengl/glsl/index.php?oglattribute
:)
Feel free to 'rate me down', especially when I prove you wrong, because it will make you feel better for a second....
I tried going to that web site, and I got this:
Quote:Fatal error: Maximum execution time of 30 seconds exceeded in /home/light/public_html/opengl/glsl/index.php on line 130

Weird.

It's generally online for me.

Did you try Google Cache?
Feel free to 'rate me down', especially when I prove you wrong, because it will make you feel better for a second....
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]

This topic is closed to new replies.

Advertisement