sábado, 18 de octubre de 2008

Cubo

Este código está basado en uno que nos dieron para trabajar en el laboratorio, pero lo modifiqué para cumplir con la características que se pidieron.


#include #include #include
float pos_camX = 0, pos_camY = 0, pos_camZ = -5; int eye_camX = 0, eye_camY = 0.0, eye_camZ = 0;
float ang_rot1 = 0.0;float a=1.0, b=1.0, c=1.0, d=0.5;
GLfloat Diffuse[]= { 0.5f, 0.5f, 0.5f, 1.0f }; // Diffuse Light ValuesGLfloat Specular[] = { 1.0, 1.0, 1.0, 1.0 }; // Specular Light ValuesGLfloat Position[]= { 0.0f, 3.0f, 0.0f, 1.0f }; // Light PositionGLfloat Position2[]= { 0.0f, 0.0f, -5.0f, 1.0f }; // Light Position
void InitGL ( GLvoid ) // Inicializamos parametros{ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Fondo
glLightfv(GL_LIGHT0, GL_POSITION, Position);glPopMatrix();glPopMatrix();glPopMatrix(); glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, Position2); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable ( GL_COLOR_MATERIAL );
glClearDepth(1.0f); // Configuramos Depth Buffer glEnable(GL_DEPTH_TEST); // Habilitamos Depth Testing glDepthFunc(GL_LEQUAL); // Tipo de Depth Testing a realizar glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}
void cubo (GLenum render) //Funcion creacion prisma{
GLfloat vertice [8][3] = { {0.5 ,-0.5, 0.5}, //Coordenadas V1 {-0.5 ,-0.5, 0.5}, //Coordenadas V2 {-0.5 ,-0.5, -0.5}, //CoordenadasV3 {0.5 ,-0.5, -0.5}, //Coordenadas V4 {0.5 ,0.5, 0.5}, //Coordenadas V5 {0.5 ,0.5, -0.5}, //Coordenadas V6 {-0.5 ,0.5, -0.5}, //Coordenadas V7 {-0.5 ,0.5, 0.5}, //Coordenadas V8 };
glBegin(render); //Frente glNormal3f( 0.0f, 0.0f, 1.0f); glVertex3fv(vertice[0]); glVertex3fv(vertice[4]); glVertex3fv(vertice[7]); glVertex3fv(vertice[1]); glEnd();
glBegin(render); //Lado Derecho glNormal3f( 1.0f, 0.0f, 0.0f); glVertex3fv(vertice[0]); glVertex3fv(vertice[3]); glVertex3fv(vertice[5]); glVertex3fv(vertice[4]); glEnd();
glBegin(render); //Atras glNormal3f( 0.0f, 0.0f,-1.0f); glVertex3fv(vertice[6]); glVertex3fv(vertice[5]); glVertex3fv(vertice[3]); glVertex3fv(vertice[2]); glEnd();
glBegin(render); //Lado Izquierdo glNormal3f(-1.0f, 0.0f, 0.0f); glVertex3fv(vertice[1]); glVertex3fv(vertice[7]); glVertex3fv(vertice[6]); glVertex3fv(vertice[2]); glEnd();
glBegin(render); //Abajo glNormal3f( 0.0f,-1.0f, 0.0f); glVertex3fv(vertice[0]); glVertex3fv(vertice[1]); glVertex3fv(vertice[2]); glVertex3fv(vertice[3]); glEnd();
glBegin(render); //Arriba glNormal3f( 0.0f, 1.0f, 0.0f); glVertex3fv(vertice[4]); glVertex3fv(vertice[5]); glVertex3fv(vertice[6]); glVertex3fv(vertice[7]); glEnd();}
void display ( void ) // Creamos la funcion donde se dibuja{ glClear (GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT); glPushMatrix();
glTranslatef(pos_camX, pos_camY, pos_camZ); glRotatef(eye_camX, 1.0, 0.0, 0.0); glRotatef(eye_camY, 0.0, 1.0, 0.0); glRotatef(eye_camZ, 0.0, 0.0, 1.0);
glPushMatrix(); glTranslatef(-1,0.0,0.0);glRotatef(ang_rot1,0.0,0.0,1.0);glTranslatef(1,0.0,0.0); glPushMatrix();

glScalef(a, b, c); //Escalamiento con variablescubo(GL_POLYGON); glPopMatrix();

glPopMatrix();
glPopMatrix();
glColor3f(0.0,0.0,1.0); glPopMatrix();
glutSwapBuffers ( );
}
void animacion(){ glutPostRedisplay();}
void reshape ( int width , int height ) // Creamos funcion Reshape{ if (height==0) // Prevenir division entre cero { height=1; }
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION); // Seleccionamos Projection Matrix glLoadIdentity();
// Tipo de Vista glFrustum (-0.1, 0.1,-0.1, 0.1, 0.1, 50.0);
glMatrixMode(GL_MODELVIEW); // Seleccionamos Modelview Matrix glLoadIdentity();}
void keyboard ( unsigned char key, int x, int y ) // Create Keyboard Function{ switch ( key ) {
//Rotacion case 'r': case 'R': ang_rot1 ++; break;
case 'f': case 'F': ang_rot1 --; break; //Escalamiento case 'g': case 'G': a ++; b ++; c ++; break; case 't': case 'T': a --; b --; c --; break; case 'J': case 'j': a ++; c --; break;
case 27: exit ( 0 ); break; default: break; } glutPostRedisplay();}
void arrow_keys ( int a_keys, int x, int y ) // Funcion para manejo de teclas especiales (arrow keys){ switch ( a_keys ) { case GLUT_KEY_PAGE_UP: pos_camY -= 0.5f; break;
case GLUT_KEY_PAGE_DOWN: pos_camY += 0.5f; break;
case GLUT_KEY_UP: eye_camX = (eye_camX-15) % 360; break;
case GLUT_KEY_DOWN: eye_camX = (eye_camX+15) % 360; break;
case GLUT_KEY_LEFT: eye_camY = (eye_camY-15) % 360; break;
case GLUT_KEY_RIGHT: eye_camY = (eye_camY+15) % 360; break; default: break; } glutPostRedisplay();}
int main ( int argc, char** argv ) // Main Function{ glutInit (&argc, argv); // Inicializamos OpenGL glutInitDisplayMode (GLUT_RGB GLUT_DOUBLE GLUT_DEPTH); // Display Mode (Clores RGB y alpha Buffer Doble ) glutInitWindowSize (500, 500); // Tama� de la Ventana glutInitWindowPosition (0, 0); //Posicion de la Ventana glutCreateWindow ("Cubo"); // Nombre de la Ventana InitGL (); // Parametros iniciales de la aplicacion glutDisplayFunc ( display ); //Indicamos a Glut funci� de dibujo glutReshapeFunc ( reshape ); //Indicamos a Glut funci� en caso de cambio de tamano glutKeyboardFunc ( keyboard ); //Indicamos a Glut funci� de manejo de teclado glutSpecialFunc ( arrow_keys ); //Otras//glutIdleFunc ( animacion ); glutMainLoop ( ); //
return 0;}

sábado, 13 de septiembre de 2008

Pantallas Flexibles


Las pantallas flexibles (o enrollables) utilizan principalmente la tecnología OLED (Organic light-emitting diode), que funciona basándose "en una capa electroluminiscente formada por una película de componentes orgánicos que reaccionan a una determinada estimulación eléctrica, generando y emitiendo luz por sí mismos."


Entre sus principales ventajas está un menor consumo de energía y que el grosor de la pantalla puede ser reducido a milímetros, permitiendo de esta manera el desarrollo de pantallas flexibles.
Muchas de las grandes compañías dedicadas a la tecnológia han presentado prototipos utilizando este tipo de pantallas, pero hasta ahora no existe una aplicación comercial que pueda ser adquirida por el usuario final.
Para más información sobre el funcionamiento de la tecnología OLED: