Sign in to follow this  
saman_artorious

GL_VERTEX_ARRAY Vs. GL_COLOR_ARRAY

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Brother Bob    10344

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.

Share this post


Link to post
Share on other sites
marcClintDion    435

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);

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this