OpenGL & Color

Source: Internet
Author: User
Color Overview

The color display mode is divided into two types:

  1. Rgba Display Mode
  2. Color index display mode (using the color ing table, the ing table provides indexes that can be mixed with basic red, green, and Blue values ). In rgba mode, you can select more colors than the color index mode. Generally, the rgba mode is recommended, while the color index mode is mainly used in texture textures and lighting, coloring, fog and anti-aliasing.
OpenGL specifies the color and coloring model

The following pseudocode is available:

setColor(RED)drawItem(A)
In this way, a is red.

In rgba mode, you can use glcolor * () to select the current color:

  1. Void glcolor3 (type R, type G, type B );
  2. Void glcolor4 (type R, type B, type B, type );

In color index mode, you can use glindex * (type C) to specify the color.

''' Cppgluinitdisplaymode (GLUTSingle | glutRGB );

Glclearcolor (0.0, 0.0, 0.0, 0.0); glshademodel (gl_smooth );

Void twoddispaly: colordisplay () {glclear (GLColorBufferBit); glbegin (GLTriangles); glcolor3f (1.0, 0.0, 0.0); glvertex2f (5.0, 5.0); glcolor3f (0.0, 1.0, 0.0); glvertex2f (25.0, 5.0); glcolor3f (0.0, 0.0, 1.0); glvertex2f (5.0, 25.0); glend (); glflush ();}

'''

Glshademodel (GLSmooth); specifies the coloring model, where GLSmooth indicates that multiple colors can be used for painting, while gl_flat can only be used in monochrome.

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.