Deep understanding of OpenGL-frame caching

Source: Internet
Author: User

OpenGL is an API used for voice graphics. Therefore, OpenGL's primary goal is to transform the data provided by an application into something that can be viewed on the display screen. This process is usually referencedRendering (Rendering). Generally, this process is accelerated by specially designed hardware, but some or all operations of the OpenGL assembly line can be executed by a software running on the CPU. OpenGL is transparent (not required) to implement division of labor between hardware and software ). It is important that the drawn results follow the results defined in the OpenGL detailed instruction.

 

Hardware dedicated to Drawing Images and maintaining display content is often calledGraphics Accelerator. The graphics accelerator generally has a memory area dedicated to maintaining the display content. Each visible image element (pixel) of the monitor is represented in several bytes on the Graphics Accelerator. A color display may correspond to one byte for each Red, green, and blue to indicate the color value of each pixel. This so-called Display memory needs to be scanned (refreshed) several times per second, in order to maintain non-blinking screen display on the display. Image accelerators are also calledOff-screen memory areaThe storage area cannot be used to display and store invisible things.

 

OpenGL assumes that the distribution of display storage and off-screen storage is handled by the window system. The window system determines how the part of the memory can be accessed by OpenGL and structured. In each environment supported by OpenGL, a group of function calls bind opencl to a specific environment. In Microsoft Windows, this group of routines is called WGL. In the X Window System Environment, this group of routines is called Glx. In Apple's Macintosh environment, this set of routines is called nsopengl (cocoa window/view), CGL (core GL), or AGL (carbon window ). In each environment, this group of calls support such as allocating, releasing graphics processor storage, allocating, and releasing so-calledGraphic Context(Used to maintain the OpenGL status), select the current graphics context, and select the graphic storage area (in this area, used for drawing and synchronizing commands between OpenGL and window systems.

 

The graphic memory area to be modified as the OpenGL drawing result is calledFrame cache (framebuffer). In a window system, the OpenGL concept of a default frame cache corresponds to a window. Tools in Windows System-specific OpenGL routines allow users to select the default frame cache feature for the window. The window system also needs to clarify the default frame caching behavior of OpenGL when multiple windows are stacked. In a non-window system, the default frame cache of OpenGL corresponds to the entire display.

 

A window that supports OpenGL (that is, a default frame cache) can be composed of the following combinations:

* Cache of up to four colors

* A deep Cache

* One template Cache

* One multi-sample (msaa) Cache

* One or more secondary caches

 

Most graphics hardware supports both a front-end cache and a back-end cache.Double Buffering. This allows the application to display (visible) the front-end cache while drawing (off-screen) the back-end cache. When the painting is complete, the two caches are exchanged, so that the cache after the painting can be displayed as the foreground cache, and the original foreground cache can be drawn as the new background cache. When the dual cache is used, the end user will not be able to see the drawing, but can only see the completed image. This technology allows smooth animation of interactive frame rates.

 

By caching a color to the left eye and a right eye, a three-dimensional view is supported. Dual cache can be supported by a front-end cache and a back-end cache. A dual-buffered three-dimensional window will have four color caches: front left, front right, back left, back right. A normal (non-Three-dimensional) Double-buffered window will have a front-end cache and a back-end cache. A buffered window will only have one front-end cache.

 

If a 3D object is drawn along with a hidden surface removal,Deep Cache. This cache stores the depth of each pixel of the displayed object. When you want to draw additional objects, you need to make a depth comparison for each pixel to determine whether it is visible or blocked.

 

The template cache is used for Complex Blocking operations. A complex shape can be stored in the template cache, and subsequent painting operations can determine whether to update each pixel Based on the Content cached by the template.

 

Normally, when drawing an object, you can make a simple judgment on whether the graphic element affects a pixel on the screen.Multi-sample CacheAll objects drawn to the cache are allowed to be sampled multiple times within each object to achieve high-quality full-screen anti-aliasing without the need to draw the frame more than once. Each sample in one pixel contains color, depth, and template information, and the number of samples in each pixel can be queried. When a window contains a multi-sample cache, it does not contain an independent depth or template cache. When an object is drawn, a color sample is linked to generate a single color value, which is passed continuously and written to the color cache. Because the multi-sample cache contains multiple samples of color, depth, and template (usually 2, 4, 8, or 16), each pixel in the window. They can use up a large amount of off-screen image storage.

 

Secondary CacheIs the off-screen storage buffer, which can store any data, such as the intermediate results of a multiple-time rendering algorithm. A frame cache can have secondary caches of 1, 2, 3, 4, or more multi-phase associations.

 

Besides the default frame cache, OpenGL provides the frame cache object. These are the frame caches created by the application and are more flexible than the default frame caches of the window system. Frame cache objects can be cached in several different formats, including normalized formats (numbers stored in the range of 0.0 to 1.0 ), signed and normalized formats (numbers in the range of-1.0 to 1.0), signed and unsigned integer, and floating-point numbers.

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.