2016年5月30日 星期一

ModeR_Week15_GLUT教學_內插法

WEEK15


Work01





















Work02





//--------------------------------------------------------------程式碼-------------------------------------------------
#include<stdio.h>
#include <GL/glut.h>
float pos=0, oldX=0.7, newX=0.1;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(pos, 0, 0);
        glutSolidTeapot(0.2);
    glPopMatrix();
    glutSwapBuffers();
}
void timer(int t)
{
    float alpha=t/10.0;
    pos = newX*alpha+oldX*(1-alpha);
    glutTimerFunc(100, timer, t+1);
    glutPostRedisplay();
}


int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("3D Interpolate");
    glutDisplayFunc(display);
    glutTimerFunc(100, timer, 0);
    glutMainLoop();
}
//-----------------------------------------------------------------------------------------------------------------------------












沒有留言:

張貼留言