Problem with the chrono library
Problem with the chrono library
I have a problem, when I use the chrono library to measure the time between two time points, the time duration, in seconds, is around 2.85100009e-06 which is 0.000003
This number is too low, so to move my box around the screen, I have to set the velocity to 1,000,000 which should be too big.
I have cleaned my solution, as chili instructed, using this: http://wiki.planetchili.net/index.php?t ... ili_Forums
This number is too low, so to move my box around the screen, I have to set the velocity to 1,000,000 which should be too big.
I have cleaned my solution, as chili instructed, using this: http://wiki.planetchili.net/index.php?t ... ili_Forums
- Attachments
-
- Chili Framework 2016.rar
- Solution file
- (87.44 KiB) Downloaded 115 times
Last edited by Ariphael on February 12th, 2017, 5:21 am, edited 1 time in total.
Re: Problem with the chrono library
The repository is empty.. ?
Curiosity killed the cat, satisfaction brought him back
Re: Problem with the chrono library
Ariphael, looks like you had a problem creating / uploading the git repo. Either try again, or clean/zip the solution folder and upload it here.
Chili
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Problem with the chrono library
This type of thing has happened to me a few times because I'm not paying attention. Make sure you are resetting the clock at the beginning of the frame where the clock is stopped first then started. This way, the elapsed time measures the entire frame including all the updates and drawing.
If you are not accounting for the time it takes to draw all the pixels, then it won't be accurate since the update portion will probably take less time than drawing the hundreds of thousands of pixels, not to mention the half million pixel copies from the system memory to the gpu memory ( this usually only takes about 1 millisecond on my slow machine, but because of vsync it takes up whatever is left of 16).
If that's not the issue, then yeah, you'll need to try again to share your code with the class.
If you are not accounting for the time it takes to draw all the pixels, then it won't be accurate since the update portion will probably take less time than drawing the hundreds of thousands of pixels, not to mention the half million pixel copies from the system memory to the gpu memory ( this usually only takes about 1 millisecond on my slow machine, but because of vsync it takes up whatever is left of 16).
If that's not the issue, then yeah, you'll need to try again to share your code with the class.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Problem with the chrono library
chili wrote:Ariphael, looks like you had a problem creating / uploading the git repo. Either try again, or clean/zip the solution folder and upload it here.
ok i have attached the solution in a zip file, download that.MrGodin wrote:The repository is empty.. ?
Re: Problem with the chrono library
oops, i put the timer.mark() in the wrong function, but that does not fix anything.
Re: Problem with the chrono library
Looks like you cleaned it properly
I will take a look at this in a bit and get back to you bro.
I will take a look at this in a bit and get back to you bro.
Chili
Re: Problem with the chrono library
i accidently put timer.mark() in DrawBox function, i was supposed to put it in composeframe, but the time interval is still so small.chili wrote:Looks like you cleaned it properly
I will take a look at this in a bit and get back to you bro.
So I put it in ComposeFrame, and now the time interval is ~2e-5 which is one digit bigger, so then I could lower the velocity to 100,000 instead of 1,000,000.
I do not understand what is happening.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Problem with the chrono library
Ok, like I said, you need to have the measured time cover the entire frame. Currently, you are only measuring the controls and drawing the box, you still aren't taking into account the gfx.BeginFrame and gfx.EndFrame()
You need to do something like this
Elapsed = timer.Mark();
timer.Point();
So that, at the beginning of the new frame, you update your elapsed time and restart the clock.
You need to do something like this
Elapsed = timer.Mark();
timer.Point();
So that, at the beginning of the new frame, you update your elapsed time and restart the clock.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Problem with the chrono library
Ok, so I put that in the Game::Go() function and now it works, thanks; I had to consider gfx.BeginFrame() and gfx.EndFrame(), the entire frame.albinopapa wrote:Ok, like I said, you need to have the measured time cover the entire frame. Currently, you are only measuring the controls and drawing the box, you still aren't taking into account the gfx.BeginFrame and gfx.EndFrame()
You need to do something like this
Elapsed = timer.Mark();
timer.Point();
So that, at the beginning of the new frame, you update your elapsed time and restart the clock.