(1)小考TRT觀念
(2)上周PlaySound ,MP3播放
※切記要把音檔丟入freeglut/bin資料夾裡
還要至下載CMP3_MCI.h放入week12_mp3資料夾
放在main()外面
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
int a;
放在main()裡面
myMP3.Load("123.mp3");
myMP3.Play();
(3)主題:計時器Timer
#include <windows.h>//因為mmsystem.h需要windows.h
#include <mmsystem.h>//多媒體系統,才會有PlaySound
void timer(int t)
{
glutTimerFunc(1000,timer,t+1); //一秒鐘彈一下
PlaySound("Do.wav",NULL,SND_ASYNC);
}
放在main()裡面
glutTimerFunc(5000,timer,0);//會先延遲5秒鐘
(4)主題:線性內插
公式:alpha*新+(1-alpha)*舊alpha0.0~1.0
畫茶壺,套用公式讓茶壺自動旋轉
#include <GL/glut.h>#include <stdio.h>
float angle=0,oldAngle=0,newAngle=90;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void timer(int t)
{
glutTimerFunc(1000,timer,t+1);
float alpha =(t)/30.0;
angle =newAngle *alpha + oldAngle*(1-alpha);
glutPostRedisplay();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutTimerFunc(0,timer,0);
glutDisplayFunc(display);
glutMainLoop();
}

沒有留言:
張貼留言