Código de colores OpenGl Graficos 2D y 3D

Código de colores OpenGl (Open Graphics Library) es una especificación estándar que define una API multilenguaje y multiplataforma sirve para escribir aplicaciones que producen gráficos 2D y 3D  También es utilizada en la creación de videojuegos, compite con Direct3D.

Colores OpenGl Graficos 2D y 3D

Para color de fondo:

gl.glClearColor (flotante rojo, flotante verde, flotante azul, flotante alfa)
glClearColor (0.0,0.0,1.0,0.0); // azul oscuro
Para color de relleno
glColor4f(1.0f, 0.0f, 0.0f, 0.0f);//red
glColor4f(1.0f, 1.0f, 1.0f, 0.0f);//white
glColor4f(1.0f, 1.0f, 0.0f, 0.0f);//yellow
glColor4f(1.0f, 0.0f, 1.0f, 0.0f);//purple
glColor4f(0.0f, 1.0f, 1.0f, 1.0f);//light blue
glColor4f(1.0f, 0.5f, 0.0f, 0.0f);//orange/brown
glColor3f(0.0f, 1.0f, 0.0f);//Green
glColor3f(0.0f, 0.0f, 1.0f);//Blue
glColor3f(0.5f, 1.0f, 1.0f);//cyan
glColor3f(0.0f, 0.0f, 0.0f);//Black
glColor3f(1.0f, 0.0f, 1.0f);//Purple
glColor3f(1.0f, 0.5f, 0.0f);//Orange
glColor3f(0.5f, 0.5f, 0.5f);//Violet
glColor3f(0.0f, 0.5f, 0.5f);//Blue-Green
glColor3f(0.0f, 0.5f, 1.0f);//baby Blue
glColor3f(2.0f, 0.5f, 1.0f);//Lilac
glColor3f(0.1f, 0.1f, 0.1f);//Dark grey
glColor3f(0.1f, 0.0f, 0.1f);//Dark Purple
glColor3f(0.1f, 0.1f, 0.0f);//Bronze
glColor3f(0.0f, 0.1f, 0.1f);//Dark blue
glColor3f(0.0f, 0.1f, 0.0f);//Forest Green
glColor3f(0.1f, 0.0f, 0.0f);//Brown

Ejemplo de un cubo 3D Código de colores OpenGl

Código de colores OpenGl Graficos 2D y 3D

glBegin(GL_POLYGON);

glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( 0.5, -0.5, -0.5 ); // P1 es rojo
glColor3f( 0.0, 1.0, 0.0 ); glVertex3f( 0.5, 0.5, -0.5 ); // P2 es verde
glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( -0.5, 0.5, -0.5 ); // P3 es azul
glColor3f( 1.0, 0.0, 1.0 ); glVertex3f( -0.5, -0.5, -0.5 ); // P4 es morado

glEnd();