2024年5月30日 星期四

week15

 week15-1_PlaySound


#include<windows.h>

```


```cpp

int main(....)

{

    PlaySound("檔名.wav",NULL,SND_ASYNC);

}

ASYNC:不等待直接執行

SYNC:等上一個音頻結束後再撥

 week15-2_PlaySound_empty

透過輸入一個數讓音樂停止



透過按鍵來發出音檔

week15-3_CMP3_MCI

把老師的音檔丟進專案資料夾

#include "CMP3_MCI.h"

CMP3_MCI myMP3;


```cpp

int main()

{

    myMP3.Load("song.mp3");

    myMP3.Play();

}
week15-4_ouse_motion_translate_rotate


用滑鼠移動茶壺

#include <GL/glut.h>



float angleX[10]={},angleY[10]={};

float teapotX=0,teapotY=0;

void display()

{


    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glPushMatrix();

        glTranslatef(teapotX,teapotY,0);

        glutSolidTeapot(0.3);

    glPopMatrix();

    glutSwapBuffers();


}

int oldX=0,oldY=0;

void mouse(int button,int state,int x,int y){

    oldX=x;

    oldY=y;

}

void motion(int x,int y)

{

    teapotX += (x-oldX)/150.0;

    teapotY += (y-oldY)/150.0;

    oldX=x;

    oldY=y;

    glutPostRedisplay();

}


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


{


    glutInit(&argc, argv);


    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);


    glutCreateWindow("week15-4");


    glutDisplayFunc(display);

    glutMouseFunc(mouse);

    glutMotionFunc(motion);


    glutMainLoop();


}

 


沒有留言:

張貼留言