2016年6月6日 星期一

week16

電腦圖學
(1)攝影機設定
(2)Camer運鏡
     gluLookAt()
(3)期末作品(下周展示)

TODO1:貝殼專案 
咒語: Compiler(include)
           Line(lib)
           freeflut
           opengl32
           glu32
           gdi32
           winmm

<相機旋轉>

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

void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glutSolidTeapot(1);
    glPopMatrix();

    glutSwapBuffers();
}
void motion(int x,int y)
{
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(x/80.0,y/200.0,5,0,0,0,0,1,0);
    glutPostRedisplay();
}
void resize(int w,int h)
{
    glViewport(0,0,(GLsizei) w,(GLsizei) h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(65.0,(GLdouble) w/h,1.0,100.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(0.0,0.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0);

}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("camer");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutReshapeFunc(resize);
    glutMainLoop();
}


沒有留言:

張貼留言