欢迎来到课桌文档! | 帮助中心 课桌文档-建筑工程资料库
课桌文档
全部分类
  • 党建之窗>
  • 感悟体会>
  • 百家争鸣>
  • 教育整顿>
  • 文笔提升>
  • 热门分类>
  • 计划总结>
  • 致辞演讲>
  • 在线阅读>
  • ImageVerifierCode 换一换
    首页 课桌文档 > 资源分类 > PPT文档下载  

    计算机图形学computergraphics课件5.ppt

    • 资源ID:619980       资源大小:1.06MB        全文页数:23页
    • 资源格式: PPT        下载积分:10金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    计算机图形学computergraphics课件5.ppt

    1,Programming with OpenGLPart 2:Complete Programs,治路仟屯砰鼎姿截卞羔德绒嫁凡抛状弱伏御掷耪肤半掣叙熔俗必禹赠灾怔计算机图形学computer graphics课件5计算机图形学computer graphics课件5,2,Objectives,Refine the first programAlter the default valuesIntroduce a standard program structureSimple viewingTwo-dimensional viewing as a special case of three-dimensional viewingFundamental OpenGL primitivesAttributes,嚣璃济酞昔抵朵梢区踞致扭易厂埃例雀厂尽帐敌异撂涟镀君犯浊狼镐卉冲计算机图形学computer graphics课件5计算机图形学computer graphics课件5,3,Program Structure,Most OpenGL programs have a similar structure that consists of the following functionsmain():defines the callback functions opens one or more windows with the required propertiesenters event loop(last executable statement)init():sets the state variablesViewingAttributescallbacksDisplay functionInput and window functions,炉主戎蹲左磐娩乔而在噬下哼戍系缎垃郊醚刨龟赘萄这须屏屯菠举竖远祥计算机图形学computer graphics课件5计算机图形学computer graphics课件5,4,simple.c revisited,In this version,we shall see the same output but we have defined all the relevant state values through function calls using the default valuesIn particular,we setColorsViewing conditionsWindow properties,韦裁考暂拷眶裂淑帖怠薯嚣步贼邑恕岸眠轮佳峪稚嘲瑞瞩果抽代含缉荆响计算机图形学computer graphics课件5计算机图形学computer graphics课件5,5,simple.c,#include void mydisplay()glClear(GL_COLOR_BUFFER_BIT);/glColor3f(1.0f,0.0f,0.0f);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();int main(int argc,char*argv)glutCreateWindow(simple);glutDisplayFunc(mydisplay);glutMainLoop();,饶哟饼化哨典伊氧帅整句远丛览憾雕弹秀黄悬权嘉善出呵拷愁瘤罗澄躯尤计算机图形学computer graphics课件5计算机图形学computer graphics课件5,6,main.c,#include int main(int argc,char*argv)glutInit(,includes gl.h,define window properties,set OpenGL state,enter event loop,display callback,潞氢女然蝴竞郎卿料柴佯慰条观剂枯肤懊信粳汐铂卤膜材暴樱擒母踪轧遵计算机图形学computer graphics课件5计算机图形学computer graphics课件5,7,GLUT functions,glutInit allows application to get command line arguments and initializes systemgluInitDisplayMode requests properties for the window(the rendering context)RGB colorSingle bufferingProperties logically ORed togetherglutWindowSize in pixelsglutWindowPosition from top-left corner of displayglutCreateWindow create window with title“simple”glutDisplayFunc display callbackglutMainLoop enter infinite event loop,其承赖应殆蹭陷矣莱砒冀童寄抑垮鸽诞喷楚锐谬助烛疡刻广楼群著弗娇逝计算机图形学computer graphics课件5计算机图形学computer graphics课件5,8,init.c,void init()glClearColor(0.0,0.0,0.0,1.0);glColor3f(1.0,1.0,1.0);glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);,black clear color,opaque window,fill/draw with white,viewing volume,袒禽唱燎轻驴届飞泞幅醚僵呕席现寞阶灌徊渭帮磋呛瞻烷睦朵映招搭技取计算机图形学computer graphics课件5计算机图形学computer graphics课件5,9,Coordinate Systems,The units in glVertex are determined by the application and are called object or world coordinatesThe viewing specifications are also in object coordinates and it is the size of the viewing volume that determines what will appear in the imageInternally,OpenGL will convert to camera(eye)coordinates and later to screen coordinates OpenGL also uses some internal representations that usually are not visible to the application,方拌埔读呼辙孔霉桔立膊鬃耍烷厨揍斧羌罕谴券埠戏心梆箩亿政寂秤夏嚎计算机图形学computer graphics课件5计算机图形学computer graphics课件5,10,OpenGL Camera,OpenGL places a camera at the origin in object space pointing in the negative z directionThe default viewing volume is a box centered at the origin with a side of length 2,glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);,源粱壮装钡况村咽嘎畏录屹蹲罪厂蓝渔局弦快医瘦袱幼栖际龋役攫辞斧阐计算机图形学computer graphics课件5计算机图形学computer graphics课件5,11,Orthographic Viewing,In the default orthographic view,points are projected forward along the z axis onto theplane z=0,邪懊靖赦做堪傻凯似继吸闰渝根利擎光靴把妇鬃逻摄篆曼填馅葛女幂便孩计算机图形学computer graphics课件5计算机图形学computer graphics课件5,12,Transformations and Viewing,In OpenGL,projection is carried out by a projection matrix(transformation)There is only one set of transformation functions so we must set the matrix mode first glMatrixMode(GL_PROJECTION)Transformation functions are incremental so we start with an identity matrix and alter it with a projection matrix that gives the view volume glLoadIdentity();glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);,枯狰坷幢涪庐您贡通檬硅众摸捏罢换剿积桅苇矣汝掸劫钥愈割乌司疗讯盾计算机图形学computer graphics课件5计算机图形学computer graphics课件5,13,Two-and three-dimensional viewing,In glOrtho(left,right,bottom,top,near,far)the near and far distances are measured from the cameraTwo-dimensional vertex commands place all vertices in the plane z=0If the application is in two dimensions,we can use the function gluOrtho2D(left,right,bottom,top)In two dimensions,the view or clipping volume becomes a clipping window,筒膝矢类铰倾当蒙述走士惭诉凰陕架魁柄杭辙缘润功醚选枉固智祷峻柱颤计算机图形学computer graphics课件5计算机图形学computer graphics课件5,14,mydisplay.c,void mydisplay()glClear(GL_COLOR_BUFFER_BIT);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();,产蒋狄睹拙问滩很逢熔饶亏败妖狰厅掇薪涂烤涯征擞贴版邪缴具魄敌吮沥计算机图形学computer graphics课件5计算机图形学computer graphics课件5,15,OpenGL Primitives,GL_QUAD_STRIP,GL_POLYGON,GL_TRIANGLE_STRIP,GL_TRIANGLE_FAN,GL_POINTS,GL_LINES,GL_LINE_LOOP,GL_LINE_STRIP,GL_TRIANGLES,伸害钧域兰畏撂雇蒸植涤慑化涂厄揉挣霍狠痞养韦尸躬粪祈父冤队未棺擞计算机图形学computer graphics课件5计算机图形学computer graphics课件5,16,Polygon Issues,OpenGL will only display polygons correctly that areSimple:edges cannot crossConvex:All points on line segment between two points in a polygon are also in the polygonFlat:all vertices are in the same planeUser program can check if above trueOpenGL will produce output if these conditions are violated but it may not be what is desiredTriangles satisfy all conditions,nonsimple polygon,nonconvex polygon,拴挥读富荐境馅脖攒迪检骡壮弯勇泄沟局砚诊禄媒鱼荚秘毁脸跪韶披刃历计算机图形学computer graphics课件5计算机图形学computer graphics课件5,Approximating a Sphere,17,畅终瓜降司雹集谢硬菇驳绚滋辗饵国佑胳顽积龚袁兜莆瞎踩邯域壶氰偏蹭计算机图形学computer graphics课件5计算机图形学computer graphics课件5,18,Attributes,Attributes are part of the OpenGL state and determine the appearance of objectsColor(points,lines,polygons)Size and width(points,lines)Stipple pattern(lines,polygons)Polygon modeDisplay as filled:solid color or stipple patternDisplay edgesDisplay vertices,畅甸铡女庸猖间予账迈造岁事彭队镰安宝酬崎眺拧滨旁差血石谢懒粗落桌计算机图形学computer graphics课件5计算机图形学computer graphics课件5,19,RGB color,Each color component is stored separately in the frame bufferUsually 8 bits per component in bufferNote in glColor3f the color values range from 0.0(none)to 1.0(all),whereas in glColor3ub the values range from 0 to 255,养脂祟十余俘横丸旋卫炭埋跨舒漱件毡帆匀叶夺庚组颁嚷挝州尚芦网恩迈计算机图形学computer graphics课件5计算机图形学computer graphics课件5,20,Indexed Color,Colors are indices into tables of RGB valuesRequires less memoryindices usually 8 bitsnot as important nowMemory inexpensiveNeed more colors for shading,颈暴嫩雅从盯聪又往稻鬼苯培薯锁哺妇入霄庚穆救萝葵贡返习收垫祁郑坛计算机图形学computer graphics课件5计算机图形学computer graphics课件5,21,Color and State,The color as set by glColor becomes part of the state and will be used until changedColors and other attributes are not part of the object but are assigned when the object is renderedWe can create conceptual vertex colors by code such as glColor glVertex glColor glVertex,瞒徐萤项彤象纶氧会切婉娄圣胜九跋砂衷炎钞棵幂鹃骋赃呕链纶络讹羚昧计算机图形学computer graphics课件5计算机图形学computer graphics课件5,22,Smooth Color,Default is smooth shadingOpenGL interpolates vertex colors across visible polygonsAlternative is flat shadingColor of first vertex determines fill colorglShadeModel(GL_SMOOTH)or GL_FLAT,导辜驶蹭仁疵卷梭汁滇益笔搪敞练梯赢魔澎役琼省畅罐埠蛹入闷闺墙羹荒计算机图形学computer graphics课件5计算机图形学computer graphics课件5,23,Viewports,Do not have use the entire window for the image:glViewport(x,y,w,h)Values in pixels(screen coordinates),屯枚稼疆貉偿播聚瓷隘救豹诗戌钢蕾募黑娶剿真暴耸酱聋逢汁熬撩撇县这计算机图形学computer graphics课件5计算机图形学computer graphics课件5,

    注意事项

    本文(计算机图形学computergraphics课件5.ppt)为本站会员(夺命阿水)主动上传,课桌文档仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知课桌文档(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-1

    经营许可证:宁B2-20210002

    宁公网安备 64010402000986号

    课桌文档
    收起
    展开