We create a vao, which is more or less like a pointer. where is it? in os mem or in graphic card mem?
then generate two or more VBO in graphic card mem, which is cantained by the VAO.
How shall we distinguish them belong to which vao without coding sequence.?
say, needn’t bind, gen, bind, gen…
2]how to transmit the data in shaders to conresponding VBO distintly and easily?
let prog knows who is who simply and easily?
look at the relative prog, is it very complex?
set up vbo, one is for vertex, one is color;
glGenBuffers(2,vboHandle);
bind to be effective and transmit vertex and color data into it. the data is in shaders*.text defined.
//////////////////
GLuint vboHandles[2];
glGenBuffers(2, vboHandles);
GLuint positionBufferHandle = vboHandles[0];
GLuint colorBufferHandle = vboHandles[1];
//bind to use it.
glBindBuffer(GL_ARRAY_BUFFER,positionBufferHandle);
glBufferData(GL_ARRAY_BUFFER,9 * sizeof(float),
positionData,GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER,colorBufferHandle);
glBufferData(GL_ARRAY_BUFFER,9 * sizeof(float),
colorData,GL_STATIC_DRAW);
glGenVertexArrays(1,&vaoHandle); //Vertex Array Object
glBindVertexArray(vaoHandle); /* Bind VAO as the current used object */
/* Enable attribute index 0 as being used */
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, positionBufferHandle); //see below
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte *)NULL );
/* Specify that our coordinate data is going into attribute index 0, and contains 3 floats per vertex */
glBindBuffer(GL_ARRAY_BUFFER, colorBufferHandle);
glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, (GLubyte *)NULL );