2018年3月26日 星期一

Week05 1000

前往網址: http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/

下載windows / data / glut32.dll
解壓縮 把 data / glut32.dll移到windows

glTranslatef(...);移動下面的旋轉大車子

按滑鼠右鍵[s]


隱藏//glTranslated(-2.4,1.2,-6);
放到glRotated(a,0,0,1); 下排

茶壺

code程式碼
#include <GL/glut.h>

void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glutSolidTeapot(0.3);
    glutSwapBuffers();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week05step");
    glutDisplayFunc(display);
    glutMainLoop();
}

旋轉的茶壺

code程式碼
#include <GL/glut.h>///開啟GL外掛
#include <stdio.h>
float angle=0;
void motion(int x, int y)
{
    angle=x;///改變angle值
    glutPostRedisplay();///重畫
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);///清理畫面
    glPushMatrix();
        glRotatef(angle,0,0,1);///轉動
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();///秀出東西

}
int main(int argc, char**argv)///主函式
{
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
   glutCreateWindow("05160400Week5");
   glutMotionFunc(motion);
   glutDisplayFunc(display);
   glutMainLoop();

}
連在一起的茶壺

code程式碼
#include <GL/glut.h>///開啟GL外掛
#include <stdio.h>
float angle=0;
void motion(int x, int y)
{
    angle=x;///改變angle值
    glutPostRedisplay();///重畫
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);///清理畫面
    glPushMatrix();
    glutSolidTeapot(0.3);

    glTranslatef(0.5,0.15,0);
        glRotatef(angle,0,0,1);///轉動
        glTranslatef(0.45,-0.08,0);
        glutSolidTeapot(0.3);

    glPopMatrix();///還原矩陣
    glutSwapBuffers();///秀出東西

}
int main(int argc, char**argv)///主函式
{
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
   glutCreateWindow("05160400Week5");
   glutMotionFunc(motion);
   glutDisplayFunc(display);
   glutMainLoop();

}

沒有留言:

張貼留言