2019年3月7日 星期四

06160301-吳過W3


第一步














http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/

進入網站下載 Example[win32][data]還有glut32.dll















第二步 解壓縮至windows 全部丟進去

尋找shape的檔案













作業二
打開open GL
與之前的打開方式一樣
再輸入以下的程式
#include <GL/glut.h>
void display()
{
     glPushMatrix();
     glTranslatef(0.3,0.3,0);
     glutSolidTeapot( 0.3 );
     glPopMatrix();
     glutSwapBuffers();
}
int main(int argc, char**argv)
{

     glutInit(&argc, argv);
     glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
     glutCreateWindow("week04");
     glutDisplayFunc(display);
     glutMainLoop();
}














作業三
輸入
#include <GL/glut.h>
float x=0,y=0;
void display()
{
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glPushMatrix();
     glTranslatef((x-150)/150.0,-(y-150)/150.0,0);
     glutSolidTeapot( 0.3 );
     glPopMatrix();
     glutSwapBuffers();
}
void motion(int nowX,int nowY)
{
    x=nowX;y=nowY;
    display();
}
int main(int argc, char**argv)
{

     glutInit(&argc, argv);
     glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
     glutCreateWindow("week04");
     glutDisplayFunc(display);
     glutMotionFunc(motion);
     glutMainLoop();
}

沒有留言:

張貼留言