2023年3月2日 星期四

Ja week03

 1.跑transformation

去老師的網站下載檔案
jsyeh.org/3dcg10


下載windows,data再去解壓縮,把data移動到windows裡,再開transformation


2.

step02-1
去codeblocks打開新專案,名稱設week03-1_translate,freeglut裡的lib其中一個檔案名字改成freeglut32.a

去github把上星期寫的程式貼上去
#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("week03");
    glutDisplayFunc(display);
    glutMainLoop();
}


step02-2
把程式放在githubgist上,再用html檢視

step02-3



3.

step03-1




輸入程式碼,用global變數來移動茶壺的座標
#include<GL/glut.h>
float X=0,Y=0,Z=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(X,Y,Z);
        glutSolidTeapot( 0.3 );
    glPopMatrix();
    glutSwapBuffers();
}
void mouse(int button,int state,int x,int y)
{
    X=(x-150)/150.0;
    Y=-(y-150)/150.0;

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

step3-2

使用printf

step3-3

用滑鼠點座標,在小黑窗按enter複製,再貼上座標,圖就可以畫出來!




沒有留言:

張貼留言