2019年5月24日 星期五

0524 week14


1.加入MP3檔
加上以下幾行
#include <mmsystem.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
int main(int argc, char *argv[])
{
    myMP3.Load("2.mp3");
    myMP3.Play();
}

2.計時器

#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);

沒有留言:

張貼留言