2023年4月27日 星期四

91 week11

 

week11-1:

開一個新的glut專案,找到keybroad程式碼:

static void key(unsigned char key, int x, int y)

{

    switch (key)

    {

        case 27 :

        case 'q':

            exit(0);

            break;


        case '+':

            slices++;

            stacks++;

            break;


        case '-':

            if (slices>3 && stacks>3)

            {

                slices--;

                stacks--;

            }

            break;

    }


#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();
}
week11-2:
複製貼上week11-1程式碼
讀wav.檔:
#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();
}
week11-3:
新專案
#include<windows.h>
#include<stdio.h>
int main()
{
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\do.wav",NULL,SND_SYNC);//A刪掉
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\re.wav",NULL,SND_SYNC);//A刪掉
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\mi.wav",NULL,SND_SYNC);//A刪掉
    printf("Hello World\n");
}
Settings-->compiler-->linker settings-->add winmm

絕對路徑:
PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\do.wav",NULL,SND_SYNC);
相對路徑:
PlaySound("do-re-mi/do.wav",NULL,SND_SYNC);

week11-4:
CMP3_MCI.h檔案放在week11-4裡面:

修改程式碼:
#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();
複製do-re-mi的suzume檔案貼到week11-4裡面:

複製freeglut裡面的bin-->freeglut.dll檔案到week11-4:
project-->properties-->build targets-->working dir-->改成小數點.

修改程式碼:
#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("suzume.mp3");
    myMP3.Play();
git clone 個人網址
.gitignore修改Notepad++
改成*.dll//註解






















沒有留言:

張貼留言