顯示具有 04160401_劉念慈 標籤的文章。 顯示所有文章
顯示具有 04160401_劉念慈 標籤的文章。 顯示所有文章

2017年7月1日 星期六

2017年6月11日 星期日

Week13 劉念慈的上課筆記

主題: 
         (1) 小考:T-R-T 觀念
         (2) 上周範例
         (3) 讀圖檔
         (4) 轉動的地球
         (5) 回家作業:機器人

TODO 1: 
 T-R-T 觀念

glPushMatrix(); // 10%
glTranslatef(0.6, 0.4, 0);  // 20%  (3)最後把"會照著手肘中心轉動的手"移動、掛到真的世界的畫面裡
glRotatef(-80, 0, 0.1);  // 20%  (2)旋轉(小心,轉動的正負號,要想一下右手定則)
glTranslatef(0.3, 0.3, 0);  // 20%  (1)把手肘(轉動中心)移到畫面的中心(負向、倒過來移喔)
drawHand();  // 20% , (0)  畫手,位置不能錯,從下往上看
glPopMatrix();  // 10%




TODO 2: 
讀圖檔
(1) Google:opencv 2.1 download (安裝,小心PATH,第3個認定PATH)
(2) CodeBlock,新專案   
    右上角 Console App貝殼專案
    設定專案 Build Options...
    咒語Linker Setting (cv210 , cxcore210 , highgui210))
          Compiler  include ; C:\opencv2.1\include
          Linker  lib ; C:\open2.1\lib





















#include <opencv/highgui.h> ///(opencv目錄)High高級GUI使用者介面
int main()
{
    IplImage * img =cvLoadImage("c:/image.png"); ///自己準備好    
cvShowImage("my2DImage",img); ///秀圖
    cvWaitKey(0); ///等一下,程式不要結束

}











TODO 3: 
 轉動的地球

#include <opencv/highgui.h> ///for cvLoadImage()
#include <opencv/cv.h> ///for cvCvtColor()
#include <GL/glut.h> ///3D glut
#include <stdio.h>
GLUquadric * quad;
GLuint id;
float angle=0;
void display()
{  
glEnable(GL_DEPTH_TEST); ///要啟動 Detph Test 深度值的測試,3D顯示才正確
    glClear(GL_COLOR_BUFFER_BIT  | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();///自動轉很帥
        glRotatef(90, 1,0,0);
        glRotatef(angle, 0,0,1);///自動轉很帥
        gluQuadricTexture(quad, 1);
        gluSphere(quad, 1, 30, 30);///glutSolidTeapot(0.3);
    glPopMatrix();///自動轉很帥
    glFlush();
}
void timer(int t)
{  
glutTimerFunc(20, timer, 0);/// 1000 msec   50fps:20msec
    angle+=1;///自動轉很帥
    glutPostRedisplay();
}
int myTexture(char *filename)
{
    IplImage * img = cvLoadImage(filename); ///OpenCV讀圖
    cvCvtColor(img,img, CV_BGR2RGB); ///OpenCV轉色彩 (需要cv.h)
    glEnable(GL_TEXTURE_2D); ///1. 開啟貼圖功能
    GLuint id; ///準備一個 unsigned int 整數, 叫 貼圖ID
    glGenTextures(1, &id); /// 產生Generate 貼圖ID
    glBindTexture(GL_TEXTURE_2D, id); ///綁定bind 貼圖ID
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); /// 貼圖參數, 超過包裝的範圖T, 就重覆貼圖
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); /// 貼圖參數, 超過包裝的範圖S, 就重覆貼圖
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); /// 貼圖參數, 放大時的內插, 用最近點
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); /// 貼圖參數, 縮小時的內插, 用最近點
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img->width, img->height, 0, GL_RGB, GL_UNSIGNED_BYTE, img->imageData);
    return id;
}
void myInit()
{  
    quad = gluNewQuadric();
    id = myTexture("image.jpg");
}
int main(int argc, char**argv)
{  
    glutInit(&argc, argv);
    glutCreateWindow("3D");
    glutDisplayFunc(display); ///顯示
    glutTimerFunc(0, timer, 0);
    myInit(); ///我的 init 初始化 把貼圖準備好 前面OpenCV 2行, 後面 OpenGL 9行
    glutMainLoop();
}


week_01 劉念慈的上課筆記

TODO 1 :  WebGL Water

















TODO 2 : OpenGL (會轉的三角形)



TODO 3 :  GLUT



