#include <windows.h>
//#include <GL/gl.h>
//#include <GL/glu.h>
#include <glut.h>
#include <stdlib.h> //agregar para manejar la salida del programa


typedef struct treenode {
	//GLfloat m[16];
	void (*f)();
	struct treenode *sibling;
	struct treenode *child;
} treenode;

static int *rot_x, *rot_y, *rot_z;
static int cubo0 = 0, cubo1 = 0, cubo2 = 0, cubo3 = 0,
	torso_rx = 0, torso_ry = 0, torso_rz = 0,
	head_rx = 0, head_ry = 0, head_rz = 0,

	lua_rx = 0, lua_ry = 0, lua_rz = 0,
	lla_rx = 0, lla_ry = 0, lla_rz = 0,
	lh_rx = 0, lh_ry = 0, lh_rz = 0,
	
	rua_rx = 0, rua_ry = 0, rua_rz = 0,
	rla_rx = 0, rla_ry = 0, rla_rz = 0,
	rh_rx = 0, rh_ry = 0, rh_rz = 0,
	
	lul_rx = 0, lul_ry = 0, lul_rz = 0,
	lll_rx = 0, lll_ry = 0, lll_rz = 0,
	lf_rx = 0, lf_ry = 0, lf_rz = 0,
	
	rul_rx = 0, rul_ry = 0, rul_rz = 0,
	rll_rx = 0, rll_ry = 0, rll_rz = 0,
	rf_rx = 0, rf_ry = 0, rf_rz = 0;

// nodos del arbol
treenode torsoNode, headNode, luaNode, llaNode, lhNode, ruaNode, rlaNode, rhNode,
	lulNode, lllNode, lfNode, rulNode, rllNode, rfNode;

GLUquadric *torsoQuad = gluNewQuadric(),
	*headQuad = gluNewQuadric(),
	*luaQuad = gluNewQuadric(),
	*llaQuad = gluNewQuadric(),
	*lhQuad = gluNewQuadric(),
	*ruaQuad = gluNewQuadric(),
	*rlaQuad = gluNewQuadric(),
	*rhQuad = gluNewQuadric(),
	*lulQuad = gluNewQuadric(),
	*lllQuad = gluNewQuadric(),
	*lfQuad = gluNewQuadric(),
	*rulQuad = gluNewQuadric(),
	*rllQuad = gluNewQuadric(),
	*rfQuad = gluNewQuadric();

// ** Menu items
enum MENU_TYPE
{
		TRONCO,
		CABEZA,
	
		BRAZO_DERECHO,
        ANTEBRAZO_DERECHO,
        MANO_DERECHA,

        BRAZO_IZQUIERDO,
        ANTEBRAZO_IZQUIERDO,
        MANO_IZQUIERDA,

		MUSLO_DERECHO,
		PIERNA_DERECHA,
		PIE_DERECHO,

		MUSLO_IZQUIERDO,
		PIERNA_IZQUIERDA,
		PIE_IZQUIERDO
};

// Assign a default value
MENU_TYPE show = TRONCO;

// Menu handling function declaration
void menu(int);

// Menu handling function definition
void menu(int item)
{
        switch (item)
        {
        case BRAZO_DERECHO: 
			rot_x = &rua_rx;
			rot_y = &rua_ry;
			rot_z = &rua_rz;
			break;
        case ANTEBRAZO_DERECHO:
			rot_x = &rla_rx;
			rot_y = &rla_ry;
			rot_z = &rla_rz;
			break;
        case MANO_DERECHA: 
			rot_x = &rh_rx;
			rot_y = &rh_ry;
			rot_z = &rh_rz;
			break;
		case BRAZO_IZQUIERDO:
			rot_x = &lua_rx;
			rot_y = &lua_ry;
			rot_z = &lua_rz;
			break;
        case ANTEBRAZO_IZQUIERDO:
			rot_x = &lla_rx;
			rot_y = &lla_ry;
			rot_z = &lla_rz;
			break;
        case MANO_IZQUIERDA:
			rot_x = &lh_rx;
			rot_y = &lh_ry;
			rot_z = &lh_rz;
			break;
		case MUSLO_DERECHO: 
			rot_x = &rul_rx;
			rot_y = &rul_ry;
			rot_z = &rul_rz;
			break;
        case PIERNA_DERECHA: 
			rot_x = &rll_rx;
			rot_y = &rll_ry;
			rot_z = &rll_rz;
			break;
        case PIE_DERECHO:
			rot_x = &rf_rx;
			rot_y = &rf_ry;
			rot_z = &rf_rz;
			break;
		case MUSLO_IZQUIERDO:
			rot_x = &lul_rx;
			rot_y = &lul_ry;
			rot_z = &lul_rz;
			break;
        case PIERNA_IZQUIERDA:
			rot_x = &lll_rx;
			rot_y = &lll_ry;
			rot_z = &lll_rz;
			break;
        case PIE_IZQUIERDO:
			rot_x = &lf_rx;
			rot_y = &lf_ry;
			rot_z = &lf_rz;
			break;
		case CABEZA: 
			rot_x = &head_rx;
			rot_y = &head_ry;
			rot_z = &head_rz;
			break;
        case TRONCO:
			rot_x = &torso_rx;
			rot_y = &torso_ry;
			rot_z = &torso_rz;
                /*{
                        show = (MENU_TYPE) item;
                }*/
                break;
        default:
                {       /* Nothing */       }
                break;
        }

        glutPostRedisplay();

        return;
}

