Computer Graphics (ii) output primitive _14_opengl pixel Array function _1_ bitmap function

Source: Internet
Author: User

OpenGL pixel Array functionOpenGL has two functions that can be used to define the shape or pattern of a rectangular pattern. One is a bitmap and the other is a pixel graph. OpenGL also provides several functions for storing, copying, and managing pixel-valued arrays.
OpenGL bitmap Functions
The following function defines a two-valued array:
Glbitmap (width, height, x0, y0, Xoffset, Yoffset, Bitshape);
The parameter width and height in the function give the empty array column bitshape column number and row number respectively. each element of the Bitshape is assigned a value of 0 or 1. A value of 1 indicates that the corresponding pixel is displayed in the previously set color, otherwise the corresponding pixel is not affected by the bitmap. (as an option, you canuse 1 to combine the specified color with the color value stored in the corresponding location in the refresh cache. ) parameters x0 and y0 define the rectangular arrayThe location of the column "origin". The origin location is specified as the lower-left corner of the bitshape, while X0 and y0 can be positive. In addition, you need to specify the framethe location where the pattern is applied in the cache. The position is called when the front raster position (current raster position), and the bitmap is placed at the origin.appears after the current raster position. The values assigned to Xoffset and Yoffset are used as bitmap displays to update the coordinates of the current raster position of the frame cachedisplacement.
x0, y0, Xoffset, Yoffset, and the coordinate values of the current raster position are formatted using floating-point numbers. Bitmaps of course use integer pixelslocation. However, the coordinates of a floating-point number allow a set of bitmaps to be arranged at arbitrary intervals, which in some applications, such as the use of bitmap characters to form a stringvery useful.
You can use the following subroutine to set the current raster position:
Glrasterpos* ()
The parameters and suffix codes are the same as in the Glvertex function. Therefore, the current raster position is given in the world coordinate system, and the observed transformation will Its transformation to the screen coordinate system. in our two-dimensional example, you can specify the coordinates of the current raster position directly using the integer screen coordinates. The default value for the current raster position is the origin in the World coordinate system (0, 0, 0).
the color of the bitmap uses the valid color when Glrasterpos is referenced. Any subsequent color changes will not affect the bitmap.
each row in a rectangular array is organized in 8-bit units, which is arranged into a set of 8-bit unsigned characters. But we can use anya convenient grid size to describe the shape. As an example, figure 3.61 shows a grid of 10 rows and 9 columns to define the bit array .At this time each exercise is described by 16 bits. When the pattern is applied to a frame cache pixel, all the bit values after the 9th columnis ignored.


Use the following program segment to apply the bit patterns in figure 3.61 to the frame cache:
Glubyte Bitshape [] = {  0x1c, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x1c, 0x00,  0xFF, 0x80, 0x7f, 0x00, 0x3e , 0x00, 0x1c, 0x00, 0x08, 0x00};glpixelstorei (gl_unpack_alignment, 1);//set pixel storage made.glrasterpos2i (+); GlB Itmap (9, ten, 0.0, 20.0, 15.0, bitshape);
The array values of the Bitshape are specified line by row, starting at the bottom of the rectangular grid. Then use the OpenGL function Glpixelstorei to set the location map storage mode . The function uses a parameter value of 1 to indicate that the data value is aligned with the byte boundary. Glrasterpos used to set the current raster position for (30, 40). Finally, the function Glbitmap refers to the positioning array given in the array bitshape, and the array has 9 columns and 10 rows. the array's origin coordinates are at (0.0, 0.0), which is the lower-left corner of the grid. We give a coordinate displacement of (20.0, 15.0), although in this case the displacement is not used.

Computer Graphics (ii) output primitive _14_opengl pixel Array function _1_ bitmap function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.