2016年5月9日 星期一

廖婕珊hw12

(1)課堂一

      blog內容複習
     下載http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
      data,win32,glut32.dll,source(glm.h  ,  glm.c  , transformation.c)
     

     

(2)課堂二

    GLUT基礎元件
    開console檔
    
   Search Directory目錄 加  C:\Users\USER\Desktop\freeglut\include
   Linker 加 C:\Users\USER\Desktop\freeglut\lib
   加咒語freeglut / opengl32 / glu32 / gdi32 / winmm
   
   刪掉main.cpp
   
 
    add file
   
 
   複製glm.h  / glm.c / transformation.c 過去
   
 
   data 也複製過去
   

   複製freeglut 過去
   

   開glm.c /transformation.c 兩個檔---執行
   

 
    glm.c改cpp檔
    transformation.c---另存新檔(myOBJ.cpp)
    刪掉原glm.c /transformation.c
    開glm,cpp/ myOBJ.cpp
    刪掉myOBJ.cpp理的程式碼
    自己打--邊複製貼上transformation.c的一些程式碼
   
   
   
   
#include <GL/glut.h>
#include "glm.h"
GLMmodel* pmodel = NULL; ///GLM(型別)

void display()  ///剪貼transformation.c中的程式碼
{
    glClearColor(0,1,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();
}
    

(4)課堂四

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

void display()
{
    glClearColor(0,1,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);
    }
    glPushMatrix();
        glRotatef(130,0,1,0);
        glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix();
    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();
}

沒有留言:

張貼留言