#include <stdio.h>
void display()
{
glutSolidTeapot(0.3);
glFlush();
}
void keyboard(unsigned char key,int x,int y) ///鍵盤輸入
{
if(key=='a') ///輸入a
{
printf("AAA\n"); ///印出AAA
}
else if(key=='b')
{
printf("BBB\n");
}
}
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutCreateWindow("hi~~~");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
}
#include <GL/glut.h>
///////////////////////
#include <mmsystem.h>
#include <stdio.h>
void display()
{
glutSolidTeapot(0.3);
glFlush();
}
void keyboard(unsigned char key,int x,int y)
{
if(key=='a'){printf("AAA\n");}
else if(key=='b'){printf("BBB\n");}
}
void mouse(int button, int state, int x, int y) ///用按滑鼠啟動音樂撥放
{
printf("now playing sound\n");
////////////////////////////////////
PlaySound("chaha",NULL,SND_ASYNC); /// "音樂檔名" 音樂是在搜尋器上打WAV下載
}
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutCreateWindow("hi~~~");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMainLoop();
}
記得音樂下載下來之後要放在freeglut裡的bin資料夾裡
播放音樂真的是超級有趣的啦~~~~~
#include <GL/glut.h>
///////////////////////
#include <mmsystem.h>
#include <stdio.h>
void display()
{
glutSolidTeapot(0.3);
glFlush();
}
void keyboard(unsigned char key,int x,int y) ///加入音樂用鍵盤啟動
{
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("Sol.wav",NULL,SND_ASYNC);
if(key=='6')PlaySound("La.wav",NULL,SND_ASYNC);
if(key=='7')PlaySound("Si.wav",NULL,SND_ASYNC);
}
void mouse(int button, int state, int x, int y)
{
printf("now playing sound\n");
////////////////////////////////////
PlaySound("chaha",NULL,SND_ASYNC);
}
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutCreateWindow("hi~~~");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMainLoop();
}
沒有留言:
張貼留言