I run across a sample OpenGL code that I ported to OpenGL ES 2.0 (there wasn't much to be done actually), but I cannot help wondering what the glBufferData function is for. The original source is like that:

glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 2 * 6, quad, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 2, (void *) 0);

But I can successfully simplify it as:

glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 2, quad);

That is, I can omit the glBufferData function just by using a valid pointer to the quad array in glVertexAttribPointer.

So, could anyone explain what's the glBufferData function for? From what I'm doing it seems to be redundant but that must be because of my serious lack of knowledge of the API. As a matter of fact I tried reading the docs at khronos.org but this didn't help me understand its use.

Edit
Report