2016年5月10日 星期二

武一可食貳_艾倫穿綠褲還不拉拉鏈

作業一

教材: jsyeh.org/3dcg10

下載[data][win32] glut32.dll 


2.全部解壓縮
   (1)將windows裡面的檔拉進資料夾
   (2)將source裡的glm.c、glm.h、transformation也拉進資料夾
   (3)將data整個拉進資料夾







2.顯示附檔名,並將c改成cpp









3.成功執行exe檔

作業二


1.開一個貝殼專案



3.把原本main.cpp刪除,並且把glm.cpp、transformation.cpp拉進資料夾
4.新增files(glm.cpp、transformation.cpp)


5.compiler(include)、Linker(lib)、咒語(5個)










6.確認資料夾裡面必須有glut32.dll、data資料夾、
glm.cpp、transformation.cpp、glm.h


7.成功執行(若失敗,將視窗拉大即可)













程式碼:

#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_DEPTH | GLUT_DOUBLE);
    glutCreateWindow("3D Model");

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

    glutMainLoop();
}


影片:





沒有留言:

張貼留言