將模型用於CodeBlocks
先將source壓縮檔壓縮
將GLM檔案放入專案資料夾
利用搜尋去尋找GLM
將專案資料夾中的副檔名顯示出來
再將原本glm.c改為glm.cpp
點選上方的ReBuild
將模型放入freeglut→bin
#include "glm.h"
GLMmodel* pmodel = NULL;
void display()
{
GLfloat pos[] = { 0.0, 0.0, -1.0, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
glFlush();
}
int main(int argc, char **argv)
{
pmodel = glmReadOBJ("porsche.obj");
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
glutInit(&argc, argv);
glutCreateWindow("02160943");
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言