2015年4月8日 星期三

week07 02160200 Mouse.Keyboard.UI.音樂

程式碼
#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)///按鍵盤會print東西
{
    if(key=='a'||key=='A')
    {
        printf("AAA\n");
    }
    else if(key=='b')
    {
        printf("BBB\n");
    }
}
void mouse(int button,int state,int x,int y)///聲音要放freeglut的bin裡
{
    printf("now playing sound");
    PlaySound("madmoo.wav",NULL,SND_ASYNC);
}
int main(int argc,char **argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("hello");

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


沒有留言:

張貼留言