From: Sven P. <Sve...@ae...> - 2006-05-13 13:52:10
|
Am Donnerstag, 11. Mai 2006 22:37 schrieb Orion Poplawski: > [...] > I think the initial reshape callback is unexpected by the code and > throws things out of whack. Now, I'm not sure it is reasonable for the > code not to be able to handle multiple calls to the reshape callback, > but there it is. It would however be more efficient if there was only > one call. > > Also, it throws off code like I sent before which tries to enforce > limits on the size of the window and calls glutReshapeWindow() from the > callback. In this case it would get the (300,300) call which would then > set the size back to (300,300). Uncomment the two lines in changeSize() > to see that in action. > > Thoughts? [...] Some remarks: * In general, all changes to the window sizes and positions done in a program are only *requests* for the window manager. It might honor them exactly, modify them or ignore them completely. This is up to the window manager policy, and has nothing to do with GLUT or freeglut. Therefore your program should work with all possible window sizes/positions, as there can't be any guarantees. * In GLUT/freeglut, almost nothing is done immediately. More or less all calls only set some internal state, and those changes are only processed when control has been relinquished to the main loop. When e.g. glutReshapeWindow is called, only the requested size is remembered internally, along with the fact that the window manager should be informed about the request when the main loop has control again. When the latter will actually happen is undefined, there might be other changes waiting etc. * Don't make any assumptions about how often and when callbacks are called, this is again mostly up to the window manager. One of the few things which are guaranteed is that the reshape callback is called at least once before the display callback is called for the resized window (it would not make sense the other way round). * To set the initial window size use (not surprisingly) glutInitWindowSize, and not glutReshapeWindow before the main loop has been entered. This is a border case, so we should check what GLUT does here, but anyway, using glutInitWindowSize is aesthetically nicer and more portable. Cheers, S. |