2021年4月26日 星期一

black week10

 Week10

1.播放聲音


2.自彈音樂

3.不用按enter播放

4.滑鼠播放

5.播放mp3
程式碼:

#include <windows.h>
#include <GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI MP3;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
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);
}
void mouse(int botton,int state,int x,int y)
{
    if(state==GLUT_DOWN)PlaySound("shot.wav",NULL,SND_ASYNC);
}
int main(int argc,char**argv)
{
    MP3.Load("music.mp3");
    MP3.Play();
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week10 sound");

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

沒有留言:

張貼留言

Week18期末作業(橘貓的跳舞熊熊)

 期末作業(橘貓的跳舞熊熊) 影片: https://youtu.be/R89tptMaQZw 程式碼: #include <opencv/highgui.h> #include <opencv/cv.h> #include <GL/glut.h...