Sign in to follow this  
CosmoKramer

update() vs display() with glut

Recommended Posts

You always hear about update() and display() functions in games. Ive always just updated in my display() function, so that you update right before you display, and no more. I never saw the point in updating the game world if your not going to display it anyway, so why separate the two ? Anyway, my friend told me its better to separate them (I still have no idea why), but even if this is the case, how can I do it using GLUT? Glut has a display callback function, but no update callback function. One might consider using the idle callback function for updating, but if you read the official description of that function, you will realize that it is not really the correct thing to do.

Share this post


Link to post
Share on other sites
Quote:
Original post by CosmoKramer
I never saw the point in updating the game world if your not going to display it anyway, so why separate the two ?

Think the other way round - you might want to display() more often than you actually update() (e.g. using interpolated values).

Share this post


Link to post
Share on other sites
Oh. That seems like it would be complicated to do, not to mention inaccurate. Wouldnt interpolating take just about as much time as updating, in which case you might as well just update anyway?

Assuming youre talking about interpolating the display between 2 updates, how can you do that if you dont know what the world stat will be at the next update, or even when the next update will be? I think that just confused me more.

Anyway that stuffs not too important to me right now, I dont want my thread to get too side tracked.

My question remains: How can you separate the update and display functions in GLUT, when there is no appropriate callback function for update?

Share this post


Link to post
Share on other sites
Well it depends on your application with whether or not you should do this. If you have a game for example you would want to update the screen in regular intervals (of say 30 updates per second). The display callback will only be called if the windowing system causes an update-display event, which happens if you move the screen, resize etc.

Quote:
Original post by CosmoKramer how can I do it using GLUT?


Use the timer function callback, just make sure you re-call it at the end of your update function.
void glutTimerFunc(unsigned int msecs,void (*func)(int value), value);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this