2016年5月10日 星期二

01370984_CLASS_WORK_WEEK12

Week 12

CLASS WORK 01
1. Download [data][win32][source] and glut32.dll from jsyeh.org/3dcg10 this website.
2. Unzip [data], [win32] and put them into a folder.
3. Unzip [source] and put glm.h, glm.c and transformation.c into same folder.
4. Use Notepad++ to run the source.

CLASS WORK 02
1. Use codeblock to build a new project.
2. Remove main.cpp from project and add glm.cpp, transformation.cpp and glm.h to project.
3. Setting build options.



4. Copy glut.dll to project folder.


CLASS WORK 03

Source code:
#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_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glutMainLoop();
}

沒有留言:

張貼留言