開啟glut把wav檔丟到freeglut資料夾裡
開始執行
#include <GL/glut.h>
#include <mmsystem.h>///NOW (0)發聲音
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
void timer(int t)///NOW (2)
{
glutTimerFunc(1000, timer, 0);///NOW2
PlaySoundA("ribbit.wav", NULL, SND_ASYNC);///NOW (2)
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(500,500);///大一點
glutCreateWindow("week14 timer");
glutDisplayFunc(display);
glutTimerFunc(1000, timer, 0);///NOW (1)
glutMainLoop();
}
讓茶壺轉動每0.03秒轉1度
float alpha = (t%30) / 30.0;///變成 alpha: 0.0 ~ 1.0 ///NOW5
nowX = alpha*1.0 + (1-alpha)* -1.0;///NOW5
沒有留言:
張貼留言