2005年4月8日 星期五

4/8


第一項 打AB小黑窗印出AB
#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
static void display(void)
{
    glutSolidTeapot(0.3);
    glFlush();
}
 void keyboard(unsigned char key, int x, int y)
{
    if(key=='a'){printf("AAAAAAAAA\n");}
    else if(key=='b'){printf("BBBBBBBBB\n");}
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutCreateWindow("GLUT ");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
}






















案圖片讓他發出音效


#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#include<mmsystem.h>

static void display(void)
{
    glutSolidTeapot(0.3);
    glFlush();
}


 void keyboard(unsigned char key, int x, int y)
{
    if(key=='a'){printf("AAAAAAAAA\n");}
    else if(key=='b'){printf("BBBBBBBBB\n");}

}
 void mouse(int button, int state, int x,int y)
{
    printf("play!\n");
    PlaySound("dk.wav",NULL,SND_ASYNC);
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);


    glutCreateWindow("GLUT ");


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

    glutMainLoop();
}



#include <GL/glut.h>
#include <stdlib.h>
#include <stdio.h>
#include<mmsystem.h>

static void display(void)
{
    glutSolidTeapot(0.3);
    glFlush();
}


 void keyboard(unsigned char key, int x, int y)
{
    printf("play!\n");
    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("So.wav",NULL,SND_ASYNC);
    if(key=='6')PlaySound("La.wav",NULL,SND_ASYNC);
    if(key=='7')PlaySound("Si.wav",NULL,SND_ASYNC);



}
 void mouse(int button, int state, int x,int y)
{
    //printf("play!\n");
   // PlaySound("dk.wav",NULL,SND_ASYNC);
   // PlaySound("5679.MP3",NULL,SND_ASYNC);
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);


    glutCreateWindow("GLUT ");


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

    glutMainLoop();
}