Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.
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

glLineWidth(3);
glDrawArrays(GL_LINES,0,2);

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
add comment

1 Answer

up vote 1 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
add comment

Your Answer

 
discard

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.