2023年4月27日 星期四

咻碰閃week11

 week11

1-1 開GLUT專案 week11_keyboard
1-2 程式碼全刪改成下面的樣子
#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();
}

1-3 開新專案 week11-2_keyboard_sound


#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 == 27)exit(1234);
    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();
}
2-1 開新專案 week11-3_Playsound

Setting-Compiler>Linker>winmm 
2-2 絕對路徑、相對路徑
目錄斜線可以用兩個反斜線\\或一個斜線/
3-1 開新專案 week11-4_CMP#_MCI_Load_Play

#include "CMP3_MCI.h"  使用外掛 用雙引號,表示是同一目錄裡的.h檔

3-2 解決歷史餘毒
    複製freeglut.dll、mp3檔到同一個專案資料夾中
project>properties>build targets的工作執行目錄working dir 改成.小數點
3-3 專案目錄裡有mp3 dll檔無法用git上傳
因gitignore會把 .dll檔忽略
要把 .dll檔備份

用notepad++開啟.gitignore #*.dll
#*.dll 註解掉



 0. 安裝Git 開啟 Git Bash

- 1. cd desktop 進入桌面 git clone https://網址 再 cd 2023graphicsb

- 2. start . 開檔案總管,把今天的2個程式加進去

- 3. git add . 加入帳冊

- 4.0. git config --global user.email jsyeh@mail.mcu.edu.tw

- 4.0. git config --global user.name jsyeh

- 4.1. git commit -m "week14"

- 5. git push



















沒有留言:

張貼留言