The way your code is writen only when a window event, ie re-size, move, etc. will the window be updated.
Say you want the screen to update after a mouse move or keyboard. Use glutPostRedisplay, at the end of that routine.
My_mouse_event(int button, int x, int y)
Check mouse position, move if needed.
glutPostRedisplay(); // Redraw screen with new mouse data.
For game timming and idle time, I like to use glutTimerEvent( time in ms, func * , int)
Insert before glutMainLoop
glutTimerEvent( 10, My_timer_event, 1)
update_objects /// code to update your objects
glutPostRedisplay(); // Redraw screen with new object data.
glutTimerEvent( 10, My_timer_event, 1)// timer is a one shoot must be reset after being called. By using a timed event, your application should run about the same speed on any machine.
You can use glutIdelFunc but it will not any idea of how fast the updates will be. So on a fast machine vs. a slow machine will get diffrent rates of updates. I prefer the gluttimerevent.
Originally posted by method5:
[b]ok as some of you know… im trying to make an pixel by pixel scrolling rpg engine… i just put the keyboard controls in and for some reason glutDisplayFunc is not updating… i have to minimize the opengl window and maximize again for it too change to reflect the characters position on the screen… why isnt is updating… once you call the mainloop function thing shouldnt it automatically be called every few miliseconds or so…?
my init code…
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
so shouldnt the display code keep refreshing?? or am i missing something to get it autorefreshed…[/b]
[This message has been edited by nexusone (edited 03-25-2002).]