beginning opengl game programming 2004 phần 5

OpenGL (tiếng Anh Open Graphics Library) là một tiêu chuẩn kỹ thuật đồ họa có mục đích định ra một giao diện lập trình ứng dụng (tiếng Anh: API) đồ họa 3 chiều. OpenGL cũng có thể được dùng trong các ứng dụng đồ họa 2 chiều. | CHARTER 6 Ị Bitmaps an D Images I with OpenGL Ể Now it s time to break off from the world of 3D graphics and take a look at the world of raster graphics which are graphics in which an image is composed of an array of pixels arranged in rows and columns. In this chapter you ll be looking specifically at how you can use OpenGL to perform various functions on bitmaps and images. We ll also be discussing how to load and save the Targa .tga image file format. In this chapter you will discover How to use OpenGL bitmaps OpenGL pixel functions How to load and save the Targa image format The OpenGL Bitmap The term bitmap in the context of OpenGL is defined as a rectangular array of pixels where one bit of information a 0 or 1 is stored about each pixel. Bitmaps are composed of a mask encapsulated in a two-dimensional array representing a rectangular area of the window. You can use them for rendering font characters 2D objects in a game or as elements in a GUI. For instance take a 16 X 16 bitmap and divide it into a 16 X 16 grid as shown in Figure . When you draw this bitmap every bit in the two-dimensional array that is set to 1 corresponds to a pixel in the current raster color on the screen. If the bit is 133 TLFeBOOK 134 Chapter 6 Bitmaps and Images with OpenGL not set then nothing is drawn. Given this behavior the 16 X 16 bitmap shown in Figure will be drawn by OpenGL as the letter X. You will see an example in this chapter that does something similar. Actually specifying the bitmap data is slightly different than that shown in Figure . Bitmap data is always stored in 8-bit multiple chunks although the width of the actual bitmap does not need to be a multiple of 8. OpenGL draws the bitmap by starting at the lower-left corner and working its way up row by row. Therefore you need to specify your bitmap s data in this order so Figure 6 1 A 16 X 16 bitmap that the bottom of the bitmap is the first set of data and divided into a grid of zeroes and ones. the top of

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
13    351    1    16-05-2024
114    75    2    16-05-2024
164    76    2    16-05-2024
Đã 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.