Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
float linePos[6]={0.0f,5.0f,0.0f,0.0f,30.0f,0.0f};    

glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*3*2, linePos, GL_STATIC_DRAW);

glUniformMatrix4fv(UniformColor.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
//this just transforms all vertices


I want to make some animation changing the position (ex.translate) of one end the line(linePos[0]) but not the other. How can I do that?

share|improve this question
up vote 2 down vote accepted

You can do that using glBufferSubData. In your case, with only 6 vertices, you can just replace the complete buffer using glBufferSubData. This prevents the reallocation that glBufferData does.

You shouldn't use GL_STATIC_DRAW if you change it often, thought.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.