I’m using this tutorial: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-4-a-colored-cube/
And here’s the exercise: Once you’ve done that, make the colors change each frame. You’ll have to call glBufferData each frame. Make sure the appropriate buffer is bound (glBindBuffer) before !
I don’t know how to do this. I know how to modify the color buffer to change colors, but not how to change them each frame. Can anyone help?
As the exercise states: Call
glBufferData! You’ve already done it to set the colour the first time.After changing the data, re-bind the colour buffer with
glBindBuffer, then repeat the call toglBufferData– both with the same arguments as the first time – and your new colour buffer data will be sent to the GPU.On how to actually change the data, you could, for instance, insert the same value in each cell of the colour data array with a loop like the following:
Alternatively, if you want to insert a specific value in each component of the colour:
These loops should be located before the call to
glBufferData, inside your rendering loop.