Jump to content

  • Log In with Google      Sign In   
  • Create Account


GL_VERTEX_ARRAY Vs. GL_COLOR_ARRAY


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 saman_artorious   Members   -  Reputation: 145

Like
0Likes
Like

Posted 04 July 2013 - 05:20 AM

In my implementation to send Vertices and Color variables to GPU using VBO and VAO, I created one VAO and two VBOs.

Both these VBOs are of type GL_ARRAY_BUFFER. However, I see in some implementations that they dedicate one GL_VERTEX_ARRAY and one GL_COLOR_ARRAY.

I am confused! could anyone explain about these to me please.



Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 7903

Like
2Likes
Like

Posted 04 July 2013 - 05:28 AM

GL_ARRAY_BUFFER is a VBO type (in particular that stored vertex data; there are other VBO types that stores for example vertex indices), GL_VERTEX_ARRAY and GL_COLOR_ARRAY are attribute types that says whether a vertex array stores vertex or color data.

 

If you're working with VBOs, then GL_ARRAY_BUFFER is the type of VBO you strore vertex data in, and if you're using shaders and generic attributes then you can forget about the other two because they are only used for the old and deprecated vertex array methods.



#3 marcClintDion   Members   -  Reputation: 431

Like
0Likes
Like

Posted 08 July 2013 - 05:28 AM

You'll likely also want to implement GL_ELEMENT_ARRAY_BUFFER(for indices) in combination with GL_ARRAY_BUFFER.

 

As was said, GL_ARRAY_BUFFER is generic and can hold many types of info including color.  In the following instance the array that's being passed to the VBO has 4 "types" being passed in.  The first 3 floats are the position, the next 3 are tangents, after that 3 for biTangents, the last 2 are the texCoords.

 

You could also put 4 more in there for color, 3 more for normals or whatever, it's totally generic and user defined.  I'm not sure off hand what the attribute limitation is for the various levels of hardware.  You'd want to check on that for your target platform before getting too carried away with packing various whatever's in there.

In this light, GL_COLOR_ARRAY seems redundant so far as understanding it goes.

//==============================================================================================================================

 

GLfloat facing_UP[] = { //number of vertices = 294 -6.3995, 0.00457, 2.50083, 0,1,01, 0, 0, -0, 1,

....

....

....

};

 

//==============================================================================================================================

  #include   "facing_UP.c"   //<-This is the array shown above   glGenBuffers(1, &facing_UP_VBO);     glBindBuffer(GL_ARRAY_BUFFER, facing_UP_VBO);     glBufferData(GL_ARRAY_BUFFER, sizeof(facing_UP), facing_UP, GL_STATIC_DRAW);     glBindBuffer(GL_ARRAY_BUFFER, 0);

//==============================================================================================================================


Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, because you know that the testing of your faith produces perseverance. Let perseverance finish its work so that you may be mature and complete, not lacking anything.





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