2016年3月15日 星期二

Week 04 王薏婷

作業 1  作業互評


作業 2

選轉軸



作業 3

移動Mode

#include <GL/glut.h>
float nowx=0, nowy=0;
void mouse (int button,int state,int x,int y)
{
    nowx= (x-150)/150.0;
    nowy= -(y-150)/150.0;
}
void display()
{
    glClearColor(1,1,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glTranslated(nowx,nowy,0);
        glColor3f (1,0,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();

}

int main (int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow ("03160101王薏婷");

    glutDisplayFunc (display);
    glutMouseFunc(mouse);
    glutMainLoop ();
}

作業 4 



#include <GL/glut.h>
#include <stdio.h>
#include <math.h>
float nowx=0, nowy=0;
void mouse (int button,int state,int x,int y)
{
    nowx= (x-150)/150.0;
    nowy= -(y-150)/150.0;
    printf("glTranslatef(%f,%f,0);\n",nowx,nowy);
}
void display()
{
    glClearColor(1,1,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(nowx,nowy,0);
        glColor3f (1,0,0);
        ///glutSolidTeapot(0.3);
        glBegin(GL_POLYGON);
            for(float angle=0;angle<3.14159265358979*2;angle+=0.1){
                glVertex2f (0.2*cos(angle),0.2*sin(angle));
            }
        glEnd();
    glPopMatrix();
    glutSwapBuffers();

}

int main (int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow ("03160101王薏婷");
    glutDisplayFunc (display);
    glutMouseFunc(mouse);
    glutMainLoop ();

}

額外:



沒有留言:

張貼留言