2016年5月9日 星期一

WEEK12

1.去http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
2.下載



開貝殼專案

專案(左鍵) - Build Options 設定

(a)Search Directories 目錄
      1.Compiler Add  C:\freeglut\include
      2.Linker Add C:\freeglut\lib

(b)Linker Settings
      Add  1.freeglut
              2.opengl32
              3.glu32
              4.gdi32
              5.winmm

刪除原本的 main.cpp
複製下面3個到專案裡
data、freeglut.dll



3.

#include <GL/glut.h>
#include "glm.h"
GLMmodel * pmodel=NULL;

void display()
{

    glClearColor(1,0,0,0);
    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();

}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
    glutCreateWindow("GLM model is great!");
    glutDisplayFunc(display);
    glutMainLoop();

}

沒有留言:

張貼留言