Transformaciones Geométricas
Datos de los nuevos vértices
Puntos graficados.
---------------------------------------------------------------------------------------
Código Transformaciones Geométricas(por separado)
#include <glut.h>
void trans(void)
{
// ORIGINAL CAFE
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (0.45, 0.23, 0.1);
glBegin(GL_POLYGON);
glVertex3f (2.0, 2.0, 0.0);
glVertex3f (7.0, 2.0, 0.0);
glVertex3f (7.0, 7.0, 0.0);
glVertex3f (2.0, 7.0, 0.0);
glEnd();
//TRANSLACION BlANCO
glColor3f (1.0, 1.0, 1.0);
glPushMatrix();
glTranslatef(2.0f,2.0f,0.0f);
glBegin(GL_POLYGON);
glVertex3f (2.0, 2.0, 0.0);
glVertex3f (7.0, 2.0, 0.0);
glVertex3f (7.0, 7.0, 0.0);
glVertex3f (2.0, 7.0, 0.0);
glEnd();
glPopMatrix();
// ROTACION VERDE
glColor3f (0.5, 0.8, 0.2);
glPushMatrix();
glRotatef(45,0,0,1);
glBegin(GL_POLYGON);
glVertex3f (2.0, 2.0, 0.0);
glVertex3f (7.0, 2.0, 0.0);
glVertex3f (7.0, 7.0, 0.0);
glVertex3f (2.0, 7.0, 0.0);
glEnd();
glPopMatrix();
//ESCALACION AMARILLO
glColor3f(0.8f, 0.7f, 0.1f);
glScalef(0.5,0.5,0.0);
glBegin(GL_POLYGON);
glVertex3f (2.0, 2.0, 0.0);
glVertex3f (7.0, 2.0, 0.0);
glVertex3f (7.0, 7.0, 0.0);
glVertex3f (2.0, 7.0, 0.0);
glEnd();
glFlush ();
}
void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-15.0, 15.0, -15.0, 15.0, -2.0, 4.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (600, 600);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(trans);
glutMainLoop();
return 0;
}
Código Transformaciones Geométricas(Aplicadas una tras otra).
#include <glut.h>
void trans(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (0.45, 0.23, 0.1);
glTranslatef(2.0f,2.0f,0.0f);
glScalef(0.5,0.5,0.0);
glRotatef(45,0,0,1);
glBegin(GL_POLYGON);
glVertex3f (2.0, 2.0, 0.0);
glVertex3f (7.0, 2.0, 0.0);
glVertex3f (7.0, 7.0, 0.0);
glVertex3f (2.0, 7.0, 0.0);
glEnd();
glFlush ();
}
void init (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-15.0, 15.0, -15.0, 15.0, -2.0, 4.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (600, 600);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(trans);
glutMainLoop();
return 0;
}
No hay comentarios:
Publicar un comentario