2019年3月15日 星期五

想睡覺_week04


第三周作業,用滑鼠控制小畫家輔助畫出

更好的作品



glRotatef(角度,轉x,轉y,轉z);

(轉哪個軸是只繞著那個軸轉)



#include <GL/glut.h>
float x=0,y=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//滑鼠移動
    glPushMatrix();
    glTranslatef((x-150)/150.0,-(y-150)/150.0,0);//以視窗內座標決定移動位置
    //glColor3f(0.8,0.6,0);
    glutSolidTeapot(0.3);
    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("week03 translate 06160095");
    glutDisplayFunc(display);
    glutMotionFunc(motion);//執行
    glutMainLoop();

}

http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/



glRotatef(y,1,0,0);

(角度y,沿著x軸旋轉,y不轉,z不轉)

沒有留言:

張貼留言