1.用google搜尋引擎搜尋nehe lesson32
2.下載lesson32壓縮檔
3.將檔案解壓縮
4.
點選是為全螢幕 |
lesson 32.cpp中用playsound
模仿:file-new-project.GLUT
加入#include <mmsystem.h>
void mouse(int button,int state, int x,int y)
{
PlaySound("C:\\users\\user\\Desktsp\\lesson32/data/shot.wav",NULL,SND_ASYNC);
}
再加glutMouseFunc(mouse);
5.鋼琴家入keyboard
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("So.wav",NULL,SND_ASYNC);
}
6.下載音樂檔並加入freeglut-bin
7.將音樂檔位置複製到程式碼
8.程式碼執行時有音樂
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
.
.
.
.
myMP3.Load("C:\\Users\\user\\Desktop\\2017\\yukai.mp3");
myMP3.Play();
沒有留言:
張貼留言