OpenGL Programming Guide Chapter Fourth: Colors

Source: Internet
Author: User
The color value of a pixel on a computer screen is composed of three components of RGB (or Rgba,a not directly used for color display), the number of colors that can be displayed on a single pixel of different devices, the memory size of the stored color values, and, generally, a bit to measure, 8-bit buffer can display 256 colors. The values of the RGB components can be expressed in a floating-point number without ambiguity, and the range is [0.0,1.0],1.0 indicates that the color of the component is the strongest.

Entity Color OpenGL sets the color of the API is glcolor*, the color is set in vertex units, the color of the entity into the pipeline processing to reach the screen:
1) The color of the vertex also has to be light processing;
2) At this point, based on the color of the element vertex, the selected shading mode (shading model) to color the elements, the inner colors of the elements;
3) The next step is Rasterization (Rasterize, which also transforms the elements into two-dimensional images), This step determines the image window coordinates of each lattice color, depth (z), texture coordinates, such a lattice is a fragment (fragment), texture, fog, antialiasing these effects will be added to the fragment;
5) The color of the final fragment and frame The pixel colors in buffer are mixed (alpha blending,dithering,bitwise logical operation) to form a new pixel color.


RGB color storage format
Display devices typically allocate a certain number of bits per component (not necessarily equal), the component values are stored as unsigned, for example, R has 8 bits, and the stored value is 0. 1...255, then corresponds to the floating-point value 0.0,1/255...1.0, respectively.


dithering
Some realistic devices use dithering technology to increase the number of colors that can be displayed, for example, RGB has only one bit width, so it can only be displayed: black, White,red,blue,green,yellow,cyan,magenta these colors, in order to display a pink area, you can display the red and white pixels at intervals within the area, so that it looks like pink.


color-index mode
This mode uses a color lookup table and color index to represent the color, and the index value is stored in the pixel.


shading Mode
has two shading modes, flat and smooth, which use the color of a vertex to colorize an entire entity, The latter takes into account the color of all vertices to colorize (interpolate) The points inside the elements. In flat mode, select the color of the vertex depending on the element type, please refer to the original book.

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.