電腦圖學
(1) 主題:點、線、面、顏色
Vertex:頂點
TODO:點名:Veyon Config(左下角的開始,然後再按Veyon)再開起服務裡面的啟動服務 便可開啟
TODO:到www.cmlab.csie.ntu.edu.tw/jsyeh/3dcg10(老師的網站)
下載:windows.zip解壓縮並下載\windows\Shape.exe
data.zip
解壓縮並下載\windows\data\模型
glut32.dll
下載\windows\glut32.dll
然後都下載完以上順序後,便開啟Shape.exe
之後呈現出這個畫面
下面那個是按右邊的畫面滑鼠右鍵的POLYGON
便可呈現此畫面
接下來再開啟codeblocks 重複上次的OpenGL跟GLUT動作
弄好那些步驟後打開GLUT的main.cpp程式,只是裡面的程式碼都要刪光光!!
要打成
#include <GL/glut.h>void display()
{
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("我的Week03");
glutDisplayFunc(display);
glutMainLoop();
}
呈現出來的畫面變成這樣
變顏色的話就要再打一行程式叫glColor3f(1,0,1);
經由此動作便可換成粉紅色
(2) 實作:第一個親手寫出
(3) 洩題:期中考題
(4) 回家作業(更新)
程式碼如下:
#include <GL/glut.h>
void display()
{
glBegin(GL_POLYGON);
glColor3f(252/255.0,52/255.0,10/255.0);//外圍顏色(偏紅色)
glVertex2f((20-100)/100.0, (2-100)/100.0);
glVertex2f((20-100)/100.0, (199-100)/100.0);
glVertex2f((200-100)/100.0, (199-100)/100.0);
glVertex2f((200-100)/100.0, (2-100)/100.0);
glVertex2f((20-100)/100.0, (2-100)/100.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(255/255.0,128/255.0,64/255.0);//橘色
glVertex2f((126-100)/100.0, (49-100)/100.0);
glVertex2f((20-100)/100.0, (150-100)/100.0);
glVertex2f((200-100)/100.0, (199-100)/100.0);
glVertex2f((200-100)/100.0, (20-100)/100.0);
glVertex2f((21-100)/100.0, (21-100)/100.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(26/255.0,230/255.0,71/255.0);//綠色聖誕樹
glVertex2f((125-100)/100.0, -(50-100)/100.0);
glVertex2f((162-100)/100.0, -(98-100)/100.0);
glVertex2f((151-100)/100.0, -(98-100)/100.0);
glVertex2f((176-100)/100.0, -(134-100)/100.0);
glVertex2f((161-100)/100.0, -(134-100)/100.0);
glVertex2f((186-100)/100.0, -(169-100)/100.0);
glVertex2f((136-100)/100.0, -(169-100)/100.0);
glVertex2f((136-100)/100.0, -(193-100)/100.0);
glVertex2f((115-100)/100.0, -(193-100)/100.0);
glVertex2f((115-100)/100.0, -(169-100)/100.0);
glVertex2f((63-100)/100.0, -(169-100)/100.0);
glVertex2f((89-100)/100.0, -(134-100)/100.0);
glVertex2f((73-100)/100.0, -(134-100)/100.0);
glVertex2f((99-100)/100.0, -(98-100)/100.0);
glVertex2f((87-100)/100.0, -(98-100)/100.0);
glVertex2f((125-100)/100.0, -(50-100)/100.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(255/255.0,255/255.0,128/255.0);//裝飾1
glVertex2f((114-100)/100.0, -(74-100)/100.0);
glVertex2f((103-100)/100.0, -(87-100)/100.0);
glVertex2f((114-100)/100.0, -(100-100)/100.0);
glVertex2f((124-100)/100.0, -(87-100)/100.0);
glVertex2f((114-100)/100.0, -(74-100)/100.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(255/255.0,193/255.0,224/255.0);//裝飾2
glVertex2f((146-100)/100.0, -(101-100)/100.0);
glVertex2f((137-100)/100.0, -(116-100)/100.0);
glVertex2f((146-100)/100.0, -(129-100)/100.0);
glVertex2f((155-100)/100.0, -(116-100)/100.0);
glVertex2f((146-100)/100.0, -(101-100)/100.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0/255.0,191/255.0,191/255.0);//裝飾3
glVertex2f((88-100)/100.0, -(142-100)/100.0);
glVertex2f((79-100)/100.0, -(154-100)/100.0);
glVertex2f((88-100)/100.0, -(169-100)/100.0);
glVertex2f((96-100)/100.0, -(154-100)/100.0);
glVertex2f((88-100)/100.0, -(142-100)/100.0);
glEnd();
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("06163020Week03 HW");
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言