2021年3月15日 星期一

Bunny-week04

 

#include <GL/glut.h>///(0)使用GLUT外掛
#include <stdio.h>
float teapotX=0, teapotY=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);///清空
    glPushMatrix();
        glTranslatef(teapotX,teapotY,0);
        glutSolidTeapot(0.3);///實心茶壺
    glPopMatrix();
    glEnd();
    glutSwapBuffers();///交換兩倍的buffers
}

void motion(int x,int y)
{
    teapotX=(x-150)/150.0;
    teapotY=-(y-150)/150.0;
    display();
}
int main(int argc,char ** argv)///以前是int main()
{
    glutInit( &argc, argv );///(1)GLUT初始設定
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);///(2)顯示模式
    glutCreateWindow("08160846");///(3)開窗


    glutDisplayFunc(display);///(4)等一下要顯示函式
    glutMotionFunc(motion);
    glutMainLoop();///(5)主要迴圈
}



沒有留言:

張貼留言

Week18期末作業(橘貓的跳舞熊熊)

 期末作業(橘貓的跳舞熊熊) 影片: https://youtu.be/R89tptMaQZw 程式碼: #include <opencv/highgui.h> #include <opencv/cv.h> #include <GL/glut.h...