We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Im trying to understand how draw works at a closer level. My comp sci teacher told us it runs 60 times a second. Does it run everything inside draw at the exact same instant, then do it again the next 60th of a second? Or does it run it all one by one, and then what does it do when if it hits the last command and 1/60th of a second hasn't gone by yet? Or if it can't run all of the commands with that much time, then is that what makes framerate lag? And why does my millis() timer always have a different result everytime I run it?
Thank you for any help
Answers
So it does run all of the commands one by one? And what does it do if it can't finish all of the triggers before 16 ms? Also, why is it 'approx.' 16 ms, instead of exactly?
I like to think frameRate as setting a top limit in how often draw() gets called. You can try to increase this number to 200 or even 1000. Now, if you load a movie, a movie usually plays 30fps so is there a point to run faster than 30fps?
Now, remember this is a top limit, but it is not guaranteed. You can have a while loop inside draw()blocking its normal execution times or even blocking it. Check the code below for a demo of the frameRate as calculated by Processing.
Kf
It means the 60 FPS rate has failed for that frame. The sketch will suffer slowdown.
60 FPS = 1000/60 = 16.6...
you can write a draw that needs minutes or days to run when it's calculating stuff.
but a normal sketch with 10 or 100 rectangles or whatever will run more or less at 60 FPS.
But all commands are added up on an internal canvas and only displayed at the END.
So during run you can't see any changes, only at the end.
Read the reference. Millis is the total time taken from the start of the program, not just the time taken for that frame.
@john832 excuse me seriously what are these question?
No idea
Fair, but why?
It does
How would that even be possible? :S
Of course
Nothing
Yes
Your clock hasn't stopped