I don't understand how the function works. It feels like too little time has passed since the clock was updated, and therefore the counter value is always 0.
float time = sfTime_asSeconds( sfClock_restart(clock) ) ;
delta_time = sfClock_getElapsedTime(clock) ;
timer += sfTime_asMicroseconds(delta_time);
But
timer always 0.
Also:
CSFML:
sfTime PreviousTime = sfTime_Zero ;
sfTime CurrentTime = sfClock_getElapsedTime(clock) ;
sfTime FrameTime = CurrentTime - PreviousTime ;
PreviousTime = CurrentTime ;
float DeltaTime = sfTime_asMicroseconds(FrameTime) ;
Error: [bcc32 Error] main.cpp(76): E2093 'operator-' not implemented in type 'sfTime' for arguments of the same type
SFML:
sf::Clock clock;
sf::Time previousTime{ sf::Time::Zero };
const sf::Time currentTime{ clock.getElapsedTime() };
const sf::Time frameTime{ currentTime - previousTime };
previousTime = currentTime;
const float dt{ frameTime.asSeconds() };
Compiles without errors.
What am I doing wrong?Upd.
Works:
sfClock *clock = sfClock_create();
sfTime PreviousTime = sfTime_Zero ;
sfTime CurrentTime = sfClock_getElapsedTime(clock) ;
float DeltaTime = sfTime_asMicroseconds(CurrentTime) - sfTime_asMicroseconds(PreviousTime) ;
PreviousTime = CurrentTime ;
The problem with the timer occurs if 2 clock sources are declared.Not works: sfClock *clock = sfClock_create();
sfClock *clock2 = sfClock_create();
sfTime PreviousTime = sfTime_Zero ;
sfTime CurrentTime = sfClock_getElapsedTime(clock) ;
float DeltaTime = sfTime_asMicroseconds(CurrentTime) - sfTime_asMicroseconds(PreviousTime) ;
PreviousTime = CurrentTime ;
This is a quest. It's a pity there is no description for CSFML.