// **


void dibuja_cubo(double x, double y, double z){
	glPushMatrix();

	glScalef(x,y,z);
	// construcción de la escena
	// dibuja un cubo en la coord 0,0,0 con dimensiones 1 x 1 x -1

	//glColor3f(0,0,1); //Azul
	glBegin( GL_QUADS ); // frontal
	 glVertex3f( 0, 0,  0 );
	 glVertex3f( 1, 0,  0 );
	 glVertex3f( 1, 1,  0 );
	 glVertex3f( 0, 1,  0 );
	glEnd();

	//glColor3f(0,1,0); // Verde
	glBegin( GL_QUADS ); // lateral derecha
	 glVertex3f( 1, 0,  0 );
	 glVertex3f( 1, 0, -1 );
	 glVertex3f( 1, 1, -1 );
	 glVertex3f( 1, 1,  0 );
	glEnd();

	//glColor3f(1,0,0); // Rojo
	glBegin( GL_QUADS ); // superior
	 glVertex3f( 0, 1,  0 );
	 glVertex3f( 1, 1,  0 );
	 glVertex3f( 1, 1, -1 );
	 glVertex3f( 0, 1, -1 );
	glEnd();
	
	//glColor3f(0,0,1); //Azul
	glBegin( GL_QUADS ); // trasera
     glVertex3f( 0, 0,  -1 );
	 glVertex3f( 1, 0,  -1 );
	 glVertex3f( 1, 1,  -1 );
	 glVertex3f( 0, 1,  -1 );
	glEnd();

	//glColor3f(0,1,0); //Verde
	glBegin( GL_QUADS ); // lateral izquiera
     glVertex3f( 0, 0,  0 );
	 glVertex3f( 0, 0, -1 );
	 glVertex3f( 0, 1, -1 );
	 glVertex3f( 0, 1,  0 );
	glEnd();

    //glColor3f(1,0,0); //Rojo
	glBegin( GL_QUADS ); // inferior
     glVertex3f( 0, 0,  0 );
	 glVertex3f( 1, 0,  0 );
     glVertex3f( 1, 0, -1 );
	 glVertex3f( 0, 0, -1 );
	glEnd();

	glPopMatrix();
}

/*void dibuja_cilindro(GLUquadric *obj, double x, double y, double z, int q){
	glPushMatrix();

	glRotatef(90,0,1,0);
	glScalef(x,y,z);
	// construcción de la escena
	// dibuja un cubo en la coord 0,0,0 con dimensiones 1 x 1 x -1
	
	gluCylinder(obj, 1, .5, 1, q, 1);

	glPopMatrix();
}

void dibuja_esfera(GLUquadric *obj, double x, double y, double z, int q){
	glPushMatrix();

	glScalef(x,y,z);
	glTranslatef(1,0,0);
	glRotatef(90,0,1,0);

	// construcción de la escena
	// dibuja un cubo en la coord 0,0,0 con dimensiones 1 x 1 x -1
	
	gluSphere(obj, 1, q, q);

	glPopMatrix();
}*/


void dibuja_torsoNode(){
	glRotatef((GLfloat)torso_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)torso_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)torso_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(70,130,180);
	glPushMatrix();
	glScalef(1.5, 3, 1);
	glRotatef(0, 0, 1, 0);
	gluSphere(torsoQuad, 1, 50, 50);
	glPopMatrix();
}
void dibuja_headNode(){
	glTranslatef(0, 3, 0);

	glRotatef((GLfloat)head_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)head_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)head_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(255,218,185);
	glPushMatrix();
	glScalef(1, 1, 1);
	glTranslatef(0, 1, 0);
	//glRotatef(0, 0, 1, 0);
	gluSphere(headQuad, 1, 50, 50);
	glPopMatrix();
}

