顯示具有 09160731_陳眉禎 標籤的文章。 顯示所有文章
顯示具有 09160731_陳眉禎 標籤的文章。 顯示所有文章

2022年3月22日 星期二

筆記week05

week05

keyboard

1、moodle下載freeglut

2、CodeBlocks開新的GLUT專案

3、打程式碼

#include <GL/glut.h>
#include <stdio.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3f(1,1,0);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y)
{
    printf("你按下了 %c 在 %d %d 座標\n",key,x,y);
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week05 keyboard");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
}


#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();
}






2022年3月15日 星期二

筆記week04

week04

旋轉Rotate

1、到https://jsyeh.org/3dcg10/

2、下載data.zip、window.zip

3、解壓縮 把data放到windows裡面

4、選AI Capone

5、嘗試旋轉角度


week04-2

1、下載moodle-freeglut mingw檔案,libfreeglut改libglut32.a

2、codeblocks開new project-GLUT project

3、打程式碼

#include<GL/glut.h>

float angle=0,oldX=0;

void display()

{

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glPushMatrix();

    glRotatef(angle,0,0,1);

    glutSolidTeapot(0.3);

    glPopMatrix();

    glutSwapBuffers();

}

void motion(int x,int y)

{

    angle+=(x-oldX);

    oldX=x;

    display();

}

void mouse(int button,int state,int x,int y)

{

    oldX=x;

}

int main(int argc,char**argv)

{

    glutInit(&argc,argv);

    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);

    glutCreateWindow("Week04 Rotate");

    glutDisplayFunc(display);

    glutMotionFunc(motion);

    glutMouseFunc(mouse);

    glutMainLoop();

}











2022年3月8日 星期二

筆記week03

week03

1、範例https://jsyeh.org/3dcg10/

2、下載 data,win32

windows.zip---下載\windows\Transformation.exe

data.zip---下載\windows\data\模型.obj

3、執行Transformation.exe


茶壺

1、開freeglut\lib\libfreeglut.a改成libglut32.a

2、開CodeBlocks\New Project\GLUT Project

3、打程式碼



2022年3月1日 星期二

筆記week02

week02

跑別人的範例

1、下載範例 https://jsyeh.org/3dcg10---data.zip windows.zip glut32.dll
2、windows.zip解壓---下載\windows\Shapes.exe
      data.zip解壓---下載\windows\data\模型
      glut32.dll解壓---複製\windows\glut32.dll
3、跑 Shapes.exe 看範例

跑上周的程式
1、上周的安裝 Gits for Windows
2、上周的 Git bash : cd desktop,git clone 你的網址 cd 2022graphics


3、上周的安裝 freeglut,記得改檔名 lib\libglut32.a
4、在 Codeblocks Flie-Open week01_GLUT專案,Build&Run,完成


自己弄一個GLUT專案
1、Codeblocks Flie New Project---GLUT project,取名week02_Color
2、打程式碼









2022年2月22日 星期二

筆記week01

week01

0、Codeblocks 17.12 mingw裝好

1、Flie-New Project,選OPENGL專案

2、在目錄選桌面,打week01












3、Build&Run,完成

第一個GLUT專案

1、Moodle下載 freeglut 壓縮檔

2、解壓縮 桌面 freeglut目錄

3、桌面 freeglut 的 lib 裡面的 libfreeglut.a 改成 libglut32.a

4、CodeBlocks:Flie-New Project,選GLUT專案

5、取名 week01_GLUT

6、設定 GLUT 目錄 C:\Users\?????\Desktop\freeglut

7、Build&Run,完成








GITHUB 備份檔案
























VERY BEAUTIFUL, VERY POWERFUL

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