2019年3月21日 星期四

uh-oh~可恩的上課筆記 Week05


                        狐界顏質擔當                   




Week3.一樣載 1.windows.zip  2. data.zip 3.glut32.dll
windows.zip解壓縮

然後開啟Transformation



                        觀看glRotatef(角度,X,軸Y軸,Z軸);

                                              安培右手
                                      
                    看準X,Y,Z軸就會了 用飛機圖比較好懂,不要用車車


week1.一樣開啟GLUT

自動旋轉                                                                 



                                         
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT  |     GL_DEPTH_BUFFER_BIT);
    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("06161110_Week05!!");
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMainLoop();


}




滑鼠讓他轉                                                             

#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT  |GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(angle, 0,1,0);
        glutSolidTeapot( 0.3 );
    glPopMatrix();
    glutSwapBuffers();

}
void motion(int x,int y)
{
    angle=x;
    display();
}

int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("06161110_Week05!!");
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();

}

#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT  |GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(angle, 0,1,0);
        glutSolidTeapot( 0.3 );
    glPopMatrix();
    glutSwapBuffers();

}
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("06161110_Week05!!");

    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMotionFunc(motion);
    glutMouseFunc(mouse);

    glutMainLoop();

}


沒有留言:

張貼留言