Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Hericage

Pages: [1]
1
System / Clock getting paused by Sleep()
« on: April 10, 2009, 02:16:49 am »
Couldn't find any information about this so I figuered i'd had to ask :)

We're currently working on a game projekt and we've done some prototyping in SFML.. From what we can see a sf::Clock will return incorrect values if used along with a sleep.

example1:
Code: [Select]

sf::Clock Clock;
while(true)
{
    //do some stuff, break after 60 seconds
    Sleep(1);
}
std::cout << Clock.GetElapsedTime() << std::endl;

we tested with a stop watch and broke the loop manually after 60 seconds, the Clock.GetElapsedTime() would return a value of ~35 seconds.

example2:
Code: [Select]

sf::Clock Clock;
while(true)
{
    //do some stuff, break after 60 seconds
    //Sleep(1);
}
std::cout << Clock.GetElapsedTime() << std::endl;

with the sleep out of the way, and the programm still running for 60 seconds, it returned a far more precise value.

Is there something we're doing wrong or is this a bug?

to work around it we're using floats in wich we add all the sleep values and then add the Clocks time.

edit: I'm using windows XP btw.

Pages: [1]