void dibuja_luaNode() {
	glTranslatef(1.3, 2, 0);
	glRotatef((GLfloat)lua_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)lua_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)lua_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(70,130,180);

	glPushMatrix();
	glRotatef(90,0,1,0);
	glScalef(.5,.5,3);
	gluCylinder(luaQuad, 1, .5, 1, 50, 1);
	glPopMatrix();

	glTranslatef(3, 0, 0);
}
void dibuja_llaNode() {
	glRotatef((GLfloat)lla_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)lla_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)lla_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(255,218,185);
	
	glPushMatrix();
	glRotatef(90,0,1,0);
	glScalef(.5,.5,3);
	gluCylinder(llaQuad, 1, .5, 1, 50, 1);
	glPopMatrix();
	glTranslatef(3, 0, 0);
}
void dibuja_lhNode() {
	glRotatef((GLfloat)lh_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)lh_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)lh_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(169,169,169); 
	//gluQuadricDrawStyle(lhQuad,GLU_LINE);

	glPushMatrix();
	glScalef(.5,.5,.5);
	glTranslatef(1,0,0);
	glRotatef(90,0,1,0);
	gluSphere(lhQuad, 1, 10, 10);
	glPopMatrix();
}

void dibuja_ruaNode(){
	glTranslatef(-1.3, 2, 0);
	
	glRotatef((GLfloat)rua_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)rua_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)rua_rz, 0, 0, 1); // Rotacion en z
	
	glColor3ub(70,130,180);

	glPushMatrix();
	glRotatef(-90,0,1,0);
	glScalef(.5,.5,3);
	gluCylinder(ruaQuad, 1, .5, 1, 50, 1);
	glPopMatrix();

	glTranslatef(-3, 0, 0);
}
void dibuja_rlaNode(){
	glRotatef((GLfloat)rla_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)rla_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)rla_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(255,218,185);
	
	glPushMatrix();
	glRotatef(-90,0,1,0);
	glScalef(.5,.5,3);
	gluCylinder(rlaQuad, 1, .5, 1, 50, 1);
	glPopMatrix();
	glTranslatef(-3, 0, 0);
}
void dibuja_rhNode(){
	glRotatef((GLfloat)rh_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)rh_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)rh_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(169,169,169);
	//gluQuadricDrawStyle(lhQuad,GLU_LINE);

	glPushMatrix();
	glScalef(.5,.5,.5);
	glTranslatef(-1,0,0);
	glRotatef(-90,0,1,0);
	gluSphere(rhQuad, 1, 10, 10);
	glPopMatrix();
}

void dibuja_lulNode(){
	glTranslatef(.8, -2.5, 0);
	glRotatef((GLfloat)lul_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)lul_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)lul_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(70,130,180);

	glPushMatrix();
	glRotatef(90,1,0,0);
	glScalef(.5,.5,3);
	gluCylinder(lulQuad, 1, .5, 1, 50, 1);
	glPopMatrix();

	glTranslatef(0, -3, 0);
}
void dibuja_lllNode(){
	glRotatef((GLfloat)lll_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)lll_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)lll_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(255,218,185);
	
	glPushMatrix();
	glRotatef(90,1,0,0);
	glScalef(.5,.5, 3);
	gluCylinder(lllQuad, 1, .5, 1, 50, 1);
	glPopMatrix();
	glTranslatef(0, -3, 0);
}
void dibuja_lfNode(){
	glRotatef((GLfloat)lf_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)lf_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)lf_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(169,169,169); 
	//gluQuadricDrawStyle(lhQuad,GLU_LINE);

	glPushMatrix();
	glScalef(.5,.5,.5);
	glTranslatef(0,-1,0);
	glRotatef(90,0,1,0);
	gluSphere(lhQuad, 1, 10, 10);
	glPopMatrix();
}

