OpenGL system design-bitmap font (1)

Source: Internet
Author: User

 

Bitmap font

OpenGL is not only a complete 3D rendering interface, but also a very efficient image processing engine. This chapter mainly discusses the functions of OpenGL for processing color pixels and unit graphs.

OpenGL does not directly render the image, because the image is usually stored in a specific format in the file, OpenGL does not know the format of these image files, so it only knows how to render the pixel rectangle, but does not decode the image file. If you have mentioned above, you need to write and decode your own for using TGA, BMP, and jpg files. After the pixel data is parsed, OpenGL can easily render the data.

To support the rendering of pixel rectangles, besides the basic point, line, triangle, polygon and other geometric elements, OpenGL also supports pixel-based data types (pixel-based primitives ). These pixel-based data types contain the color values of each pixel, which can be divided into two types: bitmaps and images ).

A bitmap is an image that contains the information of each pixel. It can be used as a mask to determine the pixel to be overwritten. You can use glcolor to set the current color of the bitmap.

The image contains all the color information of each pixel, such as the rgba value.

After decoding the image file data such as BMP and GIF to obtain the desired color information, OpenGL can raster these color values.

 

As if there is an assembly line for rendering ry, pixel rendering also has an operation pipeline. First, read pixel data from the storage area (like a file) and process it into a format that can be used inside OpenGL. During this period, some color conversion and byte switching operations are involved. Then, fragment operation is used to process the data, raster the pixel data, and render the data to the frame buffer. The entire assembly line is 8-1.

 

 

 

Figure 8-1 pixel rendering pipeline

 

Of course, in addition to rendering the pixel data to the frame buffer, you can also copy it from the frame buffer to the memory, or transform it to the texture ing space for texture textures.

For optimal performance, the internal processing of pixels should match the hardware. For example, for a 24-bit frame buffer, the 8-8-8 RGB format may be the best match, but the 10-10-10 RGB format will certainly have problems. If the non-default format is changed successfully, the speed will be very slow.

 

The position of an image is determined by the position of the grating, which maps the lower left corner of the image to a point in the space. Like a vertex, the position of a grating can be changed and reduced. If the Grating Position fails during the split check, OpenGL will cancel the raster operation.

 

The OpenGL commands used for bitmap rendering mainly include:

Glbitmap

Gldrawpixels

Glreadpixels

Glcopypixels

Glcopytex * Image

Glrasterpos

 

Next we will introduce these common commands.

 

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.