2022年3月28日 星期一

week06👻

 1.電腦圖學之父

Ivan Sutherland(skethpad)


 https://jsyeh.org/3dcg10/下載window.zip data.zip














    解壓縮兩個資料夾

    執行Transformation.exe

----------------------------------------------------------------------------------------------------

#include <GL/glut.h>

#include <stdio.h>

float x=0, y=0, z=0, oldX, oldY;

void display()

{

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glPushMatrix();

        glTranslatef(  (x-150)/150.0  , -(y-150)/150.0  ,  z  ); ///Maya: w

        ///glRotatef( angle,  0, 0, 1);

        ///glScalef( scale, scale, scale );

        glColor3f( 1, 1, 0 );

        glutSolidTeapot(0.3);

    glPopMatrix();

    glutSwapBuffers();

}

void keyboard( unsigned char key, int mouseX, int mouseY )

{

    printf("現在按下:%c 座標在:%d %d\n", key, mouseX, mouseY);

}

void mouse( int button, int state, int mouseX, int mouseY )

{

    oldX = mouseX; oldY = mouseY;

}

void motion( int mouseX, int mouseY )

{

    x += (mouseX-oldX);

    y += (mouseY-oldY);

    oldX = mouseX; oldY = mouseY;

    display();

}

int main(int argc, char**argv)

{

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("week06 keyboard mouse motion");


    glutDisplayFunc(display);

    glutKeyboardFunc(keyboard);

    glutMouseFunc(mouse);

    glutMotionFunc(motion);


    glutMainLoop();

}

沒有留言:

張貼留言