2015年4月16日 星期四

02160820_林政華Week08

點擊畫面產生聲音,並產生BOOM字
#include <GL/glut.h>
#include <mmsystem.h>
#include <stdio.h>
void mouse(int button,int state, int x,int y)
{
    if(state==GLUT_DOWN)
        PlaySound("Shot.wav",NULL, SND_ASYNC);
    printf("BOOM\n");
}

void keyboard(unsigned char key ,int x,int y)
{
    exit(0);
}
void display()
{
    glClearColor(0.5,0.5,0.5,0);
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
}
int main (int argc, char**argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("02160820");
    glutFullScreen();

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMainLoop();
}
















在display加上 
        potX+=0.01;
        if(potX>1.1) potX=-1.1;
        glPushMatrix();
        glTranslatef(potX,potY,0);
        glutSolidTeapot(0.05);
    glPopMatrix();
在main加上    glutIdleFunc(display);




沒有留言:

張貼留言