2016年5月16日 星期一

Week12 林品至

作業1

1.  下載 Windows,data,glut32.dll  , 以上三個Zip 

2.   建立一個資料夾,將window與data及glut都放入資料夾裡


3.   將Windows裡的Transform拉到資料夾外,也就是資料夾內。





作業 2

1.    建立貝殼專案

 2.    將"作業1"檔案中的Transform.c 和  glm.c 及 glm.h 複製下來,至專案資料夾中。
3.    將剛剛以上的 .c 檔改成 .cpp 檔


4.    到CodeBlock , 加  freeglut 的 include 和 lib 的 Path
5.     加   (1)  freeglut (2) opengl32 (3) glu32 (4)gui32 (5) winmm
6.     將freeglut.dll 檔 ,加入到專案資料夾中

作業 3
1.  承作業2的檔案,將 Transfrom.cpp 刪除  , 然後新增一個New File

2.   程式碼  :

#include "glm.h"
GLMmodel *pmodel = NULL;
void display ()
{
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    if (!pmodel)
    {
         pmodel = glmReadOBJ("data/porsche.obj");
         if (!pmodel) exit (0);
         glmUnitize(pmodel) ;
         glmFacetNormals(pmodel);
         glmVertexNormals(pmodel,90.0);
    }

    glmDraw(pmodel,GLM_SMOOTH| GLM_MATERIAL);

    glutSwapBuffers();

}
GLfloat pos[] = {0.0 , 0.0,-1.0,0.0};
int main (int argc ,char **argv)
{
    glutInit (&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow ("3D Model");
    glutDisplayFunc (display);

    glLightfv (GL_LIGHT0,GL_POSITION,pos);
    glEnable (GL_LIGHT0);
    glEnable (GL_LIGHTING);
    glEnable  (GL_DEPTH_TEST);

    glutMainLoop();
}   
      Step  3 執行

沒有留言:

張貼留言