2015年4月8日 星期三

02160403_林禹全_week07

今天是教按鍵盤可以輸出指定單字,滑鼠點擊播放音樂以及當鋼琴使用



#include <GL/glut.h>
#include <mmsystem.h>
#include <stdio.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("Boing0.wav",NULL,SND_ASYNC);
}
int main(int argc,char **argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("hello");

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMainLoop();
}

沒有留言:

張貼留言