第一步驟:
freeglut下載MinGW
解壓改lib的libglut32
第二步驟:
在之前的程式碼內新增這三行程式碼~
要在主程式裡面加glutKeyboardFunc(keyboard);
void keyboard(unsigned char key, int x, int y)
{
if(key=='a') printf("Ant\n");
if(key=='b') printf("Bird\n");
}
第三步驟:
新增表頭#include <mmsystem.h>
函式:PlaySound("thund.wav",NULL,SND_ASYNC);
第四步驟:
加入if(key=='1')
PlaySound("Do.wav",NULL,SND_ASYNC);
if(key=='2')
PlaySound("Re.wav",NULL,SND_ASYNC);
if(key=='3')
PlaySound("Mi.wav",NULL,SND_ASYNC);
if(key=='4')
PlaySound("Fa.wav",NULL,SND_ASYNC);
if(key=='5')
PlaySound("So.wav",NULL,SND_ASYNC);
if(key=='6')
PlaySound("La.wav",NULL,SND_ASYNC);
if(key=='7')
PlaySound("Si.wav",NULL,SND_ASYNC);
if(key=='8')
PlaySound("H_#Do.wav",NULL,SND_ASYNC);
可以用鍵盤敲出音階
第五步驟:
新增void motion (int x,int y){//移動的量
rotX += y -oldY;
rotY += x -oldX;
oldX=x;
oldY=y;
glutPostRedisplay();}
void special(int key, int x,int y){//特殊按鍵
if(key==GLUT_KEY_DOWN)
teaY-=0.1;
else if(key==GLUT_KEY_UP)
teaY+=0.1;}
void mouse (int buttom, int state , int x,int y){//滑鼠左右鍵
oldX=x;
oldY=y;
if(GLUT_LEFT_BUTTON==buttom&&GLUT_DOWN==state)
printf("now left down\n");
if(GLUT_RIGHT_BUTTON==buttom&&GLUT_DOWN==state)
printf("now right down\n");}
沒有留言:
張貼留言