2023年3月1日 星期三

Yen的week03

 1.先利用老師的網站下載http://jsyeh.org/3dcg10/下載win data glut32.dill三個檔案

2.解壓縮後打開Transformation成功畫面如下圖


3.下載老師上課資料夾內的freeglut並解壓縮
4.把資料夾內libfreeglut.a複製貼上改為libglut32.a
5.打開codeblocks創建一個glut檔
6.寫出一個茶壺
#include <GL/glut.h>
void display()
{
    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(); 
}
7.調整茶壺往右邊靠
#include <GL/glut.h>
void display()
{
    glPushMatrix();
        glTranslatef(0.5 , 0 , 0);
        glutSolidTeapot(0.3);
    glPopMatrix();

    glutSwapBuffers();
}

int main(int argc, char *argv[])
{
    glutInit(&argc, argv); 
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
   
    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display); 
    glutMainLoop(); 
}


8.顯示滑鼠所在座標

#include <GL/glut.h>
void display()
{
    glPushMatrix();
        glTranslatef(0.5 , 0 , 0);
        glutSolidTeapot(0.3);
    glPopMatrix();

    glutSwapBuffers();
}
#include <stdio.h>
void mouse (int botton , int state , int x , int y)
{
    printf ("%d %d %d %d\n",botton , state , x , y);
}

int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week03");

    glutDisplayFunc(display);
    glutMouseFunc(mouse);

    glutMainLoop();
}



沒有留言:

張貼留言