计算机图形学computergraphics课件5.ppt
《计算机图形学computergraphics课件5.ppt》由会员分享,可在线阅读,更多相关《计算机图形学computergraphics课件5.ppt(23页珍藏版)》请在课桌文档上搜索。
1、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-d
2、imensional 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
3、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 v
4、ersion,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
5、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();,饶哟饼化哨典伊氧帅整
6、句远丛览憾雕弹秀黄悬权嘉善出呵拷愁瘤罗澄躯尤计算机图形学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 graphi
7、cs课件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 corne
8、r 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);glMatrixMo
9、de(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 applicatio
10、n 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 i
11、nternal 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 c
12、entered 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,邪懊靖赦做堪傻凯似继吸
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 图形学 computergraphics 课件
链接地址:https://www.desk33.com/p-619980.html