2019年5月23日 星期四

yoyoyo190523

耶耶GOT7回歸哦


1.今天要學計時器!!!
和之前一樣打開codeblocks
    選專案GLUT
    下載freeglut
    下載wav音檔
以下是程式碼

#include <GL/glut.h>
#include <mmsystem.h>///Now (1)
#include <stdio.h>///printf()
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSolidTeapot( 0.3 );
    glutSwapBuffers();
}
void timer(int t)///NOW timer!!!!
{
    glutTimerFunc(1000, timer, t+1 );///NOW timer!!!! 起床要播下一個鬧鐘
    printf("timer(t) 的 t是 %d\n", t);///順便印一下現在的t是多少
    PlaySoundA("thwap.wav", NULL, SND_ASYNC);///Now (2) ///NOW timer!!!!
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(500,500);///變大了
    glutCreateWindow("week 14 timer");

    glutDisplayFunc(display);
    glutTimerFunc(1000, timer, 0);///NOW timer!!!!

    glutMainLoop();
}


沒有留言:

張貼留言