2016年5月10日 星期二

Week 12_胡安俊

下載

windows -- 桌面/ 2016CG/ exe檔

data.zip -- 桌面/ 2016CG/ data/*.obj 、*.mtl

glut32.dll -- 桌面/ 2016CG/ glut32.dll

source.zip -- (glm.h、glm.c、transformation.c) 用Notepad++看



Use Code Blocks
Link : freeglut, opengl32, glu32, gdi32, winmm
#include , lib


C圖案
#include "glm.h"
GLMmodel * pmodel=NULL;

void display()
{
    glutSwapBuffers();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("3D Model ready YA!");

    glutDisplayFunc(display);

    glutMainLoop();
}

打光
#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 ready YA!");
    glutDisplayFunc(display);

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

    glutMainLoop();
}

沒有留言:

張貼留言