2018年5月14日 星期一

逸臻的筆記Week12-MP3播放、計時器

-MP3播放、計時器-

1.複習上週進度PlaySound( )

#include <mmsystem.h>
int main(int argc, char *argv[])
{
    PlaySound("Shot.wav",NULL,SND_ASYNC);

2.播MP3檔案

下載 CMP3_MCI.h   下mp3音檔

#include <mmsystem.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
int main(int argc, char *argv[])
{
    myMP3.Load("BOWZ.mp3");
    myMP3.Play();
    //PlaySound("Shot.wav",NULL,SND_ASYNC);

3.計時器

#include <mmsystem.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
void timer(int t)
{
    glutTimerFunc(2000, timer, 0);
    PlaySound("Shot.wav",NULL,SND_ASYNC);
}
int main(int argc, char *argv[])
{
    //myMP3.Load("BOWZ.mp3");
    //myMP3.Play();
    //PlaySound("Shot.wav",NULL,SND_ASYNC);

    glutInit(&argc, argv);
    glutInitWindowSize(640,480);
    glutInitWindowPosition(10,10);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("GLUT Shapes");

    glutReshapeFunc(resize);
    glutDisplayFunc(display);
    glutKeyboardFunc(key);
    glutIdleFunc(idle);
    glutTimerFunc(5000, timer, 0);

4.

#include <Gl/glut.h>
const GLfloat light_ambient[]  = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[]  = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };

const GLfloat mat_ambient[]    = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[]    = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[]   = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };
float angle=0;
float alpha=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glutSolidTeapot(0.3);
        glPushMatrix();
            glTranslatef(0.4, 0, 0);
            glRotatef(angle, 0,0,1);
            glTranslatef(0.4, 0, 0);
            glutSolidTeapot(0.3);
        glPopMatrix();
    glPopMatrix();
    glutSwapBuffers();
}
/* Program entry point */
#include <mmsystem.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
void timer(int t)
{
    glutTimerFunc(500, timer, t+1);
    alpha = t/100.0;
    angle = alpha*90 + (1-alpha)*0;
    glutPostRedisplay();
    //PlaySound("Shot.wav",NULL,SND_ASYNC);
}
int main(int argc, char *argv[])
{
   // myMP3.Load("BOWZ.mp3");
    //myMP3.Play();
    //PlaySound("Shot.wav",NULL,SND_ASYNC);

    glutInit(&argc, argv);
    glutInitWindowSize(640,480);
    glutInitWindowPosition(10,10);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("GLUT Shapes");


    glutDisplayFunc(display);

    glutTimerFunc(1000, timer, 0);







沒有留言:

張貼留言