程式碼:
#include<GL/glut.h>
float rot=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(10,timer,t+1);
rot++;
glutPostRedisplay();
}
int main()
{
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("0016108");
glutDisplayFunc(display);
glutTimerFunc(2000,timer,0);
glutMainLoop();
return 0;
}
2.會叫的聲音:
程式碼:
#include<windows.h>
#include<GL/glut.h>
float rot=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(10,timer,t+1);
rot++;
glutPostRedisplay();
}
void oioi(int t)
{
glutTimerFunc(6000,oioi,0);
PlaySound("o.wav",NULL,SND_ASYNC);
}
int main()
{
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("0016108");
glutDisplayFunc(display);
glutTimerFunc(2000,timer,0);
glutTimerFunc(6000,oioi,0);
glutMainLoop();
return 0;
}
3.MP3聲音:
#include<windows.h>
#include<GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
float rot=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(10,timer,t+1);
rot++;
glutPostRedisplay();
}
void oioi(int t)
{
glutTimerFunc(6000,oioi,0);
//PlaySound("o.wav",NULL,SND_ASYNC);
}
int main()
{
myMP3.Load("dance.mp3");
myMP3.Play();
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("0016108");
glutDisplayFunc(display);
glutTimerFunc(2000,timer,0);
// glutTimerFunc(6000,oioi,0);
glutMainLoop();
return 0;
}
4.音符聲音:
#include<windows.h>
#include<GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
float rot=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(10,timer,t+1);
rot++;
glutPostRedisplay();
}
void oioi(int t)
{
glutTimerFunc(6000,oioi,0);
//PlaySound("o.wav",NULL,SND_ASYNC);
}
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("ti.wav",NULL,SND_ASYNC);
if(key=='8')PlaySound("doHigh.wav",NULL,SND_ASYNC);
}
int main()
{
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("0016108");
glutDisplayFunc(display);
glutTimerFunc(2000,timer,0);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
3.MP3聲音:
#include<windows.h>
#include<GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
float rot=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(10,timer,t+1);
rot++;
glutPostRedisplay();
}
void oioi(int t)
{
glutTimerFunc(6000,oioi,0);
//PlaySound("o.wav",NULL,SND_ASYNC);
}
int main()
{
myMP3.Load("dance.mp3");
myMP3.Play();
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("0016108");
glutDisplayFunc(display);
glutTimerFunc(2000,timer,0);
// glutTimerFunc(6000,oioi,0);
glutMainLoop();
return 0;
}
4.音符聲音:
#include<windows.h>
#include<GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
float rot=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rot,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(10,timer,t+1);
rot++;
glutPostRedisplay();
}
void oioi(int t)
{
glutTimerFunc(6000,oioi,0);
//PlaySound("o.wav",NULL,SND_ASYNC);
}
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("ti.wav",NULL,SND_ASYNC);
if(key=='8')PlaySound("doHigh.wav",NULL,SND_ASYNC);
}
int main()
{
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("0016108");
glutDisplayFunc(display);
glutTimerFunc(2000,timer,0);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}
沒有留言:
張貼留言