WAV音檔撥放
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>///為了playSoundA()
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
void mouse(int button, int state, int x, int y)
{
if(state==GLUT_DOWN)PlaySoundA("fart.wav",NULL,SND_SYNC);
}
int main()
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week12 sound");
glutMouseFunc(mouse);
glutDisplayFunc(display);
glutMainLoop();
#include <GL/glut.h>
#include <windows.h>
#include <mmsystem.h>///為了playSoundA()
#include "CMP3_MCI.h"///需要將程式丟在專案裡
CMP3_MCI myMP3;///宣告一個物件變數 myMP3
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
void mouse(int button, int state, int x, int y)
{///mouse點擊會發出聲音
if(state==GLUT_DOWN)PlaySoundA("fart.wav",NULL,SND_SYNC);
}
int main(int argc, char**argv)
{
myMP3.Load("love.mp3");///讀入檔案,執行目錄
myMP3.Play();///播放
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week12 sound");
glutMouseFunc(mouse);
glutDisplayFunc(display);
glutMainLoop();
}


沒有留言:
張貼留言