Week11
Step01-1
新增glut專案
Ctrl-F 在程式碼裡找 keyboard
結合keyboard和撥放音樂 ,新增GLUT專案
更改程式碼讓他按數字鍵對應相對的音效檔
#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_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week11");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
}
Step02-1
新增一個空白的File
先撥放聲音在印出 Hello World
新的GLUT專案。裡面先 #include "CMP3_MCI.h" (要先將CMP3_MCI.h跟GLUT放在同一個路徑),接下來MP3.Load("檔名.mp3")把檔案讀進來,在MP3.Play播放(注意路徑問題)
把所有需要檔案放在同個目錄後進入CodeBlocks
將Project-Properties 裡面的Build targets 的工作執行目錄改為 . (代表同一目錄)
Step03-2
git clone 複製github 資料夾,並將gitignore 用 Notepad++開啟,把*.dll註解(加#)


沒有留言:
張貼留言