2019年3月21日 星期四

yoyoyo190321

1. 下載data,glut32.dll,window
 
2.把紅圈圈放進資料夾之後 打開橘色圈圈


3.打開長這樣~~~


4.讓茶壺會轉動的程式碼~~~~~


#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    ///用clear才不會有殘影 更新顏色(?)和3D深度
    glPushMatrix();
        glRotatef(angle,0,1,0);///轉角度
        glutSolidTeapot( 0.3 );
    glPopMatrix();
    glutSwapBuffers();
    angle+=3;
}
 int main(int argc, char**argv)
{
     glutInit(&argc,argv);
     glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
     glutCreateWindow("Week05 rotate");
     glutDisplayFunc(display);
     glutIdleFunc(display);
     glutMainLoop();
}

5.讓茶壺變成 可以用滑鼠控制轉動的茶壺


#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    ///用clear才不會有殘影 更新顏色(?)和3D深度
    glPushMatrix();
        glRotatef(angle,0,1,0);///轉角度
        glutSolidTeapot( 0.3 );
    glPopMatrix();
    glutSwapBuffers();
    ///angle+=3;
}
void motion(int x,int y)
{
    angle=x;///加這個
    display();///和這個
}
 int main(int argc, char**argv)
{
     glutInit(&argc,argv);
     glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
     glutCreateWindow("Week05 rotate");
     glutDisplayFunc(display);
     glutIdleFunc(display);
     glutMotionFunc(motion);///還有這個
     glutMainLoop();
}

6.可以用滑鼠 左中右鍵  控制的茶壺

0是左鍵
1是中鍵
2是右鍵
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    ///用clear才不會有殘影 更新顏色(?)和3D深度
    glPushMatrix();
        glRotatef(angle,0,1,0);///轉角度
        glutSolidTeapot( 0.3 );
    glPopMatrix();
    glutSwapBuffers();
    ///angle+=3;
}
void motion(int x,int y)
{
    angle=x;///加這個
    display();///和這個
}
#include <stdio.h>
void mouse(int button,int state ,int x,int y)
{
    printf("%d %d %d %d\n", button, state, x, y);
}
 int main(int argc, char**argv)
{
     glutInit(&argc,argv);
     glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
     glutCreateWindow("Week05 rotate");
     glutDisplayFunc(display);
     glutIdleFunc(display);
     glutMotionFunc(motion);///還有這個
     glutMouseFunc(mouse);
     glutMainLoop();
}

沒有留言:

張貼留言