开发者

A question from the "red book"

开发者 https://www.devze.com 2023-02-13 10:06 出处:网络
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 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:

  1. Clear window
  2. Item A begin drawing...
  3. A is drawn completely and visible for almost 1/24th second
  4. Item B begin drawing ...
  5. ...
  6. ... expensive drawing of B ...
  7. B finished drawing -> wont be shown too long
  8. Item C begin drawing...
  9. ...
  10. finished drawing C -> will last very short as next iteration is immanent

------- NEXT iteration -------

  1. Clear window
  2. and so on
0

精彩评论

暂无评论...
验证码 换一张
取 消