how execute instructions when there is no events/no key pressed ?

hi !
i have a problem, i would like to execute instructions when no key are pressed.
What library can i use with open gl and what instruction make it ?
i have tried to use glutIdleFunc () but i don’t find where put this function.
i have done this with it but it works only when i press a key and not when no key are pressed : (thanks for your help)

void keyboard (unsigned char key, int x, int y)
{
	switch (key) 
	{
	case 'r' : 
	case 'R' :
	nb_transformation++ ; 
	r = 5.0; 
		glutPostRedisplay () ; //réexécute la fonction display
		break ;
	default :
		glutIdleFunc(withoutEvents) ;
		break ;
	}
}

On glutIdleFunc, you don’t call it from the keyboard unless you are turning it on/off.

The glutIdleFunc is called with there is no glut event’s like keyboard, repostdisplay, etc.

I put the glutIdleFunc in the main function, see examples on my website: www.angelfire.com/linux/nexusone/

alternative way in the keyboard:

case ‘a’:
case ‘A’:
if ( animation ) // if animation ON, turn it off
{
glutIdleFunc(); // stop Idle func
animation = 0;
}else{
glutIdleFunc(my_idlefunc); // Start Idle function
animation = 1; animation ON
}
break;

Originally posted by airseb:
[b]hi !
i have a problem, i would like to execute instructions when no key are pressed.
What library can i use with open gl and what instruction make it ?
i have tried to use glutIdleFunc () but i don’t find where put this function.
i have done this with it but it works only when i press a key and not when no key are pressed : (thanks for your help)

[quote]

void keyboard (unsigned char key, int x, int y)
{
	switch (key) 
	{
	case 'r' : 
	case 'R' :
	nb_transformation++ ; 
	r = 5.0; 
		glutPostRedisplay () ; //réexécute la fonction display
		break ;
	default :
		glutIdleFunc(withoutEvents) ;
		break ;
	}
}

[/b][/QUOTE]

The idle loop is there exactly for what you want to do. Basically when the rest of your program is doing nothing, then control is passed to the function you specify in the
glutIdleFunc() call.

Set it up in your main() after the various initialisations.

myIdle()
{
x++;
y++;
… or whatever you want to do …
}

int main(…)
{
… init codes …
glutIdleFunc(myIdle);
glutMainLoop();
return 0;
}

To stop the idle function running, simply call glutIdleFunc(NULL) at some time, e.g. in a keyboard function as per the above example!

Hope this helps,

Rob