I would like to move an object (I have a simple rectangle) and I would like to move it up to a specific position and back (maybe repeat forever).
I know I should have a variable in the matrix translation (gltranslate) but where/how do I make this variable and animate each frame.
It’s hard to be certain what stage you are at but assuming you already have a rectangle drawing on screen:
Wherever you have your ‘drawMyRectangle’ function create these variables:
So fill in those values with translationAlpha starting at 0 and animatingForward at 1.
I recommend doing this next part in a separate function but you will need code that steps your animation, simply
It sounds like you are keeping it simple so just call that every time you draw.
So make sure you have a glPushMatrix and a glPopMatrix surrounding your draw.
after you pushMatrix and before you call your draw add:
That covers a really primitive way to do what you described, also consider this pseudocode because I don’t know what functions you are using and how you are handling your matrices.