1. OpenGL development Environment Construction Reference http://brothergrup.iteye.com/blog/1602471
2. Fill the color of the triangle:
The Fill color function for Glcolor (3/4) * (R,G,B) 3 or 4 means that the numeric type rgb/rgba;* represents Rgba (B,i.) will eventually be mapped to [0-1].
How to map is to take the value of the Write/current type maximum value such as Byte is -128~127 glcolor3b (1,0,0) equivalent to glcolor3f (1/127f,0,0) less than 0 when 0 processing
void Renderscene (void)
{
........
Each vertex is assigned a value of red
glvertex3f ( -0.5,-0.5,0.0);
GLCOLOR3B (127,0,0);
glvertex3f (0.5,0.0,0.0);
GLCOLOR3B (127,0,0);
glvertex3f (0.0,0.5,0.0);
GLCOLOR3B (127,0,0);
..........
}
3. Draw Quadrilateral
Note Four vertices are drawn in order, clockwise or counterclockwise when you select Quad mode.
void Renderscene (void)
{
Glbegin (gl_quads); Quadrilateral Pattern Drawing
glvertex3f ( -0.5,-0.5,0.0);
glcolor3f (1.0,0,0);
glvertex3f (0.5,-0.5,0.0);
glcolor3f (1.0,0,0);
glvertex3f (0.5,0.5,0.0);
glcolor3f (1.0,0,0);
glvertex3f ( -0.5,0.5,0.0);
glcolor3f (1.0,0,0);
Glend ();
}
If the order of 3,4 vertices is reversed, chaos occurs.
(2) Draw quadrilateral when drawing mode is triangular
Next article about drawing polygons using an indexed method
Original Basic OpenGL Tutorial (i) Polygon drawing