Week11
今天上課的第一個程式先開glut專案
檔名week11-1_keyboard
程式碼全刪加入以下程式碼
#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==27) exit(1234);
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week11");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
}
就會出現下列茶壺
再開一個Glut專案 檔名為week11-2_keyboard_PlaySound
程式碼如下
#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\\so.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();
}
今天的第三個程式
檔名為week11-3_PlaySound.cpp
程式碼如下
#include <windows.h>
#include <stdio.h>
int main()
{
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);
printf("Hello World\n");
}
今天的第四個程式 檔名week11-4_CMP3_MCI_load_Play
將老師傳的檔案CMP3_MCI.h加入week14-4資料夾
加入下列幾行程式
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
char filename[] = "C:/Users/Administrator/Desktop/do-re-mi/suzume.mp3";
myMP3.Load(filename);
myMP3.Play();
今天第三節課
照著圖片去修改
最後要記得save everything
在week11-4資料夾中加入freeglut.dll
沒有留言:
張貼留言