2023年4月27日 星期四

week11 UC

 step01-1

先開啟GLUT檔
刪掉原始檔後新增程式碼

#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_RGB|GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week11");

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMainLoop();

}






































step01-2
會結合keyboard會撥放音樂,新增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)
{///step01-1 ///step01-2
    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);
}///step01-2
int main(int argc,char ** argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week11");

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);///step01-1

    glutMainLoop();
}
 


  step02-1
開新專案week11-3_PlaySound.cpp
Setting<Compiler

































step02-2
開新專案week11-4_CMP3_MCI_Load_Play
增加下面這幾行
#include "CMP3_MCI.h"

CMP3_MCI myMP3;
int main(int argc, char *argv[])
{
    char filename[] = "C:/Users/Administrator/Desktop/do-re-mi/suzume.mp3";
    myMP3.Load(filename);
    myMP3.Play();
把音檔移到資料夾
















step03-1
解決歷史餘毒 就是working_dir
freeglut/bin裡面的freeglut.dll複製到專案
再把聲音檔suzume.mp3複製到專案
最後再把Project-Properties裡面的Bulid targets的工作執行目錄working dir改成小數點















沒有留言:

張貼留言