# Beginning Game Programming (phần 7)

## Tham khảo tài liệu 'beginning game programming (phần 7)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 280 Chapter 12 3D Graphics Fundamentals series of for loops. Tell me which one of these two sections of code is faster. Ignore the num part and just assume that something useful is happening inside the loop. for int n 0 n 1000 n num or for int n 0 n 250 n num for int n 0 n 250 n num for int n 0 n 250 n num for int n 0 n 250 n num What do you think It might seem obvious that the first code is faster because there are fewer calls. Someone who is into optimization might think the second code listing is faster because perhaps it avoids a few if statements here and there it s always faster to unroll a loop and put if statements outside of them . Unrolling a Loop What do I mean when I say unrolling a loop This is not directly related to 3D but helpful nonetheless. Take a look at the following two groups of code from a fictional line-drawing function assume x and y have already been defined for x 0 x 639 x if x 2 0 DrawPixel x y BLUE else DrawPixel x y RED and for x 0 x 639 x 2 DrawPixel x y BLUE for x 1 x 639 x 2 DrawPixel x y RED The second snippet of code is probably twice as fast as the first one because the loops have been unrolled and the if statement has been removed. Try to think about optimization issues like this as you work on a game because loops should be coded carefully. The for loop doesn t actually take up any processor time itself it s the code executed by the for loop that is important to consider. A quad is made up of two triangles. The quad requires only four vertices because the triangles will be drawn as a triangle strip. Check out Figure to see the difference between the two types of triangle rendering methods. Introduction to 3D Programming 281 Triangle List Triangle Strip V1 and V3 are shared Figure Triangle List and Triangle Strip rendering methods compared and contrasted Figure A triangle strip can take many forms. Note also that many more than two polygons can be used. Figure shows some other possibilities for triangle .

TÀI LIỆU LIÊN QUAN
64    111    8
50    84    2
50    62    2
50    41    1
50    53    1
50    35    1
50    40    1
50    49    1
50    41    1
14    40    1
TÀI LIỆU XEM NHIỀU
13    36313    2004
3    22705    231
25    21397    4015
16    17907    2706
20    17888    1502
14    16404    2768
1    15868    526
37    14268    2881
3    12989    243
23    11893    435
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
5    21    1    29-03-2023
60    18    1    29-03-2023
5    174    2    29-03-2023
3    20    1    29-03-2023
46    16    1    29-03-2023
3    19    1    29-03-2023
17    7    1    29-03-2023
15    18    1    29-03-2023
104    23    1    29-03-2023
3    6    1    29-03-2023
5    23    2    29-03-2023
112    9    1    29-03-2023
8    13    1    29-03-2023
56    7    1    29-03-2023
5    22    1    29-03-2023
15    6    1    29-03-2023
1    30    1    29-03-2023
14    29    1    29-03-2023
3    7    1    29-03-2023
118    19    1    29-03-2023
TÀI LIỆU HOT
3    22705    231
13    36313    2004
3    1944    78
580    4052    359
62    5300    1
584    2349    92
171    4617    655
2    2181    75
51    3074    165
53    3916    184
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.