Presentation is loading. Please wait.

Presentation is loading. Please wait.

PROGRAM 1 Simple E. Angel, Interactive Computer Graphics A Top-Down Approach with OpenGL, Third Edition Addison-Wesley Longman, 2003.

Similar presentations


Presentation on theme: "PROGRAM 1 Simple E. Angel, Interactive Computer Graphics A Top-Down Approach with OpenGL, Third Edition Addison-Wesley Longman, 2003."— Presentation transcript:

1 PROGRAM 1 Simple E. Angel, Interactive Computer Graphics A Top-Down Approach with OpenGL, Third Edition Addison-Wesley Longman, 2003

2 目的 利用簡單的Open GL 指令撰寫一程式 介紹程式架構 了解指令的功能以及用法 描繪出一多邊形

3 #include <GL/glut.h> /* glut.h includes gl.h and glu.h*/
void display(void) { /* clear window */ glClear(GL_COLOR_BUFFER_BIT); // 利用現有的清除顏色清除視窗 /* draw unit square polygon */ glBegin(GL_POLYGON); //與glEnd搭配使用. glBegin和glEnd //之間可以加入多組座標點. glVertex2f(-0.5, -0.5); //集合,但是其元件型態必須相同 glVertex2f(-0.5, 0.5); //GL_POLYGON將指定的座標建立凸多邊形 glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); //glVertex2f(x,y)函式是用來描繪一點的座標 glEnd(); /* flush GL buffers */ glFlush(); //出清 OpenGL的指令佇列與緩衝區 }

4 Init(){ } void init() //初始化視窗視窗表現方式 { }

5 Main( ){ } int main(int argc, char** argv) { /*建立一個視窗其名稱為 simple*/
glutCreateWindow("simple"); /*這個函式告訴GLUT當視窗重繪時要呼叫哪個函數*/ glutDisplayFunc(display); init(); /*啟動GLUT主要的處理迴圈,直到程式終止*/ glutMainLoop(); }

6 程式執行結果


Download ppt "PROGRAM 1 Simple E. Angel, Interactive Computer Graphics A Top-Down Approach with OpenGL, Third Edition Addison-Wesley Longman, 2003."

Similar presentations


Ads by Google