Week11-1
CodeBlocks開啟,glut專案,命名week11-1_keyboard
打程式碼出現水壺
#include <GL/glut.h>
void display()
{
glutSolidTeapot( 0.3 );
glutSwapBuffers();
}
void keyboard(unsigned char key, int x , int y)
{
if(key==27) exit(0);
}
int main(int argc, char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week11");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
}
#include <windows.h>
#include <GL/glut.h>
void display()
{
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();
}
按鍵盤123會出現對應的音高
Week11-3
Ctrl+Shift+s 儲存所有
關掉,然後直接開一個檔案
int main()
{
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\do.wav", NULL , SND_ASYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\ra.wav", NULL , SND_ASYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\mi.wav", NULL , SND_ASYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\fa.wav", NULL , SND_ASYNC);
PlaySound("C:\\Users\\Administrator\\Desktop\\do_re_mi\\so.wav", NULL , SND_ASYNC);
}
Week11-4
再創一個GLUT專案 命名為week11-4_GLUT_mp3 可播放MP3音樂
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
int main(int argc, char *argv[])
{
char filename[] = "C:/Users/Administrator/Desktop/do_re_mi/suzumi.mp3";
myMP3.Load(filename);
myMP3.Play();///step02-2播放
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);



.png)
.png)

沒有留言:
張貼留言