2019年5月2日 星期四

06161082_w5

<旋轉Rotation>
glRotatef()
Examples: [data]、[win32]、glut32.dll>將[win32]解壓縮> 把[data]、glut32.dll、放進[win32]資料夾 > 打開範例Transformation.exe












<代入滑鼠程式碼>
原始程式碼刪除並打入新的程式碼












加入跟著滑鼠旋轉的程式碼(需把angle+=3刪除掉)

#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("06160540");
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMotionFunc(motion);
    glutMouseFunc(mouse);     
    glutMainLoop();
}

沒有留言:

張貼留言