The code was:
open_window();
for(i=0;i<100000;i++){
clear_the_window();
draw_frame(i);
wait_until_a_24th_of_a_second_is_over();
}
The book says the problem with this code is: Suppose the drawing takes nearly a full 1/24 second. Items drawn first are visible for the full 1/24 second and present a solid image on the screen; items drawn toward the end are instantly cleared as the program starts on the next frame.
I don't quite understand what does it mean by "first" and "toward the end"开发者_运维知识库? If the three functions within the loop are called sequentially, what is the problem? Unless it is not a sequential program?
Say this span of 10 stps covers 1/24th of a second:
- Clear window
- Item A begin drawing...
- A is drawn completely and visible for almost 1/24th second
- Item B begin drawing ...
- ...
- ... expensive drawing of B ...
- B finished drawing -> wont be shown too long
- Item C begin drawing...
- ...
- finished drawing C -> will last very short as next iteration is immanent
------- NEXT iteration -------
- Clear window
- and so on
精彩评论