2024年5月27日 星期一

week15

  ## week15-1_PlaySound

要在小黑執行可以播放作業

#include <windows.h>

#include <GL/glut.h>

int main()

{

    PlaySound("mykbeat.wav",NULL,SND_SYNC);

}

上網下載wav音樂檔案 放在freeglut的bin資料夾裡面



音樂播完就會結束,所以可以一次播好幾個wav檔案

也不用一定要放在bin資料夾裡

按專案按右鍵選最下面的 properties



改成小數點 . 就不用放在bin 資料夾裡


彈了一個小蜜蜂


#week15-2_CMP3_MCI

因為wav檔案太大很難找到 所以貼一個檔案之後就可以讀入mp3檔案

開啟glut範例檔案 保留 177行 不要刪掉 中間插入四行
在main函式前面插入兩行

#include "CMP3_MCI.h"
CMP3_MCI myMP3;

裡面插入

myMP3.Load("123.mp3");
    myMP3.Play();


最下面的mainLoop 來卡住程式不要太快結束


## week15-3_mouse_motion_glTranslatef_glRotatef


要讓物體可以左右移動位置
先寫完11行程式 再去改

#include <GL/glut.h>
void display(){
    glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glutSwapBuffers();

}
int main()(int argc,char**argv){
    glutInit(&argc, argv);
    glutInitDisplayMode((GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week15-3");
    glutDisplayFunc(display);
    glutMainLoop();
}

改成這樣 確定有畫出模型就可以把背景顏色刪掉


沒有留言:

張貼留言