Hi,
when I create a buffer using glBufferData, memory is used up on the CPU. When I change the data, because say the colours of the vertices change. I delete the Buffer using glDeleteBuffers, memory is not deleted from the cpu. Then when I generate a new buffer using the same array, with the new colours using glBufferData more memory is used up on the CPU. I have a memory problem and moving from version 1 to version 4 has not solved it, it seems.
Any help gratefully appreciated please
size_t szTemp;
if (cClearVBOBuffer == 1)
{
glDeleteBuffers(1, &indexBufferID);
glDeleteBuffers(1, &triangleVBO);
if (cDebug == 'y')
{
GLenum GLenumError;
GLenumError = glGetError();
if (GLenumError != GL_NO_ERROR)
OGLErrorCode(GLenumError);
}
}
gluiNoOfPointCloudPoints = PointCloudVBO(hwnd);
cClearVBOBuffer = 1;
SetUpProcs();
//glm::translate(glm::mat4(1.f), glm::vec3(glfHoriz, glfVert, -(glfZoom - (GLfloat)gldRadius)));// (glfHoriz, glfVert, -(glfZoom - (GLfloat)gldRadius));//100.0);
polarViewVBO(((GLdouble)glfZoom), 0.0, (GLdouble)flatitude, (GLdouble)flongitude);
//vbo stuff
glGenBuffers(1, &triangleVBO);
glBindBuffer(GL_ARRAY_BUFFER, triangleVBO);
//glBufferData(GL_ARRAY_BUFFER, sizeof(vertex), vertex, GL_STATIC_DRAW);// sends data to the graphics card
//GLMPOSCOL
glBufferData(GL_ARRAY_BUFFER, (sizeof(POSCOL) * (size_t)gluiNoOfPointCloudPoints), mmvertex, GL_DYNAMIC_DRAW);// GL_STATIC_DRAW);//creates and initializes a buffer object's data store
if (cDebug == 'y')
{
GLenum GLenumError;
GLenumError = glGetError();
if (GLenumError != GL_NO_ERROR)
OGLErrorCode(GLenumError);
}
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, 0);
glEnableVertexAttribArray(1);//note the 1, is the first argument in the glvertexattribPointer which makes the connection
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, (char*)(sizeof(GLfloat) * 3));//the char is a GL thing but essential
//************ INDEX STUFF ****************
GLuint indexBufferID;
glGenBuffers(1, &indexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferID);//part of the process sending data to the graphics card
szTemp = sizeof(GLuint) * (size_t)gluiNoOfPointCloudPoints;
//glBufferData(GL_ELEMENT_ARRAY_BUFFER, (size_t)(sizeof(GLuint) * (size_t)gluiNoOfPointCloudPoints), indecis, GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (size_t)szTemp, indecis, GL_STATIC_DRAW);
if (cDebug == 'y')
{
GLenum GLenumError;
GLenumError = glGetError();
if (GLenumError != GL_NO_ERROR)
OGLErrorCode(GLenumError);
}
InstallShaders(hwnd);
}