1.至NEHE網站 前往LESSON32 課程
2.下載最下面的Visual c++ 範例
3.解壓縮至桌面\Lesson32\lesson32.exe
4.開啟應用程式Lesson32.exe
5開啟CODEBLOCKS 並開啟GLUT專案
6.再加入 #include <mmsystem.h>//多媒體系統
7.與void mouse(int button, int state, int x, int y)
{
PlaySound("data/shot.wav",NULL,SND_ASYNC);
}
跟
glutMouseFunc(mouse);
8.再加入void keyborad(unsigned char key, int x, int y)
{
PlaySound("C:\\Users\\user\\Desktop\\Lesson32\\data/shot.wav",NULL,SND_ASYNC);
}
9加入新涵式void keyborad(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("So.wav",NULL,SND_ASYNC);
}
10.並去網路上下載WAV音樂檔,放入FREE GLUT\\BIN中資料夾
11.這樣按下鍵盤12345就會有12345檔名的聲音
沒有留言:
張貼留言