JOGL Colors

In JOGL, a figure can be filled out with different type of colors. Coloring just enhances the look and feel of figure.

To specify the type of color, JOGL uses glColor3f() method of GL2 interface. This method follows RGB (Red, Green, Blue) color model. In this model, each color is represented with a value between 0 to 1 where 0 means none of that color and 1 means maximum of that color.

Note - It is required to pass the value of all three colors as a parameter of glColor3f() method.

JOGL Color Code List

Following is the list of codes for some frequently used colors :

ColorRedGreenBlue
Red100
Green010
Blue110
Yellow110
Orange10.50
Purple101
Cyan011

JOGL single coloring Example

This is a simple example where a triangle is filled out with one (green) color only.

JColor.java

Output:

JOGL Colors Output

JOGL mixed Coloring Example

In this example, a triangle is filled out with three different colors.

JMColor.java

Output:

JOGL Mixed Colors Output
Next TopicJOGL Rotation