TODO 4 :  GLUT (畫茶壺) 由上面的程式碼簡化而來

程式碼
#include <GL/glut.h>

static void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glutSolidTeapot(0.3);

    glutSwapBuffers();
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("GLUT Shapes");

    glutDisplayFunc(display);

    glutMainLoop();

    return EXIT_SUCCESS;
}


week_16 劉念慈的上課筆記

電腦圖學20170606

主題:

1.下周期末作品Demo
2.內差公式v.s動作
3.存檔.讀檔
4.利用Timer自動內插
5.學期複習
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
Todo1:用Excel試內插公式=A2*newValue+(1-A2)*oldValue



Todo2:存檔案(同學作業範例)

int oldX=0,oldY=0;
FILE * fout=NULL;///存檔的步驟2, 宣告一個檔案的指標, (一開始是空的NULL)
void keyboard(unsigned char key,int x,int y)
{
    printf("%c\n", key);///你按了什麼鍵,印出來,方便了解老師按了什麼鍵
    if(key=='s'){///存檔的步驟3, 在按下 's' 鍵 save存檔
        if(fout == NULL){/// (一開始是空的NULL)
            fout = fopen("file.txt", "w+");///開啟檔案,檔名準備好, 並且是用 write加 模式
            printf("現在開啟一個檔案file.txt, w+模式\n");
        }
        printf("想要寫這些數值到檔案%f %f %f %f %f %f %f %f %f\n", angle[0], angle[1], angle[2], angle[3], angle[4], angle[5], angle[6], angle[7], angle[8]);
        fprintf( fout, "%f %f %f %f %f %f %f %f %f\n", angle[0], angle[1], angle[2], angle[3], angle[4], angle[5], angle[6], angle[7], angle[8]);
    }

    if(key=='0') now=0;
    if(key=='1') now=1;
    if(key=='2') now=2;
    if(key=='3') now=3;
    if(key=='4') now=4;
    if(key=='5') now=5;
    if(key=='6') now=6;
    if(key=='7') now=7;
    if(key=='8') now=8;
}
void mouse(int button,int state,int x,int y)
{
    oldX=x;  oldY=y;
    glutPostRedisplay();
}
void motion(int x,int y)
{
    angle[now]+=(x-oldX);
    oldX=x;
    glutPostRedisplay();
}














Todo3:讀檔案

int oldX=0,oldY=0;
FILE * fout=NULL;///存檔的步驟2, 宣告一個檔案的指標, (一開始是空的NULL)
FILE * fin=NULL;///讀檔的步驟1, 宣告一個檔案的指標, (一開始是空的NULL)
void keyboard(unsigned char key,int x,int y)
{
    printf("%c\n", key);///你按了什麼鍵,印出來,方便了解老師按了什麼鍵
    if(key=='s'){///存檔的步驟3, 在按下 's' 鍵 save存檔
        if(fout == NULL){/// (一開始是空的NULL)
            fout = fopen("file.txt", "w+");///開啟檔案,檔名準備好, 並且是用 write加 模式
            printf("Now open file.txt for write+ Mode\n");
        }
        printf("Now write angle[] %f %f %f %f %f %f %f %f %f\n", angle[0], angle[1], angle[2], angle[3], angle[4], angle[5], angle[6], angle[7], angle[8]);
        fprintf( fout, "%f %f %f %f %f %f %f %f %f\n", angle[0], angle[1], angle[2], angle[3], angle[4], angle[5], angle[6], angle[7], angle[8]);
    }
    if(key=='r'){///讀檔的步驟2, 按下 'r' 去read
        if(fin == NULL){
            fin = fopen("file.txt", "r");///讀檔的步驟3,檔名準備好, 並且是用 read 模式
            printf("Now open file.txt for read Mode\n");
        }
        fscanf(fin, "%f %f %f %f %f %f %f %f %f", &angle[0], &angle[1], &angle[2], &angle[3], &angle[4], &angle[5], &angle[6], &angle[7], &angle[8]);
        printf("Now read angle[] Pa Pa Pa\n");   ///讀檔的步驟 fscanf()讀進來
        glutPostRedisplay();
    }

    if(key=='0') now=0;
    if(key=='1') now=1;
    if(key=='2') now=2;
    if(key=='3') now=3;
    if(key=='4') now=4;
    if(key=='5') now=5;
    if(key=='6') now=6;
    if(key=='7') now=7;
    if(key=='8') now=8;
}
void mouse(int button,int state,int x,int y)
{
    oldX=x;  oldY=y;
    glutPostRedisplay();
}
void motion(int x,int y)
{
    angle[now]+=(x-oldX);
    oldX=x;
    glutPostRedisplay();
}




