2017年3月20日 星期一

Week 04黃繶秦

下載windows/data/glut32.dll三個檔案
開啟後觀察移動
開啟GLUT檔
寫出茶壺並且更改起始位置
加入程式碼使茶壺可以跟著滑鼠移動
程式碼:
#include <GL/glut.h>
float mouseX=0, mouseY=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(mouseX,mouseY,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x,int y)
{
    mouseX=(x-150)/150.0;
    mouseY=-(y-150)/150.0;
    glutPostRedisplay();
}
int main(int argc,char **argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("04162514 Translate Potate Scale");


    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}
將Translatef改成Scalef
滑鼠即可放大縮小茶壺


沒有留言:

張貼留言