【文章內(nèi)容簡(jiǎn)介】
( 1)發(fā)展歷程 諸侯割據(jù) 標(biāo)準(zhǔn)討論 標(biāo)準(zhǔn)形成 圖形標(biāo)準(zhǔn)的產(chǎn)生與發(fā)展歷史(續(xù)) ( 2)兩類(lèi)標(biāo)準(zhǔn) ? 官方標(biāo)準(zhǔn)(標(biāo)準(zhǔn)組織制定): GKS (Graphical Kernel System) PHIGS (Programming’s Hierachical Interactive Graphics System) ? 工業(yè)標(biāo)準(zhǔn)(事實(shí)上的標(biāo)準(zhǔn)): SGI 等公司的 OpenGL, 微軟公司的 DirectX, X財(cái)團(tuán)的 Xlib,Adobe 公司的 PostScript 等等。 圖形標(biāo)準(zhǔn)的產(chǎn)生與發(fā)展歷史(續(xù)) OpenGL介紹 ?OpenGL(Open Graphics Library, 即開(kāi)放性圖形庫(kù) )是以 SGI的 GL三維圖形庫(kù)為基礎(chǔ)制定的一個(gè)開(kāi)放式三維圖形標(biāo)準(zhǔn) 。 ?OpenGL獨(dú)立于硬件設(shè)備 、 窗口系統(tǒng)和操作系統(tǒng) , 使得以 OpenGL為基礎(chǔ)開(kāi)發(fā)的應(yīng)用程序可以在各種平臺(tái)間移植 。 OpenGL可以運(yùn)行在當(dāng)前各種流行操作系統(tǒng)之上 , 如 Windows95/9 Windows NT/202 Linux、Mac OS、 Unix、 OS/2等 。 ?OpenGL可以與各種編程語(yǔ)言緊密接口 。 各種流行的編程語(yǔ)言如 C、C++、 Fortran、 Ada、 Java等都可以調(diào)用 OpenGL中的庫(kù)函數(shù) 。 OpenGL的主要功能 ?繪制模型: 提供了繪制點(diǎn) 、 線 、 多邊形 、 球 、 錐 、 多面體 、茶壺等復(fù)雜的三維物體以及貝塞爾 、 NURBS等復(fù)雜曲線或曲面的繪制函數(shù) 。 ?各種變換 :提供了平移 、 旋轉(zhuǎn) 、 變比和鏡像四種基本變換以及平行投影和透視投影兩種投影變換 。 通過(guò)變換實(shí)現(xiàn)三維的物體在二維的顯示設(shè)備上顯示 。 OpenGL的主要功能(續(xù)) ? 著色模式: 提供了 RGBA模式和顏色索引兩種顏色的顯示方式。 ? 光照處理: 在自然界我們所見(jiàn)到的物體都是由其材質(zhì)和光照相互作用的結(jié)果, OpenGL提供了輻射光 (Emitted Light)、 環(huán)境光 (Ambient Light)、漫反射光 (Diffuse Light)和鏡面光 (Specular Light)。 材質(zhì)是指物體表面對(duì)光的反射特性,在OpenGL中用光的反射率來(lái)表示材質(zhì)。 ?紋理映射 (Texture Mapping): 將真實(shí)感的紋理粘貼在物體表面,使物體逼真生動(dòng)。紋理是數(shù)據(jù)的簡(jiǎn)單矩陣排列,數(shù)據(jù)有顏色數(shù)據(jù)、亮度數(shù)據(jù)和 alpha數(shù)據(jù)。 ?位圖和圖像 :提供了一系列函數(shù)來(lái)實(shí)現(xiàn)位圖和圖像的操作。位圖和圖像數(shù)據(jù)均采用像素的矩陣形式表示。 ?制作動(dòng)畫(huà): 提供了雙緩存 (Double Buffering)技術(shù)來(lái)實(shí)現(xiàn)動(dòng)畫(huà)繪制 。 雙緩存即前臺(tái)緩存和后臺(tái)緩存 , 后臺(tái)緩存用來(lái)計(jì)算場(chǎng)景 、生成畫(huà)面 , 前臺(tái)緩存用來(lái)顯示后臺(tái)緩存已經(jīng)畫(huà)好的畫(huà)面 。 當(dāng)畫(huà)完一幀時(shí) , 交互兩個(gè)緩存 , 這樣循環(huán)交替以產(chǎn)生平滑動(dòng)畫(huà) 。 OpenGL的主要功能(續(xù)) ? 選擇和反饋: OpenGL為支持交互式應(yīng)用程序設(shè)計(jì)了選擇操作模式和反饋模式。 ? 在選擇模式下,則可以確定用戶(hù)鼠標(biāo)指定或拾取的是哪一個(gè)物體。 ? 而反饋模式, OpenGL把即將光柵化的圖元信息反饋給應(yīng)用程序。 ? 此外, OpenGL還提供了反走樣技術(shù),能夠?qū)崿F(xiàn) 深度暗示 (Depth Cue)、 運(yùn)動(dòng)模糊 (Motion Blur)、 霧化 (Fog)等特殊效果。 OpenGL的主要功能(續(xù)) GLUT庫(kù)介紹 ? GLUT 代表 OpenGL Utility Tookit。Mark 為了使 OpenGL應(yīng)用程序結(jié)構(gòu)能夠真正獨(dú)立于窗口系統(tǒng)構(gòu)思了GLUT庫(kù)。 Introduction to GLUT ? GLUT is an OpenGL addon ? not part of the standard, but shipped with most implementations ? provides a platformindependent way to ? get a context (window or fullscreen) ? read keyboard and mouse ? create menus ? perform animations ? uses the callback event model ? register callback or service functions with GLUT to handle each type of event ? GLUT calls the appropriate event handling function as each event happens Using GLUT int main(int argc, char** argv) { // initialise GLUT amp。 pass in mandline arguments glutInit(amp。argc, argv)。 // get a context … // register callbacks for GLUT … // let GLUT manage things from here glutMainLoop()。 // note that glutMainLoop() never returns return 0。 // so this is never run } Getting a windowed context // window position (hint only, may be overridden by GLUT) glutInitWindowPosition(100, 100)。 // window dimensions (hint only, may be overridden by GLUT) glutInitWindowSize(300, 300)。 // context features // . double = doublebuffered (front/back) // rgb = 24bit context // depth=24 = at least 24bit depth buffer // see for more glutInitDisplayString(double rgb depth=24)。 // open window with title glutCreateWindow(GL_POLYGON)。 Functions to register callbacks ? glutDisplayFunc() ? register the function that is called whenever the content of the window needs to be drawn ? glutReshapeFunc() ? register the function that is called when the user resizes the window ? glutKeyboardFunc() ? register the function that is called when a key is pressed ? glutSpecialFunc() ? register the function that is called when a special key is pressed (eg., cursor/function keys) Functions to register callbacks ? glutMouseFunc() ? register the function that is called when a mouse button is clicked or released ? glutMotionFunc() ? register the function that is called when the mouse is moved in a window while one or