2015年4月8日 星期三

Week07 02160580課堂作業

鍵盤點擊和滑鼠點擊做出指令
#include <GL/glut.h>
#include <stdio.h>
#include <mmsystem.h>
void display()
{
    glutSolidTeapot(0.3);
    glFlush();
}
void keyboard(unsigned char key,int x,int y)
{
    if(key=='1') PlaySound("Do.wav",NULL,SND_ASYNC);
    if(key=='2') PlaySound("Re.wav",NULL,SND_ASYNC);
    if(key=='3') PlaySound("Mi.wav",NULL,SND_ASYNC);
    if(key=='4') PlaySound("Fa.wav",NULL,SND_ASYNC);
    if(key=='5') PlaySound("Sol.wav",NULL,SND_ASYNC);
    if(key=='6') PlaySound("La.wav",NULL,SND_ASYNC);
    if(key=='7') PlaySound("Si.wav",NULL,SND_ASYNC);
}
void mouse(int button,int state,int x,int y)
{
    printf("now playing sound\n");
    PlaySound("ak47.wav",NULL,SND_ASYNC);
    PlaySound("glassbreak2.wav",NULL,SND_ASYNC);
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMainLoop();
}

音檔要放在freeglut->bin資料夾裡面

沒有留言:

張貼留言