2023年4月27日 星期四

11binggreen

 week11-1_keyboard


#include <GL/glut.h>

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==27) exit(1234);

}


    int main(int argc, char *argv[])

{

    glutInit(&argc, argv);


    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("week11");


    glutDisplayFunc(display);

    glutKeyboardFunc(keyboard);


    glutMainLoop();

}

27是esc鍵


week11-2_keyboard_playsound


#include <windows.h>

#include <GL/glut.h>

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("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_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("week11");


    glutDisplayFunc(display);

    glutKeyboardFunc(keyboard);


    glutMainLoop();

}

week11-3_playsound

不用開glut專案

#include <windows.h>
#include <stdio.h>
int main()
{
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\do.wav",NULL,SND_SYNC);
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\re.wav",NULL,SND_SYNC);
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\mi.wav",NULL,SND_SYNC);
    printf("Hello World\n");
}

SND_ASYNC 不等待 不同步
SND_SYNC    要等待 同步
咒語 在linker add winmm


目錄可以用 兩個反斜線\\ 或一個斜線/


week11-4_CMP3_ MCI
把cmp3_mci放進week11-4

加紅框的程式







改成小數點




把freeglut.dll和suzume.mp3都加入week11-4
設定完就不用打長長的目錄







沒有留言:

張貼留言