要來塞音樂囉 不知道塞個nyan cat會不會很好笑
第一節課
程式碼:
#include <GL/glut.h>
void display()
{
glutSolidTeapot(0.3);
glutSwapBuffers();
}
void keyboard(unsigned char key, int x, int y)
{
if(key==27) exit(0);//關掉
}//按ESC鍵關掉
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week11");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
}
用 void keyboard(), 呼叫 exit(0) 程式就結束,並return 0
#include <windows.h>
int main()
{
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\do.wav",NULL,SND_SYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\do.wav",NULL,SND_SYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\do.wav",NULL,SND_SYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\re.wav",NULL,SND_SYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\mi.wav",NULL,SND_SYNC);
}
又出問題了在Setting--Compiler的Linker Setting加上winmm,因為實際上PlaySound是在winmm的函式庫裡
最後弄出音樂擋在Notepad++開啟week11-4_glut_mp3目錄中的cbp檔,並將音檔目錄更改為「.」,更改完成後,將檔案儲存,開啟codeblocks檔案,並按下 "Yes"
5. 將freeglut→bin→freeglut.dll、suzumi音檔加入week11-4_glut_mp3目錄中
6.執行即可
沒有留言:
張貼留言