2018年3月19日 星期一

Week04 1000

前往網址: http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/

下載windows / data / glut32.dll
解壓縮 把 data / glut32.dll移到windows
座標

案右鍵選可以有足球

還有人,還有其他可以選



把const double a = 0;//t*90.0;
//glRotated(60,1,0,0); 變成註解

旋轉茶壺

跑程式碼的茶壺
多家一行printf("%.1f\n", angle);



#include <stdio.h>
#include <GL/glut.h>
float angle=0, teapotX=0, teapotY=0;///Now2:
int oldX=0, oldY=0, nowRotate=0;///0:translate, 1:rotate
void display()
{
     glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
     glPushMatrix();
        glTranslatef(teapotX, teapotY, 0);///Now2
        glRotatef(angle,0,0,1);
        glutSolidTeapot(0.3);
     glPopMatrix();
     glutSwapBuffers();
     ///Now: printf("%.1f\n", angle);/// Now: angle++;
}
void mouse(int button, int state, int x, int y)
{
    if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN) nowRotate=1;///Now2:
    if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN) nowRotate=0;///Now2:
    oldX=x; oldY=y;///Now2:
}
void motion(int x, int y)
{///Now:
    angle=x;///Now:
    glutPostRedisplay();///Now:
}
int main(int argc, char*argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week04 transformation");
    glutMouseFunc(mouse); ///Now: mouse
    glutMotionFunc(motion); ///Now: motion
    ///Now: glutIdleFunc(display);
    glutDisplayFunc(display);
    glutMainLoop();
}







沒有留言:

張貼留言