Display lists and contexts

Started by
4 comments, last by variant 20 years, 10 months ago
I am working on a base class method that will start up a gl window. Everything is working fine, except when I run two instances of it. I am creating a display list of an object based on random numbers, and rotating it. Both windows show the same object. I checked the rendering context before creating the list and they are two distinct contexts. The appropriate context is set before the display loop is called. The display list numbers are the same however. Is that what is supposed to happen? Any ideas? Thanks!
Advertisement
Well, I figured out what was going on, but it is rather strange. Before starting the display loop I set the appropriate context, initialize OpenGL, seed the random number generator with the time, then create my display list. Apparently, the random numbers for both instances were the exact same. I didn''t think this should happen since I am seeding with the time:

srand(time(NULL));

Seeding the generator just once solved the problem. I suppose the seed must have been the same for each initialization, but since its done with time(), I would not expect that. Any one more familiar with the workings of these functions?
How close together are these seed calls? The time() call only has a granularity of 1 second, IIRC.
That''s what the problem was. I was performing one initialization, then reseeding the generator within the same second. I should probable use timeGetTime().

The elasped time is probably insignificant. Anyways, excepting a very few select circumstances, you should only ever call srand once per application.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
True true.

This topic is closed to new replies.

Advertisement