void dibuja_rulNode(){
	glTranslatef(-.8, -2.5, 0);
	glRotatef((GLfloat)rul_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)rul_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)rul_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(70,130,180);

	glPushMatrix();
	glRotatef(90,1,0,0);
	glScalef(.5,.5,3);
	gluCylinder(rulQuad, 1, .5, 1, 50, 1);
	glPopMatrix();

	glTranslatef(0, -3, 0);
}
void dibuja_rllNode(){
	glRotatef((GLfloat)rll_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)rll_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)rll_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(255,218,185);
	
	glPushMatrix();
	glRotatef(90,1,0,0);
	glScalef(.5,.5, 3);
	gluCylinder(rllQuad, 1, .5, 1, 50, 1);
	glPopMatrix();
	glTranslatef(0, -3, 0);
}
void dibuja_rfNode(){
	glRotatef((GLfloat)rf_rx, 1, 0, 0); // Rotacion en x
	glRotatef((GLfloat)rf_ry, 0, 1, 0); // Rotacion en y
	glRotatef((GLfloat)rf_rz, 0, 0, 1); // Rotacion en z
	glColor3ub(169,169,169); 
	//gluQuadricDrawStyle(lhQuad,GLU_LINE);

	glPushMatrix();
	glScalef(.5,.5,.5);
	glTranslatef(0,-1,0);
	glRotatef(90,0,1,0);
	gluSphere(rhQuad, 1, 10, 10);
	glPopMatrix();
}

// recorrido a profundidad: primero los hijos, luego los hermanos
void traverse (treenode *node) {
	// guardar la matriz actual porque las transformaciones a realizarse
	// sólo deben afectarle a él y a sus hijos
	glPushMatrix();
	// transformar relativo a su padre
	//glMultMatrixf(node->m);
	// dibujar el nodo
	node->f();
	// primer recorrer los hijos (si hay)
	if (node->child != NULL)
		traverse(node->child);

	glPopMatrix();
	// después recorrer los hermanos (si hay)
	if(node->sibling != NULL)
		traverse(node->sibling);
}

void init(void){
	int menu_general, submenu_brazo_izquierdo, submenu_brazo_derecho, submenu_pierna_derecha, submenu_pierna_izquierda;
	glClearColor(0.0, 0.0, 0.0, 0.0); //limpiar pantalla
	glShadeModel(GL_FLAT); //relleno de color del polígono

		// ** agegando opciones en el menu del mouse

	// Create a menu
	//glutCreateMenu(menu);

	//submenu brazo derecho
	submenu_brazo_derecho = glutCreateMenu(menu);
	glutAddMenuEntry("Brazo",BRAZO_DERECHO);
	glutAddMenuEntry("Antebrazo",ANTEBRAZO_DERECHO);
	glutAddMenuEntry("Mano",MANO_DERECHA);

	//submenu brazo izquierdo
	submenu_brazo_izquierdo = glutCreateMenu(menu);
	glutAddMenuEntry("Brazo",BRAZO_IZQUIERDO);
	glutAddMenuEntry("Antebrazo",ANTEBRAZO_IZQUIERDO);
	glutAddMenuEntry("Mano",MANO_IZQUIERDA);

	//submenu pierna derecha
	submenu_pierna_derecha = glutCreateMenu(menu);
	glutAddMenuEntry("Muslo",MUSLO_DERECHO);
	glutAddMenuEntry("Pierna",PIERNA_DERECHA);
	glutAddMenuEntry("Pie",PIE_DERECHO);

	//submenu pierna izquierda
	submenu_pierna_izquierda = glutCreateMenu(menu);
	glutAddMenuEntry("Muslo",MUSLO_IZQUIERDO);
	glutAddMenuEntry("Pierna",PIERNA_IZQUIERDA);
	glutAddMenuEntry("Pie",PIE_IZQUIERDO);

	menu_general = glutCreateMenu(menu);
	glutAddMenuEntry("Cabeza",CABEZA);
	glutAddMenuEntry("Tronco",TRONCO);
	glutAddSubMenu("Brazo derecho",submenu_brazo_derecho);
	glutAddSubMenu("Brazo izquierdo",submenu_brazo_izquierdo);
	glutAddSubMenu("Pierna derecha",submenu_pierna_derecha);
	glutAddSubMenu("Pierna izquierda",submenu_pierna_izquierda);

		
	// Add menu items
/*	glutAddMenuEntry("Show Front", MENU_FRONT);
	glutAddMenuEntry("Show Back", MENU_BACK);
	glutAddMenuEntry("Spotlight", MENU_SPOT);
	glutAddMenuEntry("Blend 'em all", MENU_BACK_FRONT);
*/
	// Associate a mouse button with menu
	glutAttachMenu(GLUT_RIGHT_BUTTON);

    // **

	rot_x = &torso_rx;
	rot_y = &torso_ry;
	rot_z = &torso_rz;

	// crear arbol
	torsoNode.child = &headNode;
	headNode.sibling= &luaNode;

	luaNode.child = &llaNode;
	llaNode.child = &lhNode;
	luaNode.sibling = &lulNode;

	lulNode.child = &lllNode;
	lllNode.child = &lfNode;
	lulNode.sibling = &rulNode;

	rulNode.child = &rllNode;
	rllNode.child = &rfNode;
	rulNode.sibling = &ruaNode;

	ruaNode.child = &rlaNode;
	rlaNode.child = &rhNode;

	// asociar funciones de dibujo a nodos
	torsoNode.f = dibuja_torsoNode;
	headNode.f = dibuja_headNode;

	luaNode.f = dibuja_luaNode;
	llaNode.f = dibuja_llaNode;
	lhNode.f = dibuja_lhNode;

	rulNode.f = dibuja_rulNode;
	rllNode.f = dibuja_rllNode;
	rfNode.f = dibuja_rfNode;

	lulNode.f = dibuja_lulNode;
	lllNode.f = dibuja_lllNode;
	lfNode.f = dibuja_lfNode;

	ruaNode.f = dibuja_ruaNode;
	rlaNode.f = dibuja_rlaNode;
	rhNode.f = dibuja_rhNode;
}