Todo3:Timer自動內插
void timer(int t)
{
    glutTimerFunc(10, timer, t+1);
    if(fin == NULL){
        fin = fopen("file.txt", "r");///讀檔的步驟3,檔名準備好, 並且是用 read 模式
        printf("Now open file.txt for read Mode\n");
        fscanf(fin, "%f %f %f %f %f %f %f %f %f", &newAngle[0], &newAngle[1], &newAngle[2], &newAngle[3], &newAngle[4], &newAngle[5], &newAngle[6], &newAngle[7], &newAngle[8]);
    }

    if(alpha >= 1.0){///如果讀太多,alpha超過了, 就要再讀新的angle, 而且要把原來新的,先變舊的
        /// oldAngle = newAngle
        for(int i=0;i<9;i++) oldAngle[i] = newAngle[i];
        /// read newAngle
        fscanf(fin, "%f %f %f %f %f %f %f %f %f", &newAngle[0], &newAngle[1], &newAngle[2], &newAngle[3], &newAngle[4], &newAngle[5], &newAngle[6], &newAngle[7], &newAngle[8]);
        printf("Now read angle[] Pa Pa Pa\n");   ///讀檔的步驟 fscanf()讀進來
        alpha=0.0;
    }

    ///angle = alpha * newAngle + (1-alpha)* oldAngle;
    for(int i=0;i<9;i++){///小心, 角度不見得只有9個,可能更多哦! 要調好,有更多,就要內插更多 ex. 20個
        angle[i]=alpha*newAngle[i] + (1-alpha)*oldAngle[i];///現在要改成交叉相乘的內插方式算角度
    }
    alpha += 0.01;///現在要改成交叉相乘的內插方式算角度, 每次加一點點alpha

    glutPostRedisplay();
}

........

 glutTimerFunc(1000,timer,0);



Week14 劉念慈的上課筆記

20170523

電腦圖學

課堂作業:
(1)上周作業
(2)讓機器人動
(3)Timer計時器
(4)鍵盤滑鼠控制
(5)機器人2.0
-------------------------------------------------------------------------------------------------------------
TODO1:(用邱繼儀範例)
(1)cdp專案檔
    用Nope++開include目錄
    lib目錄設對
    working目錄設" 。"


TODO2:
計時器
week14_01timer.cpp

#include <stdio.h>
void timer(int t)
{
    printf("現在我起床了,t是%d...",t);
    glutTimerFunc(100,timer,t+1);
    printf("我撥了一個新的timer....");
    angle+=3;
    glutPostRedisplay();
    printf("記得重畫畫面哦! 我睡了,byb\n");


}
....


 ///glutIdleFunc(display);
glutTimerFunc(2000,timer,0);





TODO3:
機器人動(用計時器)
Week14_02pushTRTpop-Left.cpp
Week14_03pushTRTpop-Right.cpp

glPushMatrix( )
        glPushMatrix( );  ///Left Part
            glTranslatef(-0.22,+0.35,0);///(3)最後,把它掛在對的位置
            glRotatef(-angle,0,0,1);///(1)先轉動
            glTranslatef(-0.1,0.25,0);///(2) move the rotate center to center
            drawArm0();

            glTranslatef(-0.48,+0.1,0);///(3)最後,把它掛在對的位置
            glRotatef(-angle,0,0,1);///(1)先轉動
            glTranslatef(0.48,-0.1,0);///(2)接著將旋轉中心,放到真的中心,記得把樓上先註解掉
            drawArml();
            glPopMatrix();

        glPopMatrix();



















TODO4:

鍵盤滑鼠控制


