Hi everyone,
I have a problem to understand an error I made in tutorial 17. In Frametimer.cpp in the mark-function there is a line "last = steady_clock::now();" I know that "last" is a member variable declared by us but I accidentally wrote an "auto" in front off it, that caused a huge acceleration. Investigating it further by writting "steady_clock::time_point" instead of "auto" the acceleration remaind... What is happening there?
Thanks already
hannes
Beginner Tutorial 17 Framertimer
Re: Beginner Tutorial 17 Framertimer
What's happening is that you're creating another variable called last which is local to the mark function
At the beginning of the function you also create a variable old and set its value to the member variable last.
The value of the member variable never changes though since, as we established you're making a new local variable when you're going:
auto last = steady_clock::now();
This leads to an acceleration because when you're calculating the frame time you're doing
last - old
last in this case refers to the local variable which stores the current time
old in this case has the same value as the member variable last, which never changes
causing the delta time to grow larger
At the beginning of the function you also create a variable old and set its value to the member variable last.
The value of the member variable never changes though since, as we established you're making a new local variable when you're going:
auto last = steady_clock::now();
This leads to an acceleration because when you're calculating the frame time you're doing
last - old
last in this case refers to the local variable which stores the current time
old in this case has the same value as the member variable last, which never changes
causing the delta time to grow larger
-
- Posts: 3
- Joined: August 11th, 2019, 8:37 pm
Re: Beginner Tutorial 17 Framertimer
Thanks a lot, the explanation was very helpful. Sorry for answering late. I have been working mostly with Matlab there you have to declare less stuff and things are more seperated. Thanks to all the people working on the tutorials and in the forum, it is great !!!