Intro_Triangulo.c



// DIBUJO DE UN TRIANGULO A COLORES

#include <GL/glut.h>

void display(void)
{
	glClearColor (0.0, 0.0, 0.0, 0.0);	// selecciona el color de borrado -negro-
	/* borra la pantalla */
	glClear (GL_COLOR_BUFFER_BIT);		// borra la pantalla
	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
	glMatrixMode(GL_MODELVIEW);
	glBegin(GL_TRIANGLES);
		glColor3f(1,0,0); glVertex3f(0,.8,0);
		glColor3f(0,1,0); glVertex3f(-.6,-.2,0);
		glColor3f(0,0,1); glVertex3f(.6,-.2,0);
	glEnd();
	glFlush ();		// Vacia el buffer de dibujo
	sleep(3);
	exit(0);
}

void inicializa (void)
{
	
	/* inicializa los valores de la vista */
	
	
	
	
	glLoadIdentity();
}




int main(int argc, char** argv)
{
	glutInit(&argc, argv);					// Inicializa la libreria auxiliar GLUT
	glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);		// Inicializa el modo de visualizacion
	glutInitWindowSize (500, 500);				// Indica el tamano de la ventana (ancho,alto)
	glutInitWindowPosition (20, 20);			// Indica la posiciOn inicial (xmin,ymin)
	glutCreateWindow ("Triangulo");		// Abre la ventana con el tItulo indicado
	//inicializa ();						// Inicializar valores
	glutDisplayFunc(display);				// Indica cual es la funciOn de dibujo
	glutMainLoop();					// Comienza el bucle de dibujo y proceso de eventos.
	return 0;
}