beginning opengl game programming 2004 phần 8

Tham khảo tài liệu 'beginning opengl game programming 2004 phần 8', 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ả | 228 Chapter 10 Up Your Performance Now that you understand the reasons for using vertex arrays it s time to learn how they are used. Array-Based Data So far we ve been using relatively simple objects in our demos and thus we ve been able to describe them explicitly in the code. In a real game however you ll be working with models containing hundreds or even thousands of polygons and describing such complicated models directly in the code just isn t practical even if you manage to create decent-looking results it s going to be a nightmare to maintain. Instead one of the following two approaches is usually taken Load the model from a file. Dozens of great modeling packages enable you to create a model visually and then export the geometric data to a file which can be read by your program. This approach offers the greatest flexibility. Model loading will be discussed in much greater detail later in the book. Generate the model procedurally. Some things you want to represent can be implicitly described with equations due to patterns they contain or because they possess some random properties that you can generate on the fly. A good example of this is fractals. Geometric data for fractals can be created by a procedure that produces the same values every frame. Whichever approach is used it should be fairly obvious that you don t want to repeat all the work every frame you certainly don t want to be constantly reading a model from disk and even procedural methods can have enough overhead to have an adverse effect on performance. Instead you ll take the geometric data these methods generate and store it in arrays which you can then access as needed. This process can be summarized in the following steps 1. Generate the data you need either procedurally or from a model file on disk. 2. Save this data in an array or set of arrays for example you could put the position of each vertex in one array the vertex normal in another color in another and so on . With your data stored

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.