2024年6月16日 星期日

fangg week15

 ##week15


##week15-1_PlaySound

```cpp

#include <window.h>

#include<GL/glut.h>

int main()

{

    PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME);

}

去找wav檔 (不能是MP3檔)


改工作的地方


##week15-2_CMP3_MCT


```cpp

#include "CMP3_MCI.h" //記得用雙引號,不能用小括號

CMP3_MCI myMP3; //宣告一個變數,名字叫 myMP3

int main()

{

    myMP3.Load("filename.mp3");

    myMP3.Play();


    int a;

    scanf("%d", &a);

}


##week15-2_CMP3_MCI_sample

不要刪除177行程式,我們要共存

```cpp

#include "CMP3_MCI.h"

CMP3_MCI myMP3;

```

再插入

```cpp

    myMP3.Load("檔名.mp3");

    myMP3.Play();

```

要把mp3檔,放在「工作執行目錄」


##week15-3_mouse_motion_glTranslatef_glRotatef

貼上11GLUT簡單版本(今天不用,不用OpenCV)

```cpp

#include <GL/glut.h>

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

void display(){


    ///glClearColor(1,1,0,1);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    glPushMatrix();

        glTranslatef(angleX[14], angleY[14], 0);

        glRotatef(angleX[0], 1, 0, 0);

        glRotatef(angleY[0], 0, 1, 0);

        glutSolidTeapot(0.3);

    glPopMatrix();


    glutSwapBuffers();

}

int angleID = 0, oldX = 0, oldY = 0;

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

    oldX = x;

    oldY = y;

}

void motion(int x, int y){

    angleX[angleID] += x - oldX;

    angleY[angleID] += y - oldY;

    oldX = x;

    oldY = y;

    glutPostRedisplay();

}

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

    if(key=='x') angleID = 14;

}

int main(int argc, char**argv)

{

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

    glutCreateWindow("week15-3");

    glutDisplayFunc(display);

    glutKeyboardFunc(keyboard);

    glutMouseFunc(mouse);

    glutMotionFunc(motion);

    glutMainLoop();


}


可用滑鼠調整茶壺角度

沒有留言:

張貼留言