2016年3月22日 星期二

Week05薛鈺城

作業.1

1.教材:jsyeh/3dcg10/
2.點選window裡的Transformation



旋轉移動



旋轉移動



作業.2



程式碼

#include <GL/glut.h>
float rotX=0;

void display()
{


    glClearColor(1,1,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glRotatef(rotX, 0, 1, 0); 
        glColor3f(1,0,0);
        glutSolidTeapot(0.3);
     glPopMatrix();
     glutSwapBuffers();

}

void motion (int x, int y)

{
     rotX=x;
     display();
}

int main(int argc,char**argv)
{


    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("Hello 3D");

    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();

}

作業.3


程式碼



#include <GL/glut.h>
float rotX=0,rotY=0;

void display()
{


    glClearColor(1,1,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glRotatef(rotX, 1, 0, 0);
         glRotatef(rotX, 0, 1, 0);
        glColor3f(1,0,0);
        glutSolidTeapot(0.3);
     glPopMatrix();
     glutSwapBuffers();

}

void motion (int x, int y)

{
   rotX=x ,rotY=y;
   display();
}

int main(int argc,char**argv)
{


    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutInitWindowSize(600,600);
    glutInitWindowSize(700,0);
    glutCreateWindow("Hello 3D");


    glutMotionFunc(motion);
    glutDisplayFunc(display);

    glutMainLoop();

}

作業.4

 讓茶壺上下旋轉並改大小



#include <GL/glut.h>
float rotX=0,rotY=0;

void display()
{


    glClearColor(1,1,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glRotatef(rotX, 1, 0, 0);
         glRotatef(rotX, 0, 1, 0);
        glColor3f(1,0,0);
        glutSolidTeapot(0.3);
     glPopMatrix();
     glutSwapBuffers();

}

void motion (int x, int y)

{
   rotX=x ,rotY=y;
   display();
}

int main(int argc,char**argv)
{


    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutInitWindowSize(600,600);
    glutInitWindowSize(700,0);
    glutCreateWindow("Hello 3D");


    glutMotionFunc(motion);
    glutDisplayFunc(display);

    glutMainLoop();

}

沒有留言:

張貼留言