Is it always safe to free memory on the CPU side once glBufferData called? For instance I have some code that calculates PositionData, normals, and texture coordinates once on start up (for use with gl3). This is then passed off to GL with a glBufferData call. I then want to free up the memory (PositionData,normals,texcoords).
GLfloat *PositionData=NULL;
GLfloat *normals=NULL;
GLfloat *texcoords=NULL;
GLsizei VertexCount = 0;
// fillin PositionData with malloc
// fillin normals with malloc
// fillin texcoords with malloc
// Generate a buffer object
glGenBuffers(1, &ArrayBufferName);
glBindBuffer(GL_ARRAY_BUFFER, ArrayBufferName);
glBufferData(GL_ARRAY_BUFFER,sizeof(GLfloat)*3*VertexCount,PositionData,GL_STATIC_DRAW);
.. repeat for normals, texture cooridnates, etc
// cleanup memory from malloc (no longer needed on CPU side?)
if (PositionData) free(PositionData);
if (normals) free(normals);
if (texcoords) free(texcoords);
The code runs fine and draws what I expect even after I free the CPU side data. I just want to confirm this is proper to delete the data immediately after glBufferData() called.