2022年3月22日 星期二

豪哥電腦圖學筆記 week05

0.老師介紹 電腦圖學之父

Ivan Sutherland 的影片

介紹他的老師 Shanon

1.

https://jsyeh.org/3dcg10/ 

下載windows.zip,data.zip






#include <GL/glut.h>

#include <stdio.h>

float x=150,y=150,z=0,scale=1.0;

int oldX=0,oldY=0;

void display()

{

    glClearColor(0.5,0.5,0.5,1);

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glPushMatrix();

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

        glScalef(scale,scale,scale);

        glColor3f(1,1,0);

        glutSolidTeapot(0.3);

    glPopMatrix();

    glutSwapBuffers();

}

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

{

}

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

{

    oldX=mouseX; oldY=mouseY;

}

void motion(int mouseX,int mouseY)

{

    if(mouseX-oldX > 0) scale *=1.01;

    if(mouseX-oldX < 0) scale *=0.99;

    oldX=mouseX; oldY=mouseY;

    display();

}

int main(int argc,char**argv)

{

    glutInit(&argc,argv);

    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

    glutCreateWindow("week05 keyboard");


    glutDisplayFunc(display);

    glutKeyboardFunc(keyboard);

    glutMouseFunc(mouse);

    glutMotionFunc(motion);

    glutMainLoop();

}



沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

一.     一樣先安裝且設定好freeglut,OpecCV, 開啟CodeBlocks建立新專案 week11_gundam,                 把 MyGundam.zip下載解壓縮後的data資料夾放到freeglut/bin裡面 把week09_openc...