Đang chuẩn bị liên kết để tải về tài liệu:
Beginning Game Programming (phần 7)

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

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 12.8 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 12.8 Triangle List and Triangle Strip rendering methods compared and contrasted Figure 12.9 A triangle strip can take many forms. Note also that many more than two polygons can be used. Figure 12.9 shows some other possibilities for triangle .

Đã 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.