2016年5月9日 星期一

Week12

1.
在jsyeh/3dcg10中
下載 windows.zip、data.zip、sourse.zip、glut32.dll
可直接執行模型
2.



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

(2) Linker Settings 中加入
              1.freeglut
              2.opengl32
              3.glu32
              4.gdi32
              5.winmm


3.


#include <GL/glut.h>
#include "glm.h"

GLMmodel* pmodel = NULL;

void display()
{
    glClearColor(0,0,1,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_DEPTH | GLUT_DOUBLE);
    glutCreateWindow("03161042");
    glutDisplayFunc(display);

    glutMainLoop();
}
4.
#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);
     }
     glRotatef(90,0,1,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("GLM model is great!");
    glutDisplayFunc(display);

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

    glutMainLoop();

}


沒有留言:

張貼留言