Jump to content
  • Advertisement
Sign in to follow this  
nonsenseinc

OpenGL glVertexAttribPointer - understanding the size attribute

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

Greetings,

after reading several OpenGL documentations I understand that glVertexAttribPointer takes a numeral value between 1 and 4 for its second parameter (size) as information how many vertices are taken into consideration to render a single triangle. But I do not understand how to use other then three vertices for a triangle. Also trying different values and seeing the result doesn't help me.
What exactly does this do and what is it used for?

Cheers,
Jan

Share this post


Link to post
Share on other sites
Advertisement
It's the number of components that make up the attribute (e.g. x, y and z is 3 components).

e.g. if size is 3, and type is [font=courier new,courier,monospace]GL_FLOAT[/font], then the corresponding C/C++ type is [font=courier new,courier,monospace]float[3][/font] and the GLSL type is [font=courier new,courier,monospace]vec3[/font].

Share this post


Link to post
Share on other sites
For example, you might have an attribute with 2 as size for texture coords, or a size of 4 if you need x,y,z,w coords (which you will eventually). Moreover, it doesn't needs to be juts coordinates, you could store color in with 4 components in RGBA form (red, green, blue, alpha).

You can additional information besides the position of a vertex. Edited by TheChubu

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!