void displayevent(void)
{
	// limpia la escena (ventana)
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// verfica superficies visibles
	glEnable( GL_DEPTH_TEST );
	
	// navega en el arbol de nodos
	traverse(&torsoNode);

	glutSwapBuffers();

}

void keyboard( unsigned char key, int x, int y )
{
 // manejo de teclas especiales
 
 switch ( key ) {
	// cambia la rotación del cubo
	case 'q':
		*rot_x = (*rot_x + 5) % 360;
		//cubo0 = (cubo0 + 5)%360;
		glutPostRedisplay();
		break;
	case 'a':
		*rot_x = (*rot_x - 5) % 360;
		//cubo0 = (cubo0 - 5)%360;
		glutPostRedisplay();
		break;
	case 'w':    
		*rot_y = (*rot_y + 5) % 360;
		//cubo1 = (cubo1 + 5)%360;
		glutPostRedisplay();
		break;
	case 's':  
		*rot_y = (*rot_y - 5) % 360;
		//cubo1 = (cubo1 -5)%360;
		glutPostRedisplay();
		break;
	case 'e':
		//if(cubo2 <= 140) {		// Se limita el movimiento del antebrazo para que parezca un comportamiento mas humano
		*rot_z = (*rot_z + 5) % 360;
		//cubo2 = (cubo2 + 5)%360;
		glutPostRedisplay();
		//}
		break;
	case 'd':
		//if(cubo2 >= 0 ){		// Se limita el movimiento del antebrazo para que parezca un comportamiento mas humano
			*rot_z = (*rot_z - 5) % 360;
			//cubo2 = (cubo2 - 5)%360;
			glutPostRedisplay();
		//}
		break;
	//case 'r':
	//	if(cubo3 <= 80){		// Se limita el movimiento de la muneca para que parezca un comportamiento mas humano
	//		cubo3 = (cubo3 + 5)%360;
	//		glutPostRedisplay();
	//	}
	//	break;
	//case 'f':
	//	if(cubo3 >= -80){		// Se limita el movimiento de la muneca para que parezca un comportamiento mas humano
	//		cubo3 = (cubo3 - 5)%360;
	//		glutPostRedisplay();
	//	}
	//	break;
	
	case 27:
		exit(0);
		break;
	default:
		break;
 }
}

void reshapeevent(int w, int h)
{
	// establecer el área de visualizacion en la ventana
	glViewport(0,0,(GLsizei)w,(GLsizei)h);
	
	// seleccionar la matriz de Proyección
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	// Vista en Perspectiva
	gluPerspective(60.0,(GLfloat)w/(GLfloat)h,  1.0, 20.0);

	// Restaurar a la matriz del Modelo (escena)
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef (0.0, 2.0, -15.0);

} 


int main(int argc, char** argv)
{
	//Ciclo infinito
	// inicialización del GLUT
	glutInit( &argc, argv );

	glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA);
	// inicialiación de la ventana
	glutInitWindowSize( 800, 500 );
	glutInitWindowPosition( 100, 100 );
    
    glutCreateWindow( argv[0]);
	init(); //llamada a limpiar color 
	
	// inicialización de los datos del programa
	

	// registro de los eventos
    glutDisplayFunc( displayevent ); // Funcion de Dibujo
	glutReshapeFunc ( reshapeevent ); //Manejo de Cambio de Ventana
	glutKeyboardFunc( keyboard ); //Manejo de Teclado
	
	// lazo de eventos
	glutMainLoop();

	return 0;
} // main