Color Overview
The color display mode is divided into two types:
- Rgba Display Mode
- 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:
- Void glcolor3 (type R, type G, type B );
- 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.