OpenGL编程初步.ppt
上传人:qw****27 上传时间:2024-09-12 格式:PPT 页数:49 大小:7.5MB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

OpenGL编程初步.ppt

OpenGL编程初步.ppt

预览

免费试读已结束,剩余 39 页请下载文档后查看

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

OpenGL编程初步OpenGL介绍OpenGLisdesignedasastreamlined,hardware-independentinterfacetobeimplementedonmanydifferenthardwareplatforms.Toachievethesequalities,nocommandsforperformingwindowingtasksorobtaininguserinputareincludedinOpenGL;instead,youmustworkthroughwhateverwindowingsystemcontrolstheparticularhardwareyou'reusing.Similarly,OpenGLdoesn'tprovidehigh-levelcommandsfordescribingmodelsofthree-dimensionalobjects.Suchcommandsmightallowyoutospecifyrelativelycomplicatedshapessuchasautomobiles,partsofthebody,airplanes,ormolecules.WithOpenGL,youmustbuildupyourdesiredmodelfromasmallsetofgeometricprimitive-points,lines,andpolygons.whatdoesOpenGLdo?Thescenewiththeobjectsrenderedaswireframemodels.Thesamesceneusingfogfordepth-cueing(linesfurtherfromtheeyearedimmer).Thescenerenderedwithlightingandsmooth-shadedpolygons.Thescenedrawnwithoneoftheobjectsmotion-blurred.Theaccumulationbufferisusedtocomposethesequenceofimagesneededtoblurthemovingobject.Aclose-upshot-thesceneisrenderedfromanewviewpoint.Thescenedrawnusingatmosphericeffects(fog)tosimulateasmoke-filledroom.Teapotsdrawnwithjitteredviewingvolumesintotheaccumulationbufferforadepth-of-fieldeffect.Thegoldteapotisinsharpestfocus.OpenGL的功能OpenGL的发展OpenGL与Windows平台OpenGL开发组件安装glut一个简单的OpenGL程序#include<whateverYouNeed.h>main(){OpenAWindowPlease();glClearColor(0.0,0.0,0.0,0.0);glClear(GL_COLOR_BUFFER_BIT);glColor3f(1.0,1.0,1.0);glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);glBegin(GL_POLYGON);glVertex2f(-0.5,-0.5);glVertex2f(-0.5,0.5);glVertex2f(0.5,0.5);glVertex2f(0.5,-0.5);glEnd();glFlush();KeepTheWindowOnTheScreenForAWhile();}glBegin(),glVertex*()andglEnd()OneMoreExample程序的基本结构主要利用了三个函数:1.函数voidglViewport(left,top,right,bottom):设置在屏幕上的窗口大小,四个参数描述屏幕窗口四个角上的坐标(以象素表示);2.函数voidglOrtho(left,right,bottom,top,near,far):设置投影方式为正交投影(平行投影),其取景体积是一个各面均为矩形的六面体;3.函数voidgluPerspective(fovy,aspect,zNear,zFar):设置投影方式为透视投影,其取景体积是一个截头锥体。第三部分是OpenGL的主要部分:使用OpenGL的库函数构造几何物体对象的数学描述,包括点线面的位置和拓扑关系、几何变换、光照处理等等。以上三个部分是Ope