2024年5月30日 星期四

week15

 #Week15

##week15-1_PlaySound

0.安裝freeglut

1.File-New-Project,GLUT專案week15-1_PlaySound

```cpp

#include <windows.h>///第1行

‵‵‵


‵‵‵cpp

int main(....)

{///mykbeat.wav放在C:\裡,NULL,SND_ASYNC撥放音樂

PlaySound("C:/Do.wav",NULL,SND_SYNC);///沒有A同步等待

    PlaySound("C:/Re.wav",NULL,SND_SYNC);

    PlaySound("C:/Mi.wav",NULL,SND_SYNC);

    PlaySound("C:/Fa.wav",NULL,SND_SYNC);

    PlaySound("C:/Sol.wav",NULL,SND_SYNC);

    PlaySound("C:/mykbeat.wav",NULL,SND_ASYNC);///有A不同步/不等待

##week15-2_PlaySound_empty
1.File-New-Project,GLUT專案

week15-2_PlaySound_empty
2.把程式碼全刪
#include <windows.h>
int main()
{
        PlaySound("C:/Do.wav",NULL,SND_SYNC);
        PlaySound("C:/mykbeat.wav",NULL,SND_ASYNC);不等待
        printf("請輸入一個整數: ");
        int n;
        scanf("%d",&n);卡住
}
現在要把工作執行目錄Project-Properties的第2分頁
Execution working dir改成小數點

##week15-3_CMP3_MCI
1.File-New-Project,GLUT專案week15-3_CMP3_MCI
2.把CMP3_MCI.h和sone.mp3和freeglut.dll都放在專案裡
3.把工作執行目錄改成小數點
‵‵‵cpp
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
‵‵‵
在main()裡
‵‵‵cpp
int main(...)
{
  myMP3.Load("song.mp3");
    myMP3.Play();
##week15-4_mouse_motion_translate_rotate
1.File-New-Project,GLUT專案week15-4_mouse_motion_translate_rotate
#include <GL/glut.h>
#include <stdio.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;
    printf("gluTranslatef(%.3f,%.3f,0);\n",teapotX,teapotY);
    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();

}
視窗轉動








沒有留言:

張貼留言