Legacy (immediate mode)GL 1.0

glColor3f

Sets the current color used by the following glVertex calls.

Removed from the core profile. Part of the legacy immediate mode, removed from the core profile in OpenGL 3.2. Shown here only so you can recognize it in old tutorials — use VBOs and VAOs instead.

Signature

void glColor3f(GLfloat red, GLfloat green, GLfloat blue);

How it works

In modern OpenGL, per-vertex color is just another vertex attribute in your buffer, and a constant color is a uniform (glUniform4f).

Parameters

redGLfloat

Red, 0–1.

greenGLfloat

Green, 0–1.

blueGLfloat

Blue, 0–1.

Example

example.cpp
1glColor3f(1.0f, 0.5f, 0.2f);