PDA

View Full Version : glVertexAttribPointer


tobeythorn
03-18-2009, 05:12 PM
Hi,
I've recently learned that in openGL, glVertexPointer, glNormalPointer, etc, are set for deprecation. The new way of doing things seems to be glVertexAttribPointer. However, I haven't found any examples of its use. From what I understand, it passes attribute variables to the shaders program. Not really sure how to name those variables so that I can use them in my shader.

Have any of you used this yet? Any examples?
Thanks,
-Tobey

Reedbeta
03-18-2009, 05:53 PM
Shading languages like Cg allow you to use semantics like ATTR0, ATTR1 (not 100% sure about the spelling of those), in place of the usual POSITION, NORMAL, TEXCOORD0 and so forth. You can specify the data for these semantics with glVertexAttribPointer. I don't remember how you do this in GLSL, but I assume it has some similar function.

delinkx
03-18-2009, 09:12 PM
http://www.opengl.org/sdk/docs/man/xhtml/glVertexAttribPointer.xml

tobeythorn
03-19-2009, 07:14 AM
delinkx,
Yes, that is the only document I have found at all, and it makes more sense the second time around. However, it doesn't provide an example of its use, and I still have no idea how to access the attributes in my vertex shader. I would like to specify both vertex positions and normals, and possibly other arrayed attributes too.

tobeythorn
03-19-2009, 07:16 AM
Nevermind, I believe that the following function does what I want:
GLint glGetAttribLocation(GLuint program,char *name);