View Full Version : How to using glBufferData to update buffer data

01-16-2015, 01:57 AM
Hi all, I am trying to update the buffer data to draw moving things using glBufferData.

The problem is this simple program memory usage increases over time. When I ran the valgrind to test leak memory, glfwSwapBuffers is reported definitely memory lost. Can any body help explained this? Thank you.

while (!glfwWindowShouldClose(window))
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices1), vertices1, GL_STATIC_DRAW); \\ inside loop draws nothing
// Retrieve window events

// Clear the screen to black
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

// Draw triangle
glDrawArrays(GL_TRIANGLES, 0, 3);
//printf("Drawing ...\n");
glfwSwapBuffers(window); // swap the back buffer and front buffer after drawing finished

Dark Photon
01-16-2015, 07:26 AM

* https://www.opengl.org/wiki/Buffer_Object#Data_Specification