I am confused about the argument "m" of this function.

I also need to know how to make this work. I am working on a simple 2d game and I am really new to programming. I don't know how to make things work in this Timer() function. I want to animate an object in a specific direction. I know the coordinates of the direction but after a lot of hit and trial, my object moves in a random direction. I have used sin and cos for the movement. But my real problem is about the functionality of this Timer() function. Can anyone here help me about it? Any help will be appreciated.

float dt = 0, lastframe = 0;

void Timer(int m) {
dt = (m - lastframe) / 1000.0;
lastframe = m;

glutPostRedisplay();
glutTimerFunc(1000.0 / FPS, Timer, m + 1);
}

• Are you sure that you copied the code correctly? If yes, does that eve work? Because the function Timer is being called in the last line without any parameters passed, and considering that the function Timer does not have a default value, it should throw you an error. Besides, knowing what the functions glutPostRedisplay and glutTimerFunc are supposed to do would help. It looks like m is trying to count the number of frames elapsed, but I can't be sure before you reply with further details. – MAnd Nov 30 '15 at 8:54
• @MAnd For free functions, Timer is the same as &Timer, that is, forming a function pointer. The intent and effect here is to once the callback completes, re-register itself for the next tick. – Lars Viklund Nov 30 '15 at 9:36
• Yes i have copied the code correctly and it works but after every click, the speed of my object incresases. glutPostRedisplay() actually calls the Display function to redraw the whole canvas i.e update the display. glutTimerFunc is something which i don't know about myself. I think i should read up more on this matter. Can you tell me what does a tick mean? – Abdul Mateen Nov 30 '15 at 10:26