2023年4月26日 星期三

擦 大哥 Week11 鍵盤、滑鼠、音樂

 Week11 鍵盤、滑鼠、音樂

#include <GL/glut.h>

void display()

{

    glutSolidTeapot(0.3);

    glutSwapBuffers();

}

void keyboard(unsigned char key, int x, int y)

{

    if(key==27) exit(886);

}

int main(int argc,char**argv)

{

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

    glutCreateWindow("week11");

    glutDisplayFunc(display);

    glutKeyboardFunc(keyboard);///新


    glutMainLoop();

}

按esc==關閉視窗

mp3小 wav大

#include <windows.h> 

#include <GL/glut.h>

void display(){

    glutSolidTeapot(0.3);

    glutSwapBuffers();

}

void keyboard(unsigned char key , int x , int y){

    if(key=='1') 

        PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\do.wav",NULL,SND_ASYNC);

    if(key=='2')

        PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\re.wav",NULL,SND_ASYNC);

    if(key=='3')

        PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\mi.wav",NULL,SND_ASYNC);

}

int main(int argc, char**argv){

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

    glutCreateWindow("week11");

    glutDisplayFunc(display);

    glutKeyboardFunc(keyboard);

    glutMainLoop();

}


#include <windows.h>

int main()

{                                                           

    PlaySound("do_re_mi\\do.wav", NULL, SND_SYNC);

    PlaySound("do_re_mi\\re.wav",NULL,SND_SYNC);

    PlaySound("do_re_mi\\mi.wav",NULL,SND_SYNC);

    PlaySound("do_re_mi\\do.wav",NULL,SND_SYNC);

}


CMP3_MCI.h複製至week11-4資料夾


#include "CMP3_MCI.h"
CMP3_MCI myMP3;

int main(int argc, char *argv[])
{
    char filename []="C:/Users/Administrator/Desktop/do_re_mi/suzumi.mp3";
    myMP3.Load(filename);
    myMP3.Play();
}

沒有留言:

張貼留言