Jump to content

  • Log In with Google      Sign In   
  • Create Account


glVertexAttribPointer - understanding the size attribute


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 nonsenseinc   Members   -  Reputation: 102

Like
0Likes
Like

Posted 18 November 2012 - 04:28 AM

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

Sponsor:

#2 Hodgman   Moderators   -  Reputation: 27559

Like
1Likes
Like

Posted 18 November 2012 - 05:54 AM

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 GL_FLOAT, then the corresponding C/C++ type is float[3] and the GLSL type is vec3.

#3 TheChubu   Crossbones+   -  Reputation: 3698

Like
0Likes
Like

Posted 18 November 2012 - 01:18 PM

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, 18 November 2012 - 01:23 PM.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

 

My journals: dustArtemis ECS framework and Making a Terrain Generator





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS