jueves, 18 de octubre de 2012


Traslación


#include <GL/glut.h>
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
    glTranslatef(-2.0, -2.0, 0.0);
    glColor3f(1.0, 0.6, 0.2);
    glBegin(GL_POLYGON);
        glVertex2f (2.0, 2.0);
        glVertex2f (7.0, 2.0);
        glVertex2f (7.0, 7.0);
        glVertex2f (-2.0, 7.0);   
    glEnd();
    glFlush (); }
void init (void)
{glClearColor (0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-3.0, 6.0, -2.0, 6.0, -5.0, 5.0);
}int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (250, 250);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("hello");
    init ();


    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
 }


ESCALACION


#include <GL/glut.h>
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
                glScalef(0.5, 0.5, 0.0)
    glColor3f (1.0, 0.8, 0.6);
    glBegin(GL_POLYGON);
        glVertex2f (2.0, 2.0);
        glVertex2f (7.0, 2.0);
        glVertex2f (7.0, 7.0);
        glVertex2f (2.0, 7.0);  
    glEnd();
    glFlush ();
}  void init (void)
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-3.0, 6.0, -2.0, 6.0, -5.0, 5.0);
}
int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (250, 250);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("hello");
    init ();

    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
 }


ROTACION
#include <GL/glut.h>

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
                glRotatef(45.0, 0.0, 0.0,1.0)
    glColor3f (0.2, 0.8, 0.6);
    glBegin(GL_POLYGON);
        glVertex2f (2.0, 2.0);
        glVertex2f (7.0, 2.0);
        glVertex2f (7.0, 7.0);
        glVertex2f (2.0, 7.0);  
    glEnd();
    glFlush ();
}
void init (void)
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-4.0, 4.0, 1.0, 6.0, -3.0, 8.0);
}
int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (250, 250);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("hello");
    init ();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}







    b)

TRASLACION

#include <GL/glut.h>

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);

    glTranslatef(-2.0, -2.0, 0.0);
    glColor3f(1.0, 0.6, 0.2);
    glBegin(GL_POLYGON);
        glVertex2f (2.0, 2.0);
        glVertex2f (7.0, 2.0);
        glVertex2f (7.0, 7.0);
        glVertex2f (-2.0, 7.0);  
    glEnd();
    glFlush ();
}

void init (void)
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-3.0, 6.0, -2.0, 6.0, -5.0, 5.0);
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (250, 250);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("hello");
    init ();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
 }

ESCALACION




#include <GL/glut.h>

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
                glScalef(0.5, 0.5, 0.0)
    glColor3f (0.2, 0.8, 0.6);
    glBegin(GL_POLYGON);
        glVertex2f (0.0, 0.0);
        glVertex2f (5.0, 0.0);
        glVertex2f (5.0, 5.0);
        glVertex2f (0.0, 5.0);  
    glEnd();
    glFlush ();
}

void init (void)
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-3.0, 6.0, -2.0, 6.0, -5.0, 5.0);
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (250, 250);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("hello");
    init ();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
 }

ROTACION




#include <GL/glut.h>

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
                glRotatef(45.0, 0.0, 0.0,1.0)
    glColor3f (0.2, 0.2, 0.6);
    glBegin(GL_POLYGON);
        glVertex2f (0.0, 0.0);
        glVertex2f (2.5, 0.0);
        glVertex2f (2.5, 2.5);
        glVertex2f (0.0, 2.5);  
    glEnd();
    glFlush ();
}

void init (void)
{
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-4.0, 4.0, 1.0, 6.0, -3.0, 8.0);
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize (250, 250);
    glutInitWindowPosition (100, 100);
    glutCreateWindow ("hello");
    init ();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

No hay comentarios:

Publicar un comentario