View Full Version : Window resize
I have a glut program which uses random numbers and everytime I resize the window the numbers are recalculated. How do I stop this? I believe it has something to do with the reshape function, but I'm not sure what.
I don't think this is an OpenGL question but anyway,
I think if I understood correctly, you are producing random number which you would like them to be the same every time your program runs right? I also suppose that you are using C. You should search the help files or google on rand() and srand(). If I remember right srand takes a seed (pseudo-random) so if you give it the same seed every time you will get the same "random" numbers every time. Hope I helped :)
No, quite the opposite.
My OpenGL program runs in a window. Every time it runs I want the random numbers to be random. BUT, if I resize the windows whilst the program is running, I don't want the numbers to change. Not Unless I say so, anyway. I would, however, like the scene to stay the same but stretch or shrink in the necessary dimensions.
At the moment, my entire scene changes, butI don't want that.
Thanks for your help, though.
No trouble, this is what these forums are for. Anyway I think then that maybe you call srand within a reshape (or resize) or display (or render) function? srand should be called only once (say within an initialization function) and then call rand whenever you want a random number. Did I get it this time :) ?
10-14-2004, 04:28 AM
Erm, not sure..
But I fixed it by assigning time(NULL) to an int and calling srand(t); every time I call myDisplay(). Works a treat now.
Thanks for your help!! :D
Dol AI with 3D Bone system
10-14-2004, 05:08 AM
You can use random size of window in WM_CREATE command such as
X := 0;
Y := 0;
Width := Random(1024-1);
Height := Random(768-1);
MyReshape(X, Y, Width, Height);
the Width and Height is process in one scene only.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.