程式 :
#include <string.h>
#include <stdlib.h>
#include <GL/glut.h>
#include "glm.h"
GLMmodel* pmodel = NULL;
GLMmodel* pmodel2 = NULL;
GLMmodel* pmodel3 = NULL;
GLMmodel* pmodel4 = NULL;
GLMmodel* pmodel5 = NULL;
GLMmodel* pmodel6 = NULL;
GLMmodel* pmodel7 = NULL;
GLMmodel* pmodel8 = NULL;
float angle[20] = {} ;///全家都是零
int now=0;
void drawBody()
{
    glPushMatrix( );  ///body
        glTranslatef(0,0.1,0);///T
        glRotatef(90,0,0,1);///R
        glRotatef(90,0,1,0);
        glRotatef(90,0,0,1);
        glRotatef(180,1,0,0);
        glTranslatef(0,0.5,0);///T
        glScalef(0.3,0.3,0.3);
        glmDraw(pmodel3, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix();
}
void drawArm0()
{
    glPushMatrix( );  ///left hand arm
        glTranslatef(-0.25,0.1,0);///T
        glRotatef(45,0,0,1);///R
        glTranslatef(0,0.2,0);///T
        glScalef(0.25,0.25,0.25);
        glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix();
}
void drawArm1()
{
    glPushMatrix( );  ///left hand
        glTranslatef(-0.25,0,0);///T
        glRotatef(90,0,0,1);///R
        glTranslatef(-0.1,0.25,0);///T
        glScalef(0.25,0.25,0.25);
        glmDraw(pmodel2, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix();
}
void drawRArm()
{
    glPushMatrix( );  ///Right hand arm
        glTranslatef(0.25,0.1,0);///T
        glRotatef(180,0,0,1);///R
        glRotatef(180,1,0,0);
        glRotatef(45,0,0,1);
        glTranslatef(0,0.2,0);///T
        glScalef(0.25,0.25,0.25);
        glmDraw( pmodel, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix( );
}
void drawRhand()
{
    glPushMatrix( );  ///Right hand
        glTranslatef(0.5,0,0);///T
        glRotatef(180,0,0,1);///R
        glRotatef(180,1,0,0);
        glRotatef(90,0,0,1);
        glTranslatef(-0.1,0,0);///T
        glScalef(0.25,0.25,0.25);
        glmDraw( pmodel2, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix( );
}
void drawHead()
{
    glPushMatrix( );  ///head
        glTranslatef(0,1,0);///T
        glTranslatef(0,-0.3,0);///T
        glScalef(0.3,0.3,0.3);
        glmDraw( pmodel4, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix( );
}
void drawRleg()
{
    glPushMatrix( );  ///Right Leg up
        glTranslatef(-0.15,-0.3,0);///T
        //glTranslatef(0,-0.2,0);///T
        glScalef(0.3,0.5,0.3);
        glmDraw( pmodel5, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix( );
}
void drawLleg()
{
    glPushMatrix( );  ///Left Leg up
        glTranslatef(0.15,-0.3,0);///T
        //glTranslatef(0,-0.2,0);///T
        glScalef(0.3,0.5,0.3);
        glmDraw( pmodel6, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix( );
}
void drawRfoot()
{
    glPushMatrix( );  ///Right Leg low
        glTranslatef(-0.2,-0.65,0);///T
        glRotatef(180,0,1,0);
        //glTranslatef(0,-0.2,0);///T
        glScalef(0.5,0.75,0.5);
        glmDraw( pmodel7, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix( );
}
void drawLfoot()
{
    glPushMatrix( );  ///Left Leg low
        glTranslatef(0.2,-0.65,0);///T
        glRotatef(180,0,1,0);
        //glTranslatef(0,-0.2,0);///T
        glScalef(0.5,0.75,0.5);
        glmDraw( pmodel8, GLM_SMOOTH | GLM_MATERIAL);
    glPopMatrix( );
}
void display()
{
    glClearColor(1,248/255.0,203/255.0,24/255.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix( );
        //angle++;
        //glRotatef(angle, 0,1,0);
        if (!pmodel)
        {
             pmodel = glmReadOBJ("obj/dolphins1.obj");
             if (!pmodel) exit(0);
             glmUnitize(pmodel);
             glmFacetNormals(pmodel);
             glmVertexNormals(pmodel, 90.0);
        }
        if (!pmodel2)
        {
             pmodel2 = glmReadOBJ("obj/dolphins2.obj");
             if (!pmodel2) exit(0);
             glmUnitize(pmodel2);
             glmFacetNormals(pmodel2);
             glmVertexNormals(pmodel2, 90.0);
        }
        if (!pmodel3)
        {
             pmodel3 = glmReadOBJ("obj/porsche.obj");
             if (!pmodel3) exit(0);
             glmUnitize(pmodel3);
             glmFacetNormals(pmodel3);
             glmVertexNormals(pmodel3, 90.0);
        }
        if (!pmodel4)
        {
             pmodel4 = glmReadOBJ("obj/soccerball.obj");
             if (!pmodel4) exit(0);
             glmUnitize(pmodel4);
             glmFacetNormals(pmodel4);
             glmVertexNormals(pmodel4, 90.0);
        }
        if (!pmodel5)
        {
             pmodel5 = glmReadOBJ("obj/Upleg_R.obj");
             if (!pmodel5) exit(0);
             glmUnitize(pmodel5);
             glmFacetNormals(pmodel5);
             glmVertexNormals(pmodel5, 90.0);
        }
        if (!pmodel6)
        {
             pmodel6 = glmReadOBJ("obj/Upleg_L.obj");
             if (!pmodel6) exit(0);
             glmUnitize(pmodel6);
             glmFacetNormals(pmodel6);
             glmVertexNormals(pmodel6, 90.0);
        }
        if (!pmodel7)
        {
             pmodel7 = glmReadOBJ("obj/Lowleg_R.obj");
             if (!pmodel7) exit(0);
             glmUnitize(pmodel7);
             glmFacetNormals(pmodel7);
             glmVertexNormals(pmodel7, 90.0);
        }
        if (!pmodel8)
        {
             pmodel8 = glmReadOBJ("obj/Lowleg_L.obj");
             if (!pmodel8) exit(0);
             glmUnitize(pmodel8);
             glmFacetNormals(pmodel8);
             glmVertexNormals(pmodel8, 90.0);
        }
        glPushMatrix();
            //drawBody();
            glutSolidTeapot(0.03);
            glPushMatrix();///Left Part
                glTranslatef(-0.22, +0.35, 0);///(3) 最後,把它掛在對的位置
                glRotatef(-angle[0], 0,0,1); ///(1) 先轉動
                glTranslatef(0.22, -0.35, 0);///(2) move the rotate center to center
                drawArm0();
                glTranslatef(-0.48, +0.1, 0);///(3)  最後,把它掛在對的位置
                glRotatef(-angle[1], 0,0,1);///(1) 先轉動
                glTranslatef(0.48, -0.1, 0);///(2) 接著將旋轉中心,放到真的中心, 記得把樓上先註解掉
                drawArm1();
            glPopMatrix();
            glPushMatrix();///Right Part
                glTranslatef(+0.2, +0.36, 0);///3
                glRotatef(angle[2], 0,0,1); ///(1)
                glTranslatef(-0.2, -0.36, 0);///(2)
                drawRArm();
                glTranslatef(+0.48, +0.1, 0);///(3)
                glRotatef(angle[3], 0,0,1);///(1)
                glTranslatef(-0.48, -0.1, 0);///(2)
                drawRhand();
            glPopMatrix();

        glPopMatrix();
        drawHead();
        drawRleg();
        drawRfoot();
        drawLleg();
        drawLfoot();
    glPopMatrix( );
    glutSwapBuffers( );
}
const GLfloat light_ambient[ ]  = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[ ]  = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[ ] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[ ] = { 2.0f, 5.0f, -5.0f, 0.0f };
const GLfloat mat_ambient[ ]    = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[ ]    = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[ ]   = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[ ] = { 100.0f };
#include <stdio.h>
void timer(int t)
{
    printf("現在我起床了, t是%d...", t);
    glutTimerFunc(100, timer, t+1);
    printf("我撥了一個新的timer....");
    //angle+=3;
    glutPostRedisplay();
    printf("記得重畫畫面哦! 我睡了, bye\n");
}
int oldX=0, oldY=0;
void keyboard(unsigned char key, int x, int y)
{
    if(key=='0')now=0;
    if(key=='1')now=1;
    if(key=='2')now=2;
    if(key=='3')now=3;
    if(key=='4')now=4;
}
void mouse(int button, int state, int x, int y)
{
    oldX=x; oldY=y;
    glutPostRedisplay();
}
void motion(int x, int y)
{
    angle[now] += (x-oldX);
    oldX=x;
    glutPostRedisplay();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB);
    glutCreateWindow("04160683's Robbot.");
    glutDisplayFunc(display);
    ///glutIdleFunc(display);
    ///glutTimerFunc(2000, timer, 0);///睡前,先設定一個鬧鐘,2秒後會叫
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glClearColor(1,1,1,1);
    //glEnable(GL_CULL_FACE);
    //glCullFace(GL_BACK);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glEnable(GL_LIGHT0);
    glEnable(GL_NORMALIZE);
    glEnable(GL_COLOR_MATERIAL);
    glEnable(GL_LIGHTING);
    glLightfv(GL_LIGHT0, GL_AMBIENT,  light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE,  light_diffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
    glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
    glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
    glutMainLoop();
}