2019年3月14日 星期四

ˊ_>ˋ_Week04-Translate

(1)主題移動 glTranslatef+滑鼠motion

第一個前置作業ˊ_> ˋ 
第1步:進入http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
第2-4步:分別下載Win32/data/glut32.dll


第5-7步:把windows檔解壓縮到windows\(E)-->打開解壓縮後的windows檔-->把data壓縮檔裡的data直接拉進windows檔裡-->再把glut32.dll檔也拉進去windows檔案夾裡


最後:Windows 打開 Transformation.exe檔


點選右鍵各有不一樣的功能-->玩個~



第二個前置作業:
搜尋freeglut transmission-->下載粉紅圈圈的檔案-->把壓縮檔裡的資料夾拉到桌面-->打開資料夾,複製libfreeglut.a檔-->改多複製的libfreeglut.a檔檔名-->把檔名改為libglut32.a-->重開一個Project-->選擇Glut Project-->Next-->修改檔名和儲存資料夾位置到桌面-->回到freeglut資料夾,點上方freeglut-->複製路徑-->把freeglut路徑貼上-->Finish-->然後把有的原始碼全刪掉-->開始寫TODO作業














(2)TODO:



(3)主題:滑鼠

記得 負號要加XD
glTranslatef( (x-150)/150.0, -(y-150)/150.0, 0 );


#include <GL/glut.h>
float x=0, y=0;
void display()
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glPushMatrix();
     glColor3f(0.5, 0.2, 0.1);
      glTranslatef( (x-150)/150.0, -(y-150)/150.0, 0 );
      glutSolidTeapot(0.2);
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int nowX, int nowY){
    x=nowX; y=nowY;
    display();
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week04");
    glutDisplayFunc(display);
    glutMotionFunc(motion);  ///滑鼠motion
    glutMainLoop();
}




沒有留言:

張貼留言