Archived

This topic is now archived and is closed to further replies.

Show me an example (GLUT question)

This topic is 6031 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have like 30 megs of documentation on OpenGL saved, and i cant find a single example of a working glutTimerFunc, i get to really weird errors whenever i try and use it, so can someone please direct me to an example.

Share this post


Link to post
Share on other sites
ok, i add this line for the callback

glutTimerFunc(10,time_loop);

and this function

void time_loop(void)
{
glutPostRedisplay();
}

and i get these errors

Cannot convert ''void(*)()'' to ''Void(*)(int)

type mismatch in paramater 2 (wanted void(*)(int) got Void(*)())

to few parameter calls in function glutTimerFunc(int,void(*)(int),int)

all i need is an example of a working glutTimerFunc so i can see what the proper syntax is.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The prototype
void glutTimerFunc(unsigned int msecs, void (*func)(int value), value);
shows that you for some reasons has to give a value to pass. Your code would be something like

the callback:
glutTimerFunc(10, time_loop, 3 /* stupid value to pass to func. */);

I think that each timer callback registration is good for only _one_ function call.

and the function:
void time_loop(int passed_value)
{
glutPostRedisplay();
glutTimerFunc(10, time_loop, 1); /* if you want repetated calls */
}

A perhaps easier alternative is to use a idle function and glutGet(GLUT_ELAPSED_TIME) to determine if a glutPostRedisplay call should be done. Here is some information http://www.fatech.com/tech/opengl/glut/index.php3?fps

Share this post


Link to post
Share on other sites
I am useing the idle function at the moment, but i am afraid of animation problems from the wide variety of video cards out now, if i set my animation up with a glutIdleFunc, will the program run the same on a 16Meg Voodoo3, and a 64Meg Geforce2?

Share this post


Link to post
